libini_config
0.2.91
Main Page
Modules
Data Structures
Files
File List
All
Data Structures
Functions
Groups
Pages
ini_valueobj.h
1
/*
2
INI LIBRARY
3
4
Header file for the value object.
5
6
Copyright (C) Dmitri Pal <dpal@redhat.com> 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 "simplebuffer.h"
28
#include "ini_comment.h"
29
30
struct
value_obj;
31
32
#define INI_VALUE_READ 0
/* Value is read from the file */
33
#define INI_VALUE_CREATED 1
/* Value is created in memory */
34
35
/*
36
* Create value from a referenced array.
37
*
38
* NOTE: arrays and comment are NOT treated as
39
* objects that keep reference count.
40
* They are created externally and passed in
41
* as separate parts that are glued together
42
* by the value object.
43
* The caller should not free it himself
44
* (only in case of failure) since
45
* after the call the arrays and comment
46
* are owned by the value object and will
47
* be freed when it is destroyed.
48
*/
49
int
value_create_from_refarray(
struct
ref_array *raw_lines,
50
struct
ref_array *raw_lengths,
51
uint32_t line,
52
uint32_t origin,
53
uint32_t key_len,
54
uint32_t boundary,
55
struct
ini_comment *ic,
56
struct
value_obj **vo);
57
58
/* Cleanup callback for lines array */
59
void
value_lines_cleanup_cb(
void
*elem,
60
ref_array_del_enum type,
61
void
*data);
62
63
/* Create a pair of arrays */
64
int
value_create_arrays(
struct
ref_array **raw_lines,
65
struct
ref_array **raw_lengths);
66
67
/* Add a raw read line to the arrays */
68
int
value_add_to_arrays(
const
char
*strvalue,
69
uint32_t len,
70
struct
ref_array *raw_lines,
71
struct
ref_array *raw_lengths);
72
73
/* Create a pair of arrays */
74
void
value_destroy_arrays(
struct
ref_array *raw_lines,
75
struct
ref_array *raw_lengths);
76
77
/* Create value object from string buffer.
78
* NOTE: see note above
79
* in the description of the
80
* value_create_from_refarray function.
81
*/
82
int
value_create_new(
const
char
*strvalue,
83
uint32_t length,
84
uint32_t origin,
85
uint32_t key_len,
86
uint32_t boundary,
87
struct
ini_comment *ic,
88
struct
value_obj **vo);
89
90
/* Create a copy of the value */
91
int
value_copy(
struct
value_obj *vo,
92
struct
value_obj **copy_vo);
93
94
/* Destroy a value object */
95
void
value_destroy(
struct
value_obj *vo);
96
97
/* Get concatenated value */
98
int
value_get_concatenated(
struct
value_obj *vo,
99
const
char
**fullstr);
100
101
/* Get value's origin */
102
int
value_get_origin(
struct
value_obj *vo,
103
uint32_t *origin);
104
105
/* Get value's line */
106
int
value_get_line(
struct
value_obj *vo,
107
uint32_t *line);
108
109
/* Update key length */
110
int
value_set_keylen(
struct
value_obj *vo,
111
uint32_t key_len);
112
/* Change boundary */
113
int
value_set_boundary(
struct
value_obj *vo,
114
uint32_t boundary);
115
116
/* Update value */
117
int
value_update(
struct
value_obj *vo,
118
const
char
*value,
119
uint32_t length,
120
uint32_t origin,
121
uint32_t boundary);
122
123
/* Get comment from the value */
124
int
value_extract_comment(
struct
value_obj *vo,
125
struct
ini_comment **ic);
126
127
/* Set comment into the value */
128
int
value_put_comment(
struct
value_obj *vo,
129
struct
ini_comment *ic);
130
131
/* Serialize value */
132
int
value_serialize(
struct
value_obj *vo,
133
const
char
*key,
134
struct
simplebuffer *sbobj);
135
136
137
#endif
Generated on Fri Nov 2 2012 20:11:50 for libini_config by
1.8.1.2