src/cx/properties.h

Sun, 05 Jan 2025 13:19:56 +0100

author
Mike Becker <universe@uap-core.de>
date
Sun, 05 Jan 2025 13:19:56 +0100
changeset 1106
0480f8600fb7
parent 1069
6565e7ef5ee3
permissions
-rw-r--r--

refine docs for properties.h - issue #548

923
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1 /*
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
3 *
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
4 * Copyright 2024 Mike Becker, Olaf Wintermann All rights reserved.
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
5 *
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
8 *
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
11 *
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
15 *
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
27 */
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
28 /**
1106
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
29 * @file properties.h
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
30 * @brief Interface for parsing data from properties files.
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
31 * @author Mike Becker
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
32 * @author Olaf Wintermann
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
33 * @copyright 2-Clause BSD License
923
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
34 */
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
35
1069
6565e7ef5ee3 fix include guard for properties.h
Mike Becker <universe@uap-core.de>
parents: 1059
diff changeset
36 #ifndef UCX_PROPERTIES_H
6565e7ef5ee3 fix include guard for properties.h
Mike Becker <universe@uap-core.de>
parents: 1059
diff changeset
37 #define UCX_PROPERTIES_H
923
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
38
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
39 #include "common.h"
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
40 #include "string.h"
928
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
41 #include "map.h"
1031
8a90552bba29 rework of properties parser - fixes #529 and resolves #458
Mike Becker <universe@uap-core.de>
parents: 1013
diff changeset
42 #include "buffer.h"
923
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
43
928
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
44 #include <stdio.h>
972
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
45 #include <string.h>
928
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
46
932
484dab606292 add extern "C" to properties.h
Mike Becker <universe@uap-core.de>
parents: 928
diff changeset
47 #ifdef __cplusplus
484dab606292 add extern "C" to properties.h
Mike Becker <universe@uap-core.de>
parents: 928
diff changeset
48 extern "C" {
484dab606292 add extern "C" to properties.h
Mike Becker <universe@uap-core.de>
parents: 928
diff changeset
49 #endif
484dab606292 add extern "C" to properties.h
Mike Becker <universe@uap-core.de>
parents: 928
diff changeset
50
1036
6d29532a76c3 add missing documentation for struct cx_properties_config_s
Mike Becker <universe@uap-core.de>
parents: 1031
diff changeset
51 /**
6d29532a76c3 add missing documentation for struct cx_properties_config_s
Mike Becker <universe@uap-core.de>
parents: 1031
diff changeset
52 * Configures the expected characters for the properties parser.
6d29532a76c3 add missing documentation for struct cx_properties_config_s
Mike Becker <universe@uap-core.de>
parents: 1031
diff changeset
53 */
923
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
54 struct cx_properties_config_s {
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
55 /**
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
56 * The key/value delimiter that shall be used.
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
57 * This is '=' by default.
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
58 */
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
59 char delimiter;
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
60
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
61 /**
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
62 * The character, when appearing at the end of a line, continues that line.
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
63 * This is '\' by default.
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
64 */
924
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
65 // char continuation; // TODO: line continuation in properties
923
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
66
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
67 /**
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
68 * The first comment character.
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
69 * This is '#' by default.
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
70 */
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
71 char comment1;
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
72
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
73 /**
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
74 * The second comment character.
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
75 * This is not set by default.
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
76 */
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
77 char comment2;
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
78
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
79 /**
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
80 * The third comment character.
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
81 * This is not set by default.
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
82 */
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
83 char comment3;
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
84 };
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
85
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
86 /**
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
87 * Typedef for the properties config.
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
88 */
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
89 typedef struct cx_properties_config_s CxPropertiesConfig;
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
90
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
91 /**
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
92 * Default properties configuration.
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
93 */
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
94 extern const CxPropertiesConfig cx_properties_config_default;
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
95
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
96 /**
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
97 * Status codes for the properties interface.
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
98 */
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
99 enum cx_properties_status {
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
100 /**
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
101 * Everything is fine.
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
102 */
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
103 CX_PROPERTIES_NO_ERROR,
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
104 /**
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
105 * The input buffer does not contain more data.
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
106 */
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
107 CX_PROPERTIES_NO_DATA,
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
108 /**
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
109 * The input ends unexpectedly.
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
110 *
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
111 * This either happens when the last line does not terminate with a line
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
112 * break, or when the input ends with a parsed key but no value.
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
113 */
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
114 CX_PROPERTIES_INCOMPLETE_DATA,
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
115 /**
928
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
116 * Not used as a status and never returned by any function.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
117 *
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
118 * You can use this enumerator to check for all "good" status results
1106
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
119 * by checking if the status is less than @c CX_PROPERTIES_OK.
928
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
120 *
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
121 * A "good" status means, that you can refill data and continue parsing.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
122 */
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
123 CX_PROPERTIES_OK,
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
124 /**
1106
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
125 * Input buffer is @c NULL.
923
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
126 */
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
127 CX_PROPERTIES_NULL_INPUT,
924
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
128 /**
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
129 * The line contains a delimiter, but no key.
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
130 */
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
131 CX_PROPERTIES_INVALID_EMPTY_KEY,
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
132 /**
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
133 * The line contains data, but no delimiter.
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
134 */
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
135 CX_PROPERTIES_INVALID_MISSING_DELIMITER,
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
136 /**
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
137 * More internal buffer was needed, but could not be allocated.
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
138 */
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
139 CX_PROPERTIES_BUFFER_ALLOC_FAILED,
928
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
140 /**
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
141 * Initializing the properties source failed.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
142 *
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
143 * @see cx_properties_read_init_func
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
144 */
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
145 CX_PROPERTIES_READ_INIT_FAILED,
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
146 /**
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
147 * Reading from a properties source failed.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
148 *
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
149 * @see cx_properties_read_func
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
150 */
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
151 CX_PROPERTIES_READ_FAILED,
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
152 /**
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
153 * Sinking a k/v-pair failed.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
154 *
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
155 * @see cx_properties_sink_func
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
156 */
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
157 CX_PROPERTIES_SINK_FAILED,
923
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
158 };
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
159
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
160 /**
928
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
161 * Typedef for the properties status enum.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
162 */
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
163 typedef enum cx_properties_status CxPropertiesStatus;
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
164
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
165 /**
923
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
166 * Interface for working with properties data.
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
167 */
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
168 struct cx_properties_s {
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
169 /**
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
170 * The configuration.
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
171 */
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
172 CxPropertiesConfig config;
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
173
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
174 /**
1031
8a90552bba29 rework of properties parser - fixes #529 and resolves #458
Mike Becker <universe@uap-core.de>
parents: 1013
diff changeset
175 * The text input buffer.
923
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
176 */
1031
8a90552bba29 rework of properties parser - fixes #529 and resolves #458
Mike Becker <universe@uap-core.de>
parents: 1013
diff changeset
177 CxBuffer input;
924
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
178
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
179 /**
1031
8a90552bba29 rework of properties parser - fixes #529 and resolves #458
Mike Becker <universe@uap-core.de>
parents: 1013
diff changeset
180 * Internal buffer.
924
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
181 */
1031
8a90552bba29 rework of properties parser - fixes #529 and resolves #458
Mike Becker <universe@uap-core.de>
parents: 1013
diff changeset
182 CxBuffer buffer;
923
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
183 };
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
184
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
185 /**
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
186 * Typedef for the properties interface.
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
187 */
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
188 typedef struct cx_properties_s CxProperties;
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
189
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
190
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
191 /**
928
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
192 * Typedef for a properties sink.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
193 */
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
194 typedef struct cx_properties_sink_s CxPropertiesSink;
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
195
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
196 /**
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
197 * A function that consumes a k/v-pair in a sink.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
198 *
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
199 * The sink could be e.g. a map and the sink function would be calling
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
200 * a map function to store the k/v-pair.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
201 *
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
202 * @param prop the properties interface that wants to sink a k/v-pair
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
203 * @param sink the sink
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
204 * @param key the key
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
205 * @param value the value
1106
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
206 * @retval zero success
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
207 * @retval non-zero sinking the k/v-pair failed
928
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
208 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 980
diff changeset
209 cx_attr_nonnull
928
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
210 typedef int(*cx_properties_sink_func)(
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
211 CxProperties *prop,
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
212 CxPropertiesSink *sink,
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
213 cxstring key,
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
214 cxstring value
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
215 );
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
216
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
217 /**
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
218 * Defines a sink for k/v-pairs.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
219 */
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
220 struct cx_properties_sink_s {
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
221 /**
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
222 * The sink object.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
223 */
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
224 void *sink;
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
225 /**
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
226 * Optional custom data.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
227 */
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
228 void *data;
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
229 /**
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
230 * A function for consuming k/v-pairs into the sink.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
231 */
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
232 cx_properties_sink_func sink_func;
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
233 };
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
234
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
235
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
236 /**
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
237 * Typedef for a properties source.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
238 */
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
239 typedef struct cx_properties_source_s CxPropertiesSource;
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
240
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
241 /**
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
242 * A function that reads data from a source.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
243 *
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
244 * When the source is depleted, implementations SHALL provide an empty
1106
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
245 * string in the @p target and return zero.
928
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
246 * A non-zero return value is only permitted in case of an error.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
247 *
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
248 * The meaning of the optional parameters is implementation-dependent.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
249 *
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
250 * @param prop the properties interface that wants to read from the source
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
251 * @param src the source
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
252 * @param target a string buffer where the read data shall be stored
1106
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
253 * @retval zero success
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
254 * @retval non-zero reading the data failed
928
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
255 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 980
diff changeset
256 cx_attr_nonnull
928
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
257 typedef int(*cx_properties_read_func)(
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
258 CxProperties *prop,
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
259 CxPropertiesSource *src,
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
260 cxstring *target
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
261 );
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
262
932
484dab606292 add extern "C" to properties.h
Mike Becker <universe@uap-core.de>
parents: 928
diff changeset
263 /**
484dab606292 add extern "C" to properties.h
Mike Becker <universe@uap-core.de>
parents: 928
diff changeset
264 * A function that may initialize additional memory for the source.
484dab606292 add extern "C" to properties.h
Mike Becker <universe@uap-core.de>
parents: 928
diff changeset
265 *
484dab606292 add extern "C" to properties.h
Mike Becker <universe@uap-core.de>
parents: 928
diff changeset
266 * @param prop the properties interface that wants to read from the source
484dab606292 add extern "C" to properties.h
Mike Becker <universe@uap-core.de>
parents: 928
diff changeset
267 * @param src the source
1106
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
268 * @retval zero initialization was successful
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
269 * @retval non-zero otherwise
932
484dab606292 add extern "C" to properties.h
Mike Becker <universe@uap-core.de>
parents: 928
diff changeset
270 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 980
diff changeset
271 cx_attr_nonnull
928
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
272 typedef int(*cx_properties_read_init_func)(
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
273 CxProperties *prop,
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
274 CxPropertiesSource *src
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
275 );
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
276
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
277 /**
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
278 * A function that cleans memory initialized by the read_init_func.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
279 *
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
280 * @param prop the properties interface that wants to read from the source
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
281 * @param src the source
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
282 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 980
diff changeset
283 cx_attr_nonnull
928
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
284 typedef void(*cx_properties_read_clean_func)(
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
285 CxProperties *prop,
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
286 CxPropertiesSource *src
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
287 );
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
288
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
289 /**
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
290 * Defines a properties source.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
291 */
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
292 struct cx_properties_source_s {
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
293 /**
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
294 * The source object.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
295 *
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
296 * For example a file stream or a string.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
297 */
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
298 void *src;
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
299 /**
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
300 * Optional additional data pointer.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
301 */
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
302 void *data_ptr;
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
303 /**
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
304 * Optional size information.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
305 */
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
306 size_t data_size;
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
307 /**
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
308 * A function that reads data from the source.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
309 */
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
310 cx_properties_read_func read_func;
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
311 /**
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
312 * Optional function that may prepare the source for reading data.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
313 */
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
314 cx_properties_read_init_func read_init_func;
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
315 /**
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
316 * Optional function that cleans additional memory allocated by the
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
317 * read_init_func.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
318 */
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
319 cx_properties_read_clean_func read_clean_func;
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
320 };
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
321
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
322 /**
924
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
323 * Initialize a properties interface.
923
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
324 *
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
325 * @param prop the properties interface
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
326 * @param config the properties configuration
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
327 * @see cxPropertiesInitDefault()
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
328 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 980
diff changeset
329 cx_attr_nonnull
924
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
330 void cxPropertiesInit(CxProperties *prop, CxPropertiesConfig config);
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
331
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
332 /**
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
333 * Destroys the properties interface.
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
334 *
1106
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
335 * @note Even when you are certain that you did not use the interface in a
924
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
336 * way that caused a memory allocation, you should call this function anyway.
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
337 * Future versions of the library might add features that need additional memory
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
338 * and you really don't want to search the entire code where you might need
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
339 * add call to this function.
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
340 *
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
341 * @param prop the properties interface
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
342 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 980
diff changeset
343 cx_attr_nonnull
924
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
344 void cxPropertiesDestroy(CxProperties *prop);
923
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
345
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
346 /**
1013
add8358fc3c3 add cxJsonReset() and cxPropertiesReset()
Mike Becker <universe@uap-core.de>
parents: 988
diff changeset
347 * Destroys and re-initializes the properties interface.
add8358fc3c3 add cxJsonReset() and cxPropertiesReset()
Mike Becker <universe@uap-core.de>
parents: 988
diff changeset
348 *
add8358fc3c3 add cxJsonReset() and cxPropertiesReset()
Mike Becker <universe@uap-core.de>
parents: 988
diff changeset
349 * You might want to use this, to reset the parser after
add8358fc3c3 add cxJsonReset() and cxPropertiesReset()
Mike Becker <universe@uap-core.de>
parents: 988
diff changeset
350 * encountering a syntax error.
add8358fc3c3 add cxJsonReset() and cxPropertiesReset()
Mike Becker <universe@uap-core.de>
parents: 988
diff changeset
351 *
add8358fc3c3 add cxJsonReset() and cxPropertiesReset()
Mike Becker <universe@uap-core.de>
parents: 988
diff changeset
352 * @param prop the properties interface
add8358fc3c3 add cxJsonReset() and cxPropertiesReset()
Mike Becker <universe@uap-core.de>
parents: 988
diff changeset
353 */
add8358fc3c3 add cxJsonReset() and cxPropertiesReset()
Mike Becker <universe@uap-core.de>
parents: 988
diff changeset
354 cx_attr_nonnull
add8358fc3c3 add cxJsonReset() and cxPropertiesReset()
Mike Becker <universe@uap-core.de>
parents: 988
diff changeset
355 static inline void cxPropertiesReset(CxProperties *prop) {
add8358fc3c3 add cxJsonReset() and cxPropertiesReset()
Mike Becker <universe@uap-core.de>
parents: 988
diff changeset
356 CxPropertiesConfig config = prop->config;
add8358fc3c3 add cxJsonReset() and cxPropertiesReset()
Mike Becker <universe@uap-core.de>
parents: 988
diff changeset
357 cxPropertiesDestroy(prop);
add8358fc3c3 add cxJsonReset() and cxPropertiesReset()
Mike Becker <universe@uap-core.de>
parents: 988
diff changeset
358 cxPropertiesInit(prop, config);
add8358fc3c3 add cxJsonReset() and cxPropertiesReset()
Mike Becker <universe@uap-core.de>
parents: 988
diff changeset
359 }
add8358fc3c3 add cxJsonReset() and cxPropertiesReset()
Mike Becker <universe@uap-core.de>
parents: 988
diff changeset
360
add8358fc3c3 add cxJsonReset() and cxPropertiesReset()
Mike Becker <universe@uap-core.de>
parents: 988
diff changeset
361 /**
923
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
362 * Initialize a properties parser with the default configuration.
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
363 *
1106
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
364 * @param prop (@c CxProperties*) the properties interface
923
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
365 * @see cxPropertiesInit()
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
366 */
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
367 #define cxPropertiesInitDefault(prop) \
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
368 cxPropertiesInit(prop, cx_properties_config_default)
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
369
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
370 /**
972
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
371 * Fills the input buffer with data.
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
372 *
1038
8cab3d8e0af4 fix outdated documentation in properties.h
Mike Becker <universe@uap-core.de>
parents: 1036
diff changeset
373 * After calling this function, you can parse the data by calling
8cab3d8e0af4 fix outdated documentation in properties.h
Mike Becker <universe@uap-core.de>
parents: 1036
diff changeset
374 * cxPropertiesNext().
923
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
375 *
1058
d347f74ce7d1 downgrades the severity of the advice in cxPropertiesFilln() from attention to remark
Mike Becker <universe@uap-core.de>
parents: 1038
diff changeset
376 * @remark The properties interface tries to avoid allocations.
1038
8cab3d8e0af4 fix outdated documentation in properties.h
Mike Becker <universe@uap-core.de>
parents: 1036
diff changeset
377 * When you use this function and cxPropertiesNext() interleaving,
8cab3d8e0af4 fix outdated documentation in properties.h
Mike Becker <universe@uap-core.de>
parents: 1036
diff changeset
378 * no allocations are performed. However, you must not free the
8cab3d8e0af4 fix outdated documentation in properties.h
Mike Becker <universe@uap-core.de>
parents: 1036
diff changeset
379 * pointer to the data in that case. When you invoke the fill
8cab3d8e0af4 fix outdated documentation in properties.h
Mike Becker <universe@uap-core.de>
parents: 1036
diff changeset
380 * function more than once before calling cxPropertiesNext(),
8cab3d8e0af4 fix outdated documentation in properties.h
Mike Becker <universe@uap-core.de>
parents: 1036
diff changeset
381 * the additional data is appended - inevitably leading to
8cab3d8e0af4 fix outdated documentation in properties.h
Mike Becker <universe@uap-core.de>
parents: 1036
diff changeset
382 * an allocation of a new buffer and copying the previous contents.
923
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
383 *
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
384 * @param prop the properties interface
1038
8cab3d8e0af4 fix outdated documentation in properties.h
Mike Becker <universe@uap-core.de>
parents: 1036
diff changeset
385 * @param buf a pointer to the data
923
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
386 * @param len the length of the data
1106
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
387 * @retval zero success
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
388 * @retval non-zero a memory allocation was necessary but failed
1059
154eb64ce746 add references between both variants of the properties fill function
Mike Becker <universe@uap-core.de>
parents: 1058
diff changeset
389 * @see cxPropertiesFill()
923
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
390 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 980
diff changeset
391 cx_attr_nonnull
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 980
diff changeset
392 cx_attr_access_r(2, 3)
972
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
393 int cxPropertiesFilln(
923
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
394 CxProperties *prop,
924
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
395 const char *buf,
923
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
396 size_t len
924
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
397 );
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
398
988
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
399 #ifdef __cplusplus
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
400 } // extern "C"
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
401 cx_attr_nonnull
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
402 static inline int cxPropertiesFill(
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
403 CxProperties *prop,
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
404 cxstring str
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
405 ) {
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
406 return cxPropertiesFilln(prop, str.ptr, str.length);
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
407 }
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
408
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
409 cx_attr_nonnull
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
410 static inline int cxPropertiesFill(
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
411 CxProperties *prop,
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
412 cxmutstr str
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
413 ) {
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
414 return cxPropertiesFilln(prop, str.ptr, str.length);
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
415 }
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
416
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
417 cx_attr_nonnull
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
418 cx_attr_cstr_arg(2)
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
419 static inline int cxPropertiesFill(
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
420 CxProperties *prop,
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
421 const char *str
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
422 ) {
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
423 return cxPropertiesFilln(prop, str, strlen(str));
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
424 }
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
425
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
426 extern "C" {
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
427 #else // __cplusplus
924
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
428 /**
1038
8cab3d8e0af4 fix outdated documentation in properties.h
Mike Becker <universe@uap-core.de>
parents: 1036
diff changeset
429 * Fills the input buffer with data.
8cab3d8e0af4 fix outdated documentation in properties.h
Mike Becker <universe@uap-core.de>
parents: 1036
diff changeset
430 *
8cab3d8e0af4 fix outdated documentation in properties.h
Mike Becker <universe@uap-core.de>
parents: 1036
diff changeset
431 * After calling this function, you can parse the data by calling
8cab3d8e0af4 fix outdated documentation in properties.h
Mike Becker <universe@uap-core.de>
parents: 1036
diff changeset
432 * cxPropertiesNext().
924
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
433 *
1038
8cab3d8e0af4 fix outdated documentation in properties.h
Mike Becker <universe@uap-core.de>
parents: 1036
diff changeset
434 * @attention The properties interface tries to avoid allocations.
8cab3d8e0af4 fix outdated documentation in properties.h
Mike Becker <universe@uap-core.de>
parents: 1036
diff changeset
435 * When you use this function and cxPropertiesNext() interleaving,
8cab3d8e0af4 fix outdated documentation in properties.h
Mike Becker <universe@uap-core.de>
parents: 1036
diff changeset
436 * no allocations are performed. However, you must not free the
8cab3d8e0af4 fix outdated documentation in properties.h
Mike Becker <universe@uap-core.de>
parents: 1036
diff changeset
437 * pointer to the data in that case. When you invoke the fill
8cab3d8e0af4 fix outdated documentation in properties.h
Mike Becker <universe@uap-core.de>
parents: 1036
diff changeset
438 * function more than once before calling cxPropertiesNext(),
8cab3d8e0af4 fix outdated documentation in properties.h
Mike Becker <universe@uap-core.de>
parents: 1036
diff changeset
439 * the additional data is appended - inevitably leading to
8cab3d8e0af4 fix outdated documentation in properties.h
Mike Becker <universe@uap-core.de>
parents: 1036
diff changeset
440 * an allocation of a new buffer and copying the previous contents.
924
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
441 *
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
442 * @param prop the properties interface
1038
8cab3d8e0af4 fix outdated documentation in properties.h
Mike Becker <universe@uap-core.de>
parents: 1036
diff changeset
443 * @param str the text to fill in
1106
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
444 * @retval zero success
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
445 * @retval non-zero a memory allocation was necessary but failed
1059
154eb64ce746 add references between both variants of the properties fill function
Mike Becker <universe@uap-core.de>
parents: 1058
diff changeset
446 * @see cxPropertiesFilln()
972
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
447 */
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
448 #define cxPropertiesFill(prop, str) _Generic((str), \
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
449 cxstring: cx_properties_fill_cxstr, \
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
450 cxmutstr: cx_properties_fill_mutstr, \
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
451 char*: cx_properties_fill_str, \
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
452 const char*: cx_properties_fill_str) \
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
453 (prop, str)
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
454
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
455 /**
1038
8cab3d8e0af4 fix outdated documentation in properties.h
Mike Becker <universe@uap-core.de>
parents: 1036
diff changeset
456 * @copydoc cxPropertiesFill()
924
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
457 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 980
diff changeset
458 cx_attr_nonnull
972
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
459 static inline int cx_properties_fill_cxstr(
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
460 CxProperties *prop,
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
461 cxstring str
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
462 ) {
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
463 return cxPropertiesFilln(prop, str.ptr, str.length);
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
464 }
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
465
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
466 /**
1038
8cab3d8e0af4 fix outdated documentation in properties.h
Mike Becker <universe@uap-core.de>
parents: 1036
diff changeset
467 * @copydoc cxPropertiesFill()
972
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
468 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 980
diff changeset
469 cx_attr_nonnull
972
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
470 static inline int cx_properties_fill_mutstr(
924
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
471 CxProperties *prop,
972
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
472 cxmutstr str
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
473 ) {
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
474 return cxPropertiesFilln(prop, str.ptr, str.length);
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
475 }
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
476
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
477 /**
1038
8cab3d8e0af4 fix outdated documentation in properties.h
Mike Becker <universe@uap-core.de>
parents: 1036
diff changeset
478 * @copydoc cxPropertiesFill()
972
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
479 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 980
diff changeset
480 cx_attr_nonnull
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 980
diff changeset
481 cx_attr_cstr_arg(2)
972
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
482 static inline int cx_properties_fill_str(
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
483 CxProperties *prop,
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
484 const char *str
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
485 ) {
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
486 return cxPropertiesFilln(prop, str, strlen(str));
a9a1d07a6840 add support for UCX strings in cxPropertiesFill()
Mike Becker <universe@uap-core.de>
parents: 932
diff changeset
487 }
988
15b3ca7ee33f make ucx C++ compatible again (and add tests for it) - fixes #486
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
488 #endif
924
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
489
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
490 /**
1031
8a90552bba29 rework of properties parser - fixes #529 and resolves #458
Mike Becker <universe@uap-core.de>
parents: 1013
diff changeset
491 * Specifies stack memory that shall be used as internal buffer.
924
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
492 *
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
493 * @param prop the properties interface
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
494 * @param buf a pointer to stack memory
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
495 * @param capacity the capacity of the stack memory
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
496 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 980
diff changeset
497 cx_attr_nonnull
924
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
498 void cxPropertiesUseStack(
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
499 CxProperties *prop,
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
500 char *buf,
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
501 size_t capacity
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
502 );
923
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
503
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
504 /**
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
505 * Retrieves the next key/value-pair.
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
506 *
924
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
507 * This function returns zero as long as there are key/value-pairs found.
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
508 * If no more key/value-pairs are found, #CX_PROPERTIES_NO_DATA is returned.
923
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
509 *
924
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
510 * When an incomplete line is encountered, #CX_PROPERTIES_INCOMPLETE_DATA is
1038
8cab3d8e0af4 fix outdated documentation in properties.h
Mike Becker <universe@uap-core.de>
parents: 1036
diff changeset
511 * returned, and you can add more data with #cxPropertiesFill().
8cab3d8e0af4 fix outdated documentation in properties.h
Mike Becker <universe@uap-core.de>
parents: 1036
diff changeset
512 *
1106
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
513 * @remark The incomplete line will be stored in an internal buffer, which is
1038
8cab3d8e0af4 fix outdated documentation in properties.h
Mike Becker <universe@uap-core.de>
parents: 1036
diff changeset
514 * allocated on the heap, by default. If you want to avoid allocations,
8cab3d8e0af4 fix outdated documentation in properties.h
Mike Becker <universe@uap-core.de>
parents: 1036
diff changeset
515 * you can specify sufficient space with cxPropertiesUseStack() after
8cab3d8e0af4 fix outdated documentation in properties.h
Mike Becker <universe@uap-core.de>
parents: 1036
diff changeset
516 * initialization with cxPropertiesInit().
924
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
517 *
1106
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
518 * @attention The returned strings will point into a buffer that might not be
924
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
519 * available later. It is strongly recommended to copy the strings for further
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
520 * use.
923
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
521 *
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
522 * @param prop the properties interface
924
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
523 * @param key a pointer to the cxstring that shall contain the property name
923
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
524 * @param value a pointer to the cxstring that shall contain the property value
1106
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
525 * @retval CX_PROPERTIES_NO_ERROR (zero) a key/value pair was found
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
526 * @retval CX_PROPERTIES_NO_DATA there is no (more) data in the input buffer
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
527 * @retval CX_PROPERTIES_INCOMPLETE_DATA the data in the input buffer is incomplete
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
528 * (fill more data and try again)
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
529 * @retval CX_PROPERTIES_NULL_INPUT the input buffer was never filled
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
530 * @retval CX_PROPERTIES_INVALID_EMPTY_KEY the properties data contains an illegal empty key
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
531 * @retval CX_PROPERTIES_INVALID_MISSING_DELIMITER the properties data contains a line without delimiter
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
532 * @retval CX_PROPERTIES_BUFFER_ALLOC_FAILED an internal allocation was necessary but failed
923
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
533 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 980
diff changeset
534 cx_attr_nonnull
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 980
diff changeset
535 cx_attr_nodiscard
928
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
536 CxPropertiesStatus cxPropertiesNext(
923
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
537 CxProperties *prop,
924
3c90dfc35f06 add implementation for the properties parser
Mike Becker <universe@uap-core.de>
parents: 923
diff changeset
538 cxstring *key,
923
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
539 cxstring *value
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
540 );
45da884269c8 add ucx2.1 style interface for a properties parser
Mike Becker <universe@uap-core.de>
parents:
diff changeset
541
928
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
542 /**
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
543 * Creates a properties sink for an UCX map.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
544 *
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
545 * The values stored in the map will be pointers to strings allocated
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
546 * by #cx_strdup_a().
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
547 * The default stdlib allocator will be used, unless you specify a custom
1106
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
548 * allocator in the optional @c data of the sink.
928
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
549 *
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
550 * @param map the map that shall consume the k/v-pairs.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
551 * @return the sink
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
552 * @see cxPropertiesLoad()
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
553 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 980
diff changeset
554 cx_attr_nonnull
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 980
diff changeset
555 cx_attr_nodiscard
928
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
556 CxPropertiesSink cxPropertiesMapSink(CxMap *map);
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
557
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
558 /**
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
559 * Creates a properties source based on an UCX string.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
560 *
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
561 * @param str the string
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
562 * @return the properties source
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
563 * @see cxPropertiesLoad()
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
564 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 980
diff changeset
565 cx_attr_nodiscard
928
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
566 CxPropertiesSource cxPropertiesStringSource(cxstring str);
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
567
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
568 /**
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
569 * Creates a properties source based on C string with the specified length.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
570 *
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
571 * @param str the string
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
572 * @param len the length
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
573 * @return the properties source
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
574 * @see cxPropertiesLoad()
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
575 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 980
diff changeset
576 cx_attr_nonnull
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 980
diff changeset
577 cx_attr_nodiscard
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 980
diff changeset
578 cx_attr_access_r(1, 2)
928
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
579 CxPropertiesSource cxPropertiesCstrnSource(const char *str, size_t len);
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
580
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
581 /**
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
582 * Creates a properties source based on a C string.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
583 *
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
584 * The length will be determined with strlen(), so the string MUST be
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
585 * zero-terminated.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
586 *
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
587 * @param str the string
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
588 * @return the properties source
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
589 * @see cxPropertiesLoad()
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
590 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 980
diff changeset
591 cx_attr_nonnull
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 980
diff changeset
592 cx_attr_nodiscard
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 980
diff changeset
593 cx_attr_cstr_arg(1)
928
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
594 CxPropertiesSource cxPropertiesCstrSource(const char *str);
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
595
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
596 /**
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
597 * Creates a properties source based on an FILE.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
598 *
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
599 * @param file the file
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
600 * @param chunk_size how many bytes may be read in one operation
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
601 *
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
602 * @return the properties source
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
603 * @see cxPropertiesLoad()
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
604 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 980
diff changeset
605 cx_attr_nonnull
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 980
diff changeset
606 cx_attr_nodiscard
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 980
diff changeset
607 cx_attr_access_r(1)
928
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
608 CxPropertiesSource cxPropertiesFileSource(FILE *file, size_t chunk_size);
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
609
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
610
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
611 /**
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
612 * Loads properties data from a source and transfers it to a sink.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
613 *
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
614 * This function tries to read as much data from the source as possible.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
615 * When the source was completely consumed and at least on k/v-pair was found,
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
616 * the return value will be #CX_PROPERTIES_NO_ERROR.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
617 * When the source was consumed but no k/v-pairs were found, the return value
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
618 * will be #CX_PROPERTIES_NO_DATA.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
619 * The other result codes apply, according to their description.
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
620 *
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
621 * @param prop the properties interface
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
622 * @param sink the sink
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
623 * @param source the source
1106
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
624 * @retval CX_PROPERTIES_NO_ERROR (zero) a key/value pair was found
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
625 * @retval CX_PROPERTIES_READ_INIT_FAILED initializing the source failed
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
626 * @retval CX_PROPERTIES_READ_FAILED reading from the source failed
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
627 * @retval CX_PROPERTIES_SINK_FAILED sinking the properties into the sink failed
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
628 * @retval CX_PROPERTIES_NO_DATA the source did not provide any key/value pairs
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
629 * @retval CX_PROPERTIES_INVALID_EMPTY_KEY the properties data contains an illegal empty key
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
630 * @retval CX_PROPERTIES_INVALID_MISSING_DELIMITER the properties data contains a line without delimiter
0480f8600fb7 refine docs for properties.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1069
diff changeset
631 * @retval CX_PROPERTIES_BUFFER_ALLOC_FAILED an internal allocation was necessary but failed
928
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
632 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 980
diff changeset
633 cx_attr_nonnull
928
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
634 CxPropertiesStatus cxPropertiesLoad(
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
635 CxProperties *prop,
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
636 CxPropertiesSink sink,
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
637 CxPropertiesSource source
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
638 );
d2d42cb1d59e add source/sink facility for properties - fixes #430
Mike Becker <universe@uap-core.de>
parents: 924
diff changeset
639
932
484dab606292 add extern "C" to properties.h
Mike Becker <universe@uap-core.de>
parents: 928
diff changeset
640 #ifdef __cplusplus
484dab606292 add extern "C" to properties.h
Mike Becker <universe@uap-core.de>
parents: 928
diff changeset
641 } // extern "C"
484dab606292 add extern "C" to properties.h
Mike Becker <universe@uap-core.de>
parents: 928
diff changeset
642 #endif
484dab606292 add extern "C" to properties.h
Mike Becker <universe@uap-core.de>
parents: 928
diff changeset
643
1069
6565e7ef5ee3 fix include guard for properties.h
Mike Becker <universe@uap-core.de>
parents: 1059
diff changeset
644 #endif // UCX_PROPERTIES_H

mercurial