32 # define getcwd _getcwd
44 appname(application_name),
49 filename = application_name.
CStr();
60 std::vector<Path> dirs, files;
67 dirs.push_back(CRN_CONFIG_PATH);
73 dirs.push_back(CRN_CONFIG_PATH);
75 files.push_back(filename +
".xml");
76 files.push_back(
"_" + filename +
".xml");
77 files.push_back(
"." + filename +
".xml");
80 for (
auto idir = dirs.begin(); (idir != dirs.end()); ++idir)
82 for (
auto ifn = files.begin(); (ifn != files.end()); ++ifn)
91 CRNdout <<
"Configuration loaded from: " << confname.
CStr() << std::endl;
106 #ifdef CRN_PF_ANDROID
107 const auto fname = filename +
".xml";
116 catch (std::exception &ex)
138 auto it(data.
Find(key));
139 if (it != data.
end())
152 if (it != data.
end())
165 auto str = std::dynamic_pointer_cast<
const Path>(
GetData(key));
168 if (str->IsRelative())
187 SCString str(std::dynamic_pointer_cast<const String>(
GetData(key)));
200 SCStringUTF8 str(std::dynamic_pointer_cast<const StringUTF8>(
GetData(key)));
213 SCProp3 val(std::dynamic_pointer_cast<const Prop3>(
GetData(key)));
226 auto val = std::dynamic_pointer_cast<
const Int>(
GetData(key));
239 auto val = std::dynamic_pointer_cast<
const Real>(
GetData(key));
Path GetUserDirectory() const
Returns the path to the user configuration directory.
void Clear() noexcept
Empties the map.
iterator Find(const String &key)
Returns an iterator to a specific key.
SObject & operator[](const String &key)
Gets a value.
Path Load()
Loads the file.
const char * CStr() const
Conversion to UTF8 cstring.
double GetDouble(const String &key) const
Gets a double.
SObject GetData(const String &key)
Gets a value.
static void Mkdir(const Path &name)
Creates a directory.
static char Separator() noexcept
Local directory separator.
void Load(const Path &fname)
#define CRN_END_CLASS_CONSTRUCTOR(classname)
Defines a class constructor.
A UTF32 character string class.
void Save(const Path &fname) const
Interface class for the metric real number class.
const char * CStr() const noexcept
Conversion to UTF8 cstring.
bool IsEmpty() const noexcept
Checks if the string is empty.
A convenience class for file paths.
Path Save()
Saves the file to the user's personal space.
String GetString(const String &key) const
Gets a string.
std::map< String, SObject >::const_iterator const_iterator
const_iterator on the contents of the container
ConfigurationFile(const String &application_name, const StringUTF8 &file_name="", ConfigurationType ctype=ConfigurationType::APP)
Constructor.
Prop3 GetProp3(const String &key) const
Gets a Prop3.
StringUTF8 GetStringUTF8(const String &key) const
Gets a UTF8 string.
int GetInt(const String &key) const
Gets an int.
Interface class for the metric real number class.
static bool Access(const Path &name, int mode)
Checks rights on a file.
A character string class.
iterator end()
Returns an iterator after the last element.
Configuration file management utility class.
Path GetPath(const String &key) const
Gets a path.
Invalid argument error (e.g.: nullptr pointer)
#define CRN_BEGIN_CLASS_CONSTRUCTOR(classname)
Defines a class constructor.