summaryrefslogtreecommitdiff
path: root/util/epist/config.hh
diff options
context:
space:
mode:
authorMarius Nita <marius@cs.pdx.edu>2002-08-26 06:36:37 +0000
committerMarius Nita <marius@cs.pdx.edu>2002-08-26 06:36:37 +0000
commit11e643f4b885ee1f96112fcf531739a339691272 (patch)
tree8fb87c401666f4bd29002bdc6e8f6abcc1fecebf /util/epist/config.hh
parenta6d6f0118be066b9bb86e681aa67eca715f4fc69 (diff)
New and improved configuration management. It now handles bool, string and number types, and all conversions happen at initialization time, so retrieval is faster. (yay)
Diffstat (limited to 'util/epist/config.hh')
-rw-r--r--util/epist/config.hh65
1 files changed, 39 insertions, 26 deletions
diff --git a/util/epist/config.hh b/util/epist/config.hh
index 443834ed..0cb2a1c0 100644
--- a/util/epist/config.hh
+++ b/util/epist/config.hh
@@ -26,50 +26,63 @@
#include <string>
#include <list>
-class ConfigItem;
+// forward declarations
+struct BoolItem;
+struct StringItem;
+struct NumberItem;
class Config {
public:
- enum ItemType {
- noType,
+ enum BoolType {
+ NO_BOOL_TYPE,
+ stackedCycling,
+ NUM_BOOL_TYPES
+ };
+
+ enum StringType {
+ NO_STRING_TYPE,
+ NUM_STRING_TYPES
+ };
+
+ enum NumberType {
+ NO_NUMBER_TYPE,
chainTimeout,
workspaceColumns,
- numTypes
+ NUM_NUMBER_TYPES
};
private:
- typedef std::list<ConfigItem *> ItemList;
- ItemList items;
+ typedef std::list<BoolItem *> BoolItemList;
+ typedef std::list<StringItem *> StringItemList;
+ typedef std::list<NumberItem *> NumberItemList;
+ BoolItemList bool_items;
+ StringItemList string_items;
+ NumberItemList number_items;
public:
Config();
~Config();
- bool getStringValue(Config::ItemType, std::string &) const;
- int getNumberValue(Config::ItemType) const;
- void addOption(ConfigItem *);
+ bool getBoolValue(BoolType, bool &) const;
+ bool getStringValue(StringType, std::string &) const;
+ bool getNumberValue(NumberType, int &) const;
+
void addOption(const std::string &, const std::string &);
};
+struct BoolItem {
+ Config::BoolType type;
+ bool value;
+};
-class ConfigItem {
-private:
- Config::ItemType _type;
- std::string _value;
-
-public:
- ConfigItem(Config::ItemType type, std::string value)
- : _type(type), _value(value) {}
- ~ConfigItem() {}
-
- inline const std::string &getStringValue() const
- { return _value; }
-
- inline int getNumberValue() const
- { return atoi(_value.c_str()); }
+struct StringItem {
+ Config::StringType type;
+ std::string value;
+};
- inline Config::ItemType getType() const
- { return _type; }
+struct NumberItem {
+ Config::NumberType type;
+ int value;
};
#endif // __config_hh