docs/Writerside/topics/properties.h.md

changeset 1229
9899043d7e39
parent 1190
a7b913d5d589
equal deleted inserted replaced
1228:c231f6a259b5 1229:9899043d7e39
1 # Properties 1 # Properties
2 2
3 The UCX properties parser can be used to parse line-separated key/value strings.
4
3 <warning> 5 <warning>
4 New Feature - will be documented soon! 6 New Feature - documentation work in progress!
5 </warning> 7 </warning>
6 8
7 <!-- 9
8 ## Undocumented Symbols (TODO) 10 ## Basic Parsing
9 ### cx_properties_config_default 11
10 ### cxPropertiesCstrnSource 12 ```C
11 ### cxPropertiesCstrSource 13 #include <cx/properties.h>
12 ### cxPropertiesDestroy 14
13 ### cxPropertiesFileSource 15 typedef struct cx_properties_config_s {
14 ### cxPropertiesFilln 16 char delimiter;
15 ### cxPropertiesInit 17 char comment1;
16 ### cxPropertiesLoad 18 char comment2;
17 ### cxPropertiesMapSink 19 char comment3;
18 ### cxPropertiesNext 20 // reserved for future use - not implemented in UCX 3.1
19 ### cxPropertiesStringSource 21 char continuation;
20 ### cxPropertiesUseStack 22 } CxPropertiesConfig;
21 --> 23
24 void cxPropertiesInit(CxProperties *prop, CxPropertiesConfig config);
25
26 void cxPropertiesInitDefault(CxProperties *prop);
27
28 void cxPropertiesDestroy(CxProperties *prop);
29
30 void cxPropertiesReset(CxProperties *prop);
31
32 int cxPropertiesFilln(CxProperties *prop,
33 const char *buf, size_t len);
34
35 // where S is one of cxstring, cxmutstr, char*, const char*
36 int cxPropertiesFill(CxProperties *prop, S string);
37
38 CxPropertiesStatus cxPropertiesNext(CxProperties *prop,
39 cxstring *key, cxstring *value);
40
41 void cxPropertiesUseStack(CxProperties *prop,
42 char *buf, size_t capacity);
43 ```
44
45 ### List of Status Codes
46
47 ## Sources and Sinks
48
49 ```C
50 #include <cx/properties.h>
51
52 CxPropertiesSource
53 cxPropertiesStringSource(cxstring str);
54
55 CxPropertiesSource
56 cxPropertiesCstrSource(const char *str);
57
58 CxPropertiesSource
59 cxPropertiesCstrnSource(const char *str, size_t len);
60
61 CxPropertiesSource
62 cxPropertiesFileSource(FILE *file, size_t chunk_size);
63
64 CxPropertiesSink
65 cxPropertiesMapSink(CxMap *map);
66
67 CxPropertiesStatus
68 cxPropertiesLoad(CxProperties *prop,
69 CxPropertiesSink sink, CxPropertiesSource source);
70 ```
71
72 ### Creating own Sources and Sinks
73
74 ```C
75 #include <cx/properties.h>
76
77 typedef int(*cx_properties_read_init_func)(CxProperties *prop,
78 CxPropertiesSource *src);
79
80 typedef int(*cx_properties_read_func)(CxProperties *prop,
81 CxPropertiesSource *src, cxstring *target);
82
83 typedef void(*cx_properties_read_clean_func)(CxProperties *prop,
84 CxPropertiesSource *src);
85
86 typedef int(*cx_properties_sink_func)(CxProperties *prop,
87 CxPropertiesSink *sink, cxstring key, cxstring value);
88
89 typedef struct cx_properties_source_s {
90 void *src;
91 void *data_ptr;
92 size_t data_size;
93 cx_properties_read_func read_func;
94 cx_properties_read_init_func read_init_func;
95 cx_properties_read_clean_func read_clean_func;
96 } CxPropertiesSource;
97
98 typedef struct cx_properties_sink_s {
99 void *sink;
100 void *data;
101 cx_properties_sink_func sink_func;
102 } CxPropertiesSink;
103 ```
22 104
23 <seealso> 105 <seealso>
24 <category ref="apidoc"> 106 <category ref="apidoc">
25 <a href="https://ucx.sourceforge.io/api/properties_8h.html">properties.h</a> 107 <a href="https://ucx.sourceforge.io/api/properties_8h.html">properties.h</a>
26 </category> 108 </category>

mercurial