00001 #ifndef INI_CONFIGURATOR_CLASS
00002 #define INI_CONFIGURATOR_CLASS
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00019
00020 #include "opsysdll.h"
00021
00022 #include <basis/object_base.h>
00023 #ifdef __WIN32__
00024 #include <data_struct/configurator.h>
00025 #else
00026 #include "ini_parser.h"
00027 #endif
00028
00029
00030 class byte_filer;
00031 class filename;
00032
00033 class OPSYSTEM_CLASS_STYLE ini_configurator : public configurator
00034 {
00035 public:
00037
00044 enum file_location_default {
00045 APPLICATION_DIRECTORY,
00046 OS_DIRECTORY,
00047 ALL_USERS_DIRECTORY
00048 };
00049
00050 ini_configurator(const istring &ini_filename,
00051 treatment_of_defaults behavior = RETURN_ONLY,
00052 file_location_default where = ALL_USERS_DIRECTORY);
00054
00058 virtual ~ini_configurator();
00059
00060 IMPLEMENT_CLASS_NAME("ini_configurator");
00061
00062 istring name() const;
00064 void name(const istring &name);
00066
00067 virtual bool get(const istring §ion, const istring &entry,
00068 istring &found);
00070
00073 virtual void sections(string_array &list);
00075
00076 virtual bool section_exists(const istring §ion);
00078
00080 virtual bool put(const istring §ion, const istring &entry,
00081 const istring &to_store);
00083
00084 virtual bool delete_section(const istring §ion);
00086
00087 virtual bool delete_entry(const istring §ion, const istring &entry);
00089
00090 virtual bool get_section(const istring §ion, string_table &info);
00092
00094 virtual bool put_section(const istring §ion, const string_table &info);
00096
00099
00100
00101 bool add_spaces() const { return _add_spaces; }
00102 void add_spaces(bool add_them) { _add_spaces = add_them; }
00103
00104 private:
00105 filename *_ini_name;
00106 #ifdef __UNIX__
00107 ini_parser *_parser;
00108 #endif
00109 file_location_default _where;
00110 bool _add_spaces;
00111
00112 #ifdef __WIN32__
00113 bool put_profile_string(const istring §ion, const istring &entry,
00114 const istring &to_store);
00116 void get_profile_string(const istring §ion, const istring &entry,
00117 const istring &default_value, flexichar *return_buffer,
00118 int buffer_size);
00120 #endif
00121 #ifdef __UNIX__
00122 void read_ini_file();
00124 void write_ini_file();
00126 #endif
00127
00128
00129 ini_configurator(const ini_configurator &);
00130 ini_configurator &operator =(const ini_configurator &);
00131
00132 static const istring_object &ini_str_fake_default();
00133 };
00134
00135 #endif
00136