-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.h
107 lines (88 loc) · 3.05 KB
/
settings.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/* PET
* Platform for Experimentation with efficient HPSG processing Techniques
* (C) 1999 - 2002 Ulrich Callmeier [email protected]
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/** \file settings.h
* Information contained in a settings file.
*/
#ifndef _SETTINGS_H_
#define _SETTINGS_H_
#include "lex-tdl.h"
#include "types.h"
#include <set>
#include <map>
#include <list>
#define SET_EXT ".set"
#define SET_TABLE_SIZE 1024
/** A setting from the settings file (in TDL format) */
struct setting
{
char *name;
int n, allocated;
char **values;
struct lex_location* loc;
};
/** a set of settings with access functions */
class settings
{
public:
settings(std::string name, std::string base, const char *message = 0);
settings(const std::string &input);
~settings();
bool valid() { return _valid; }
const std::string &base() { return _base; }
setting *lookup(const char *name);
const char *value(const char *name);
const char *req_value(const char *name);
// string equality based member test
bool member(const char *name, const char *value);
// type status based member test
bool statusmember(const char *name, type_t key);
// string equality based assoc
const char *assoc(const char *name, const char *key, int arity = 2,
int nth = 1);
#ifndef FLOP
// subtype based map
std::set<std::string> smap(const char *name, int key_type);
#endif
struct lex_location *lloc() { return _lloc; }
//
// to (temporarily) install or uninstall 'extensions' (acting as overlays)
//
void install(settings *);
bool uninstall(settings *);
private:
bool _valid;
int _n;
setting **_set;
std::string _fname, _prefix, _base;
struct lex_location *_lloc;
/** cache for settings converted to lists of integers (e.g. status values) */
std::map<std::string, struct list_int *> _li_cache;
//
// settings can be dynamically 'extended' (see tGrammarUpdate for details),
// where additional settings are read from a file (or [incr tsdb()]) and go
// into effect temporarily, returning to the original configuration once the
// update goes out of scope (typically, as controlled by [incr tsdb()]).
// note that memory ownership for these overlays is /not/ delegatd to the
// .settings. class, i.e. needs to be addressed elsewhere.
//
std::list<settings *> _updates;
void parse();
void parse_one();
};
#endif