00001 #ifndef CONFIGURATOR_IMPLEMENTATION_FILE
00002 #define CONFIGURATOR_IMPLEMENTATION_FILE
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "configurator.h"
00019 #include "string_table.h"
00020
00021 #include <basis/istring.h>
00022 #include <basis/string_array.h>
00023 #include <basis/set.cpp>
00024
00025 configurator::~configurator() {}
00026
00027 istring configurator::load(const istring §ion, const istring &entry,
00028 const istring &default_string)
00029 {
00030 istring to_return;
00031 if (!get(section, entry, to_return)) {
00032 to_return = default_string;
00033 if (_behavior == AUTO_STORE) put(section, entry, to_return);
00034
00035 }
00036 return to_return;
00037 }
00038
00039 bool configurator::store(const istring §ion, const istring &entry,
00040 const istring &to_store)
00041 { return put(section, entry, to_store); }
00042
00043 bool configurator::store(const istring §ion, const istring &entry,
00044 int value)
00045 {
00046 return store(section, entry, istring(istring::SPRINTF, "%d", value));
00047 }
00048
00049 void configurator::sections(string_array &list)
00050 {
00051
00052 list = string_array();
00053 }
00054
00055 void configurator::section_set(string_set &list)
00056 {
00057 string_array temp;
00058 sections(temp);
00059 list = temp;
00060 }
00061
00062 int configurator::load(const istring §ion, const istring &entry,
00063 int def_value)
00064 {
00065 istring value_string;
00066 if (!get(section, entry, value_string)) {
00067 if (_behavior == AUTO_STORE) store(section, entry, def_value);
00068 return def_value;
00069 }
00070 return value_string.convert(def_value);
00071 }
00072
00073 bool configurator::section_exists(const istring §ion)
00074 {
00075 string_table infos;
00076
00077 return get_section(section, infos);
00078 }
00079
00080
00081 #endif //CONFIGURATOR_IMPLEMENTATION_FILE
00082