70 if (m_modified && !m_file.empty())
98 if (0 > static_cast<MRPT_CSimpleIni*>(m_ini.get())
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)
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
void discardSavingChanges()
Discard saving (current) changes to physical file upon destruction.
#define THROW_EXCEPTION(msg)
virtual ~CConfigFile()
Destructor.
std::vector< std::string > vector_string
A type for passing a vector of strings.
CSimpleIniTempl< char, SI_GenericNoCase< char >, MRPT_IniFileParser > MRPT_CSimpleIni
CConfigFile()
Constructor, does not open any file.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
GLsizei const GLchar ** string
void writeString(const std::string §ion, const std::string &name, const std::string &str) override
A virtual method to write a generic string.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
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...
std::list< Entry > TNamesDepend
set of dependent string pointers.
GLuint const GLchar * name
void writeNow()
Dumps the changes to the physical configuration file now, not waiting until destruction.
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.
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.