/[pearpc]/src/configparser.h
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /src/configparser.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations)
Wed Sep 5 17:11:21 2007 UTC (16 years, 6 months ago) by dpavlin
File MIME type: text/plain
File size: 2127 byte(s)
import upstream CVS
1 /*
2 * PearPC
3 * configparser.cc
4 *
5 * Copyright (C) 2003 Sebastian Biallas (sb@biallas.net)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #ifndef __CONFIGPARSER_H__
22 #define __CONFIGPARSER_H__
23
24 #include "tools/data.h"
25 #include "tools/str.h"
26 #include "tools/stream.h"
27
28 enum ConfigType {
29 configTypeInt,
30 configTypeString,
31 };
32
33 class ConfigEntry: public Object {
34 public:
35 String *mName;
36 bool mMandatory;
37 bool mInitialized;
38 bool mSet;
39
40 ConfigEntry(const String &aName, bool mandatory);
41 virtual ~ConfigEntry();
42 virtual int asInt() const;
43 virtual String &asString(String &result) const;
44 virtual ConfigType getType() const;
45 virtual bool isSet() const;
46 virtual bool isInitialized() const;
47 virtual int compareTo(const Object *obj) const;
48 };
49
50 class ConfigParser: public Object {
51 Container *entries;
52 byte cur;
53 int line;
54 public:
55 ConfigParser();
56 virtual ~ConfigParser();
57
58 void acceptConfigEntryInt(const String &mName, bool mandatory);
59 void acceptConfigEntryString(const String &mName, bool mandatory);
60 void acceptConfigEntryIntDef(const String &mName, int d);
61 void acceptConfigEntryStringDef(const String &mName, const String &d);
62 void loadConfig(Stream &in);
63
64 ConfigEntry *getEntry(const String &name);
65 bool haveKey(const String &name);
66
67 // these will throw an exception if key isn't set!
68 int getConfigInt(const String &name);
69 String &getConfigString(const String &name, String &result);
70 protected:
71 bool skipWhite(Stream &in);
72 void read(Stream &in);
73 };
74
75 extern ConfigParser *gConfig;
76
77 #endif

  ViewVC Help
Powered by ViewVC 1.1.26