Debian Codegraph @

ini/ini_valueobj.h

raw symbols SCIP
1 /*
2 INI LIBRARY
3
4 Header file for the value object.
5
6 Copyright (C) Dmitri Pal <[email protected]> 2010
7
8 INI Library is free software: you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 INI Library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 along with INI Library. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22
23 #ifndef INI_VALUEOBJ_H
24 #define INI_VALUEOBJ_H
25
26 #include "ref_array.h"
27 #include "ini_comment.h"
28
29 struct value_obj;
30
31 #define INI_VALUE_READ 0 /* Value is read from the file */
32 #define INI_VALUE_CREATED 1 /* Value is created in memory */
33
34 /*
35 * Create value from a referenced array.
36 *
37 * NOTE: arrays and comment are NOT treated as
38 * objects that keep reference count.
39 * They are created externally and passed in
40 * as separate parts that are glued together
41 * by the value object.
42 * The caller should not free it himself
43 * (only in case of failure) since
44 * after the call the arrays and comment
45 * are owned by the value object and will
46 * be freed when it is destroyed.
47 */
48 int value_create_from_refarray(struct ref_array *raw_lines,
49 struct ref_array *raw_lengths,
50 uint32_t line,
51 uint32_t origin,
52 uint32_t key_len,
53 uint32_t boundary,
54 struct ini_comment *ic,
55 struct value_obj **vo);
56
57 /* Cleanup callback for lines array */
58 void value_lines_cleanup_cb(void *elem,
59 ref_array_del_enum type,
60 void *data);
61
62 /* Create a pair of arrays */
63 int value_create_arrays(struct ref_array **raw_lines,
64 struct ref_array **raw_lengths);
65
66 /* Add a raw read line to the arrays */
67 int value_add_to_arrays(const char *strvalue,
68 uint32_t len,
69 struct ref_array *raw_lines,
70 struct ref_array *raw_lengths);
71
72 /* Create a pair of arrays */
73 void value_destroy_arrays(struct ref_array *raw_lines,
74 struct ref_array *raw_lengths);
75
76 /* Create value object from string buffer.
77 * NOTE: see note above
78 * in the description of the
79 * value_create_from_refarray function.
80 */
81 int value_create_new(const char *strvalue,
82 uint32_t length,
83 uint32_t origin,
84 uint32_t key_len,
85 uint32_t boundary,
86 struct ini_comment *ic,
87 struct value_obj **vo);
88
89 /* Create a copy of the value */
90 int value_copy(struct value_obj *vo,
91 struct value_obj **copy_vo);
92
93 /* Destroy a value object */
94 void value_destroy(struct value_obj *vo);
95
96 /* Get concatenated value */
97 int value_get_concatenated(struct value_obj *vo,
98 const char **fullstr);
99
100 /* Get length of the concatenated value */
101 int value_get_concatenated_len(struct value_obj *vo,
102 uint32_t *len);
103
104 /* Get value's origin */
105 int value_get_origin(struct value_obj *vo,
106 uint32_t *origin);
107
108 /* Get value's line */
109 int value_get_line(struct value_obj *vo,
110 uint32_t *line);
111
112 /* Update key length */
113 int value_set_keylen(struct value_obj *vo,
114 uint32_t key_len);
115 /* Change boundary */
116 int value_set_boundary(struct value_obj *vo,
117 uint32_t boundary);
118
119 /* Update value */
120 int value_update(struct value_obj *vo,
121 const char *value,
122 uint32_t length,
123 uint32_t origin,
124 uint32_t boundary);
125
126 /* Get comment from the value */
127 int value_extract_comment(struct value_obj *vo,
128 struct ini_comment **ic);
129
130 /* Set comment into the value */
131 int value_put_comment(struct value_obj *vo,
132 struct ini_comment *ic);
133
134 /* Merge comment from one value into another */
135 int value_merge_comment(struct value_obj *vo_donor,
136 struct value_obj *vo);
137
138 /* Print value */
139 void value_print(const char *key, struct value_obj *vo);
140
141 #endif