70 if (m_modified && !m_file.empty())
99 ->
SetValue(section.c_str(),
name.c_str(), str.c_str(), NULL))
110 const std::string& defaultStr,
bool failIfNotFound)
const
113 const char* defVal = failIfNotFound ? NULL : defaultStr.c_str();
118 section.c_str(),
name.c_str(), defVal,
121 if (failIfNotFound && !aux)
125 "Value '%s' not found in section '%s' of file '%s' and "
126 "failIfNotFound=true.",
127 name.c_str(), section.c_str(), m_file.c_str()));
134 if ((pos = ret.find(
"//")) != string::npos && pos > 0 &&
135 isspace(ret[pos - 1]))
136 ret = ret.substr(0, pos);
148 static_cast<const MRPT_CSimpleIni*
>(m_ini.get())->GetAllSections(names);
152 sections.resize(names.size());
153 for (
n = names.begin(),
s = sections.begin();
n != names.end(); ++
n, ++
s)
164 ->GetAllKeys(section.c_str(), names);
168 keys.resize(names.size());
169 for (
n = names.begin(),
s = keys.begin();
n != names.end(); ++
n, ++
s)
virtual void getAllKeys(const std::string §ion, vector_string &keys) const override
Returs a list with all the keys into a section.
virtual void getAllSections(vector_string §ions) const override
Returns a list with all the section names.
virtual ~CConfigFile()
Destructor.
void writeString(const std::string §ion, const std::string &name, const std::string &str) override
A virtual method to write a generic string
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.
void discardSavingChanges()
Discard saving (current) changes to physical file upon destruction.
void writeNow()
Dumps the changes to the physical configuration file now, not waiting until destruction.
CConfigFile()
Constructor, does not open any file.
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...
SI_Error SetValue(const SI_CHAR *a_pSection, const SI_CHAR *a_pKey, const SI_CHAR *a_pValue, const SI_CHAR *a_pComment=nullptr)
Add or update a section or value.
std::list< Entry > TNamesDepend
set of dependent string pointers.
GLuint const GLchar * name
GLsizei const GLchar ** string
std::vector< std::string > vector_string
A type for passing a vector of strings.
#define THROW_EXCEPTION(msg)
CSimpleIniTempl< char, SI_GenericNoCase< char >, MRPT_IniFileParser > MRPT_CSimpleIni
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values,...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.