36 m_impl->m_ini.LoadFile(fileName.c_str());
64 m_impl->m_ini.LoadFile(fil_path.c_str());
97 if (0 >
m_impl->m_ini.SetValue(
98 section.c_str(),
name.c_str(), str.c_str(),
nullptr))
109 const std::string& defaultStr,
bool failIfNotFound)
const 112 const char* defVal = failIfNotFound ? nullptr : defaultStr.c_str();
114 const char* aux =
m_impl->m_ini.GetValue(
115 section.c_str(),
name.c_str(), defVal,
118 if (failIfNotFound && !aux)
121 "Value '%s' not found in section '%s' of file '%s' and " 122 "failIfNotFound=true.",
123 name.c_str(), section.c_str(),
m_file.c_str()));
130 if ((pos = ret.find(
"//")) != string::npos && pos > 0 &&
131 isspace(ret[pos - 1]))
132 ret = ret.substr(0, pos);
146 MRPT_CSimpleIni::TNamesDepend::iterator
n;
147 std::vector<std::string>::iterator
s;
148 sections.resize(
names.size());
149 for (
n =
names.begin(),
s = sections.begin();
n !=
names.end(); ++
n, ++
s)
157 const string& section, std::vector<std::string>& keys)
const 162 MRPT_CSimpleIni::TNamesDepend::iterator
n;
163 std::vector<std::string>::iterator
s;
164 keys.resize(
names.size());
mrpt::pimpl< Impl > m_impl
#define THROW_EXCEPTION(msg)
~CConfigFile() override
Destructor.
void writeString(const std::string §ion, const std::string &name, const std::string &str) override
A virtual method to write a generic string.
void getAllSections(std::vector< std::string > §ions) const override
Returns a list with all the section names.
bool m_modified
If modified since load.
This class allows loading and storing values and vectors of different types from ".ini" files easily.
CConfigFile()
Constructor, does not open any file.
std::string readString(const std::string §ion, const std::string &name, const std::string &defaultStr, bool failIfNotFound=false) const override
A virtual method to read a generic string.
GLsizei const GLchar ** string
std::vector< string > names
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void writeNow()
Dumps the changes to the physical configuration file now, not waiting until destruction.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
GLuint const GLchar * name
std::string m_file
The name of the file.
pimpl< T > make_impl(Args &&... args)
void setFileName(const std::string &fil_path)
Associate this object with the given file, so future read/write operations will be applied to that fi...
void discardSavingChanges()
Discard saving (current) changes to physical file upon destruction.
void getAllKeys(const std::string §ion, std::vector< std::string > &keys) const override
Returs a list with all the keys into a section.
std::list< Entry > TNamesDepend
set of dependent string pointers.
void clear() override
Empties the "config file".