71 if (m_modified && !m_file.empty())
117 bool failIfNotFound )
const
120 const char *defVal = failIfNotFound ? NULL :defaultStr.c_str();
122 const char *aux =
static_cast<const MRPT_CSimpleIni*
>(m_ini.get())->GetValue(
128 if (failIfNotFound && !aux )
130 string tmpStr(
format(
"Value '%s' not found in section '%s' of file '%s' and failIfNotFound=true.",
140 if ((pos=ret.find(
"//"))!=string::npos && pos>0 && isspace(ret[pos-1]))
141 ret = ret.substr(0,pos);
153 static_cast<const MRPT_CSimpleIni*
>(m_ini.get())->GetAllSections(names);
157 sections.resize(names.size());
158 for (
n=names.begin(),
s=sections.begin();
n!=names.end();++
n,++
s)
169 static_cast<const MRPT_CSimpleIni*
>(m_ini.get())->GetAllKeys(section.c_str(), names);
173 keys.resize(names.size());
174 for (
n = names.begin(),
s = keys.begin();
n!=names.end();++
n,++
s)
virtual ~CConfigFile()
Destructor.
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.
std::string readString(const std::string §ion, const std::string &name, const std::string &defaultStr, bool failIfNotFound=false) const MRPT_OVERRIDE
A virtual method to read a generic string.
void writeString(const std::string §ion, const std::string &name, const std::string &str) MRPT_OVERRIDE
A virtual method to write a generic string
virtual void getAllSections(vector_string §ions) const MRPT_OVERRIDE
Returns a list with all the section names.
virtual void getAllKeys(const std::string §ion, vector_string &keys) const MRPT_OVERRIDE
Returs a list with all the keys into a section.
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=NULL)
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 BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.