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