00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef IXE_conf_dictionary_H
00025 #define IXE_conf_dictionary_H
00026
00027
00028 #include <map>
00029
00030
00031 #include "conf/conf.h"
00032 #include "text/strings.h"
00033
00034 using namespace IXE::Text;
00035
00036 namespace IXE {
00037
00045 typedef std::map<char const*, char const*> Dictionary;
00046
00047 template <>
00048 class conf<Dictionary> : public Var<Dictionary>
00049 {
00050 public:
00051
00052 conf(char const* name) : Var<value_type>(name) { }
00053
00054 char const* operator [](value_type::key_type key) const {
00055 value_type::const_iterator const kit = value.find(key);
00056 return kit != value.end() ? kit->second : key;
00057 }
00058 protected:
00065 virtual void parseValue(char const*& line) {
00066 register char const *s;
00067 char const* key = next_token_line(line, " \r\t");
00068 key = strndup(key, line - key);
00069 while (s = next_token_line(line, " \r\t"))
00070 value[key] = strndup(s, line - s);
00071 }
00072 virtual void reset() { }
00073 };
00074
00075 }
00076
00077 #endif