Lumiera  0.pre.03
»edit your freedom«
configitem.h
Go to the documentation of this file.
1 /*
2  CONFIGITEM.h - generalised hierarchy of configuration items
3 
4  Copyright (C) Lumiera.org
5  2008, Christian Thaeter <ct@pipapo.org>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
23 
54 #ifndef COMMON_CONFIGITEM_H
55 #define COMMON_CONFIGITEM_H
56 
57 
58 #include "lib/llist.h"
59 
60 /* Forward declarations */
61 typedef struct lumiera_configitem_struct lumiera_configitem;
62 typedef lumiera_configitem* LumieraConfigitem;
63 
65 
66 #include "common/config-lookup.h"
67 
68 #include <nobug.h>
69 
70 
71 
73 {
74  LumieraConfigitem (*newitem)(LumieraConfigitem);
75  LumieraConfigitem (*destroy)(LumieraConfigitem);
76 };
77 
79 {
80  llist link; // all lines on the same hierarchy level are linked here (see children)
81  LumieraConfigitem parent; // parent section
82  llist children; // root node for all lines below this hierarchy
83 
84  llist lookup; // all lines with the same key are stacked up on the lookup
85 
86  char* line; // raw line as read in allocated here trailing \n will be replaced with \0
87  char* key; // pointer into line to start of key
88  size_t key_size;
89  char* delim; // delimiter, value starts at delim+1
90  struct lumiera_configitem_vtable* vtable; // functiontable for subclassing
91 };
92 
93 
94 LumieraConfigitem
95 lumiera_configitem_init (LumieraConfigitem self);
96 
97 LumieraConfigitem
98 lumiera_configitem_destroy (LumieraConfigitem self, LumieraConfigLookup lookup);
99 
100 LumieraConfigitem
101 lumiera_configitem_new (const char* line);
102 
103 void
104 lumiera_configitem_delete (LumieraConfigitem self, LumieraConfigLookup lookup);
105 
106 LumieraConfigitem
107 lumiera_configitem_set_value (LumieraConfigitem self, const char* delim_value);
108 
109 LumieraConfigitem
110 lumiera_configitem_parse (LumieraConfigitem self, const char* line);
111 
112 LumieraConfigitem
113 lumiera_configitem_move (LumieraConfigitem self, LumieraConfigitem dest);
114 
115 
116 #endif /*COMMON_CONFIGITEM_H*/
117 /*
118 // Local Variables:
119 // mode: C
120 // c-file-style: "gnu"
121 // indent-tabs-mode: nil
122 // End:
123 */
Lookup of configuration keys in a low-level configuration system.
Intrusive cyclic double linked list There is only one node type which contains a forward and a backwa...