ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/include/confparse.h
(Generate patch)

Comparing ermyth/include/confparse.h (file contents):
Revision 1.3 by pippijn, Tue Aug 28 17:08:06 2007 UTC vs.
Revision 1.4 by pippijn, Tue Aug 28 22:18:30 2007 UTC

2 * Copyright © 2005 William Pitcock, et al. 2 * Copyright © 2005 William Pitcock, et al.
3 * Rights to this code are as documented in doc/pod/license.pod. 3 * Rights to this code are as documented in doc/pod/license.pod.
4 * 4 *
5 * Data structures for flags to bitmask processing routines. 5 * Data structures for flags to bitmask processing routines.
6 * 6 *
7 * $Id: confparse.h,v 1.3 2007/08/28 17:08:06 pippijn Exp $ 7 * $Id: confparse.h,v 1.4 2007/08/28 22:18:30 pippijn Exp $
8 */ 8 */
9 9
10#ifndef CONFPARSE_H 10#ifndef CONFPARSE_H
11#define CONFPARSE_H 11#define CONFPARSE_H
12 12
13#include <ermyth/callback.h> 13#include <ermyth/callback.h>
14#include <ermyth/type_traits.h>
14 15
15struct config_file_t : zero_initialised 16struct config_file_t : zero_initialised
16{ 17{
17 char *cf_filename; 18 char *cf_filename;
18 config_entry_t *cf_entries; 19 config_entry_t *cf_entries;
34 config_entry_t *ce_entries; 35 config_entry_t *ce_entries;
35 36
36 config_entry_t *ce_prevlevel; 37 config_entry_t *ce_prevlevel;
37 38
38 config_entry_t *ce_next; 39 config_entry_t *ce_next;
40
41 bool valid ()
42 {
43 return ce_vardata != NULL;
44 }
45
46 template<typename T>
47 T vardata ()
48 {
49 return vardata (types::get<T> ());
50 }
51
52private:
53 char *vardata (types::charptr_type)
54 {
55 return ce_vardata;
56 }
57
58 int vardata (types::int_type)
59 {
60 return ce_vardatanum;
61 }
39}; 62};
40 63
41struct Token 64struct Token
42{ 65{
43 char const * const text; 66 char const * const text;
44 int const value; 67 int const value;
45}; 68};
46 69
47class ConfTable : public zero_initialised 70class ConfTable
48{ 71{
49 struct callbacks 72 struct callbacks
50 { 73 {
51 functor::callback0<> ready; 74 functor::callback0<> ready;
52 }; 75 };
59 int *int_val; 82 int *int_val;
60 83
61 static callbacks callback; 84 static callbacks callback;
62 85
63 ConfTable (char const * const blockname, int const can_rehash, int (*handlerfunc) (config_entry_t *)) 86 ConfTable (char const * const blockname, int const can_rehash, int (*handlerfunc) (config_entry_t *))
64 : name (blockname), rehashable (can_rehash), handler (handlerfunc) 87 : name (blockname), rehashable (can_rehash), handler (handlerfunc), str_val (0), int_val (0)
65 { 88 {
66 } 89 }
67}; 90};
68 91
69extern void init_newconf (void); 92E void init_newconf (void);
70extern struct ConfTable *find_top_conf (char const * const name); 93E struct ConfTable *find_top_conf (char const * const name);
71extern struct ConfTable *find_conf_item (char const * const name, list_t *conflist); 94E struct ConfTable *find_conf_item (char const * const name, list_t *conflist);
72extern void add_top_conf (char const * const name, int (*handler) (config_entry_t *ce)); 95E void add_top_conf (char const * const name, int (*handler) (config_entry_t *ce));
73extern void add_conf_item (char const * const name, list_t *conflist, int (*handler) (config_entry_t *ce)); 96E void add_conf_item (char const * const name, list_t *conflist, int (*handler) (config_entry_t *ce));
74extern void del_top_conf (char const * const name); 97E void del_top_conf (char const * const name);
75extern void del_conf_item (char const * const name, list_t *conflist); 98E void del_conf_item (char const * const name, list_t *conflist);
76extern int subblock_handler (config_entry_t *ce, list_t *entries); 99E int subblock_handler (config_entry_t *ce, list_t *entries);
77 100
78#endif 101#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines