ini_valueobj.h

00001 /*
00002     INI LIBRARY
00003 
00004     Header file for the value object.
00005 
00006     Copyright (C) Dmitri Pal <dpal@redhat.com> 2010
00007 
00008     INI Library is free software: you can redistribute it and/or modify
00009     it under the terms of the GNU Lesser General Public License as published by
00010     the Free Software Foundation, either version 3 of the License, or
00011     (at your option) any later version.
00012 
00013     INI Library is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016     GNU Lesser General Public License for more details.
00017 
00018     You should have received a copy of the GNU Lesser General Public License
00019     along with INI Library.  If not, see <http://www.gnu.org/licenses/>.
00020 */
00021 
00022 
00023 #ifndef INI_VALUEOBJ_H
00024 #define INI_VALUEOBJ_H
00025 
00026 #include "ref_array.h"
00027 #include "simplebuffer.h"
00028 #include "ini_comment.h"
00029 
00030 struct value_obj;
00031 
00032 #define INI_VALUE_READ      0 /* Value is read from the file */
00033 #define INI_VALUE_CREATED   1 /* Value is created in memory  */
00034 
00035 /*
00036  * Create value from a referenced array.
00037  *
00038  * NOTE: arrays and comment are NOT treated as
00039  * objects that keep reference count.
00040  * They are created externally and passed in
00041  * as separate parts that are glued together
00042  * by the value object.
00043  * The caller should not free it himself
00044  * (only in case of failure) since
00045  * after the call the arrays and comment
00046  * are owned by the value object and will
00047  * be freed when it is destroyed.
00048  */
00049 int value_create_from_refarray(struct ref_array *raw_lines,
00050                                struct ref_array *raw_lengths,
00051                                uint32_t line,
00052                                uint32_t origin,
00053                                uint32_t key_len,
00054                                uint32_t boundary,
00055                                struct ini_comment *ic,
00056                                struct value_obj **vo);
00057 
00058 /* Cleanup callback for lines array */
00059 void value_lines_cleanup_cb(void *elem,
00060                             ref_array_del_enum type,
00061                             void *data);
00062 
00063 /* Create a pair of arrays */
00064 int value_create_arrays(struct ref_array **raw_lines,
00065                         struct ref_array **raw_lengths);
00066 
00067 /* Add a raw read line to the arrays */
00068 int value_add_to_arrays(const char *strvalue,
00069                         uint32_t len,
00070                         struct ref_array *raw_lines,
00071                         struct ref_array *raw_lengths);
00072 
00073 /* Create a pair of arrays */
00074 void value_destroy_arrays(struct ref_array *raw_lines,
00075                           struct ref_array *raw_lengths);
00076 
00077 /* Create value object from string buffer.
00078  * NOTE: see note above
00079  * in the description of the
00080  * value_create_from_refarray function.
00081  */
00082 int value_create_new(const char *strvalue,
00083                      uint32_t length,
00084                      uint32_t origin,
00085                      uint32_t key_len,
00086                      uint32_t boundary,
00087                      struct ini_comment *ic,
00088                      struct value_obj **vo);
00089 
00090 /* Destroy a value object */
00091 void value_destroy(struct value_obj *vo);
00092 
00093 /* Get concatenated value */
00094 int value_get_concatenated(struct value_obj *vo,
00095                            const char **fullstr);
00096 
00097 /* Get value's origin */
00098 int value_get_origin(struct value_obj *vo,
00099                      uint32_t *origin);
00100 
00101 /* Get value's line */
00102 int value_get_line(struct value_obj *vo,
00103                    uint32_t *line);
00104 
00105 /* Update key length */
00106 int value_set_keylen(struct value_obj *vo,
00107                      uint32_t key_len);
00108 
00109 /* Update value */
00110 int value_update(struct value_obj *vo,
00111                  const char *value,
00112                  uint32_t length,
00113                  uint32_t origin,
00114                  uint32_t boundary);
00115 
00116 /* Get comment from the value */
00117 int value_extract_comment(struct value_obj *vo,
00118                           struct ini_comment **ic);
00119 
00120 /* Set comment into the value */
00121 int value_put_comment(struct value_obj *vo,
00122                       struct ini_comment *ic);
00123 
00124 /* Serialize value */
00125 int value_serialize(struct value_obj *vo,
00126                     const char *key,
00127                     struct simplebuffer *sbobj);
00128 
00129 
00130 #endif

Generated on Thu Dec 9 12:11:52 2010 for libini_config by  doxygen 1.4.7