00001 #ifndef MANAGED_INI_CONFIG_CLASS
00002 #define MANAGED_INI_CONFIG_CLASS
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00019
00020 #include "string_conversions.h"
00021
00022 #include <opsystem/ini_config.h>
00023
00024 namespace hoople_api {
00025
00027
00030 public enum class treatment_of_defaults { AUTO_STORE, RETURN_ONLY };
00031
00033
00040 public enum class file_location_default {
00041 APPLICATION_DIRECTORY,
00042 OS_DIRECTORY,
00043 ALL_USERS_DIRECTORY
00044 };
00045
00046 public ref class managed_ini_config
00047 {
00048 public:
00049 managed_ini_config(System::String ^ini_filename,
00050 treatment_of_defaults behavior, file_location_default where_to_store)
00051 {
00052 ini_configurator::file_location_default fld;
00053 ini_configurator::treatment_of_defaults tod;
00054
00055 if (behavior == treatment_of_defaults::AUTO_STORE)
00056 tod = ini_configurator::AUTO_STORE;
00057 else tod = ini_configurator::RETURN_ONLY;
00058
00059 if (where_to_store == file_location_default::ALL_USERS_DIRECTORY)
00060 fld = ini_configurator::ALL_USERS_DIRECTORY;
00061 else if (where_to_store == file_location_default::APPLICATION_DIRECTORY)
00062 fld = ini_configurator::APPLICATION_DIRECTORY;
00063 else fld = ini_configurator::OS_DIRECTORY;
00064
00065 _config = new ini_configurator(string_conversions::to_istring(ini_filename),
00066 tod, fld);
00067
00068 }
00070
00074 virtual ~managed_ini_config() {delete _config;}
00075
00076 System::String ^name() { return string_conversions::to_mstring(_config->name()); }
00078 void name(const System::String ^name) {
00080 _config->name(string_conversions::to_istring(name));
00081 }
00082
00083 virtual bool get(System::String ^section,System::String ^entry,
00084 System::String ^ %found) {
00086
00088 istring new_found;
00089 bool to_return = _config->get(string_conversions::to_istring(section),
00090 string_conversions::to_istring(entry), new_found);
00091 found = string_conversions::to_mstring(new_found);
00092 return to_return;
00093 }
00094
00095 virtual bool section_exists(System::String ^section) {
00097
00098 return _config->section_exists(string_conversions::to_istring(section));
00099 }
00100
00101 virtual bool put(System::String ^section,System::String ^entry,
00102 const System::String ^to_store) {
00104 return _config->put(string_conversions::to_istring(section),
00105 string_conversions::to_istring(entry),
00106 string_conversions::to_istring(to_store));
00107 }
00108
00109 virtual bool delete_section(System::String ^section) {
00111 return _config->delete_section(string_conversions::to_istring(section));
00112 }
00113
00114 virtual bool delete_entry(System::String ^section,
00115 const System::String ^entry) {
00117 return _config->delete_entry(string_conversions::to_istring(section),
00118 string_conversions::to_istring(entry));
00119 }
00120
00121
00122
00123
00124 private:
00125 ini_configurator *_config;
00126 };
00127
00128 }
00129
00130 #endif
00131