Main MRPT website > C++ reference for MRPT 1.4.0
CConfigFileMemory.h
Go to the documentation of this file.
1/* +---------------------------------------------------------------------------+
2 | Mobile Robot Programming Toolkit (MRPT) |
3 | http://www.mrpt.org/ |
4 | |
5 | Copyright (c) 2005-2016, Individual contributors, see AUTHORS file |
6 | See: http://www.mrpt.org/Authors - All rights reserved. |
7 | Released under BSD License. See details in http://www.mrpt.org/License |
8 +---------------------------------------------------------------------------+ */
9#ifndef CConfigFileMemory_H
10#define CConfigFileMemory_H
11
16
17/*---------------------------------------------------------------
18 Class
19 ---------------------------------------------------------------*/
20namespace mrpt
21{
22namespace utils
23{
24 /** This class implements a config file-like interface over a memory-stored string list.
25 * \ingroup mrpt_base_grp
26 */
28 {
29 private:
30 void_ptr_noncopy m_ini; //!< The IniFile object
31
32 protected:
33 /** A virtual method to write a generic string. */
34 void writeString(const std::string &section,const std::string &name, const std::string &str) MRPT_OVERRIDE;
35
36 /** A virtual method to read a generic string.
37 */
38 std::string readString(
39 const std::string &section,
40 const std::string &name,
41 const std::string &defaultStr,
42 bool failIfNotFound = false) const MRPT_OVERRIDE;
43
44 public:
45 /** Constructor and initialize from a list of strings */
46 CConfigFileMemory( const utils::CStringList &stringList );
47
48 /** Constructor and initialize from string with the whole "config file" */
49 CConfigFileMemory( const std::string &str );
50
51 /** Empty constructor. Upon construction, call any of the "setContent" method. */
53
54 /** Copy constructor */
56
57 /** Copy operator */
58 CConfigFileMemory& operator = (const CConfigFileMemory& o);
59
60 /** Changes the contents of the virtual "config file" */
61 void setContent( const utils::CStringList &stringList );
62
63 /** Changes the contents of the virtual "config file" */
64 void setContent( const std::string &str );
65
66 /** Return the currnet contents of the virtual "config file" */
67 void getContent( std::string &str ) const;
68
69 /** Return the currnet contents of the virtual "config file" */
70 inline std::string getContent() const { std::string s; getContent(s); return s; }
71
72 /** Destructor
73 */
75
76 /** Returns a list with all the section names */
78
79 /** Returs a list with all the keys into a section */
80 void getAllKeys( const std::string &section, vector_string &keys ) const MRPT_OVERRIDE;
81
82 }; // End of class def.
83
84 } // End of namespace
85} // end of namespace
86#endif
This class allows loading and storing values and vectors of different types from a configuration text...
This class implements a config file-like interface over a memory-stored string list.
std::string readString(const std::string &section, const std::string &name, const std::string &defaultStr, bool failIfNotFound=false) const MRPT_OVERRIDE
A virtual method to read a generic string.
void_ptr_noncopy m_ini
The IniFile object.
void getAllKeys(const std::string &section, vector_string &keys) const MRPT_OVERRIDE
Returs a list with all the keys into a section.
void writeString(const std::string &section, const std::string &name, const std::string &str) MRPT_OVERRIDE
A virtual method to write a generic string.
virtual ~CConfigFileMemory()
Destructor.
std::string getContent() const
Return the currnet contents of the virtual "config file".
void getAllSections(vector_string &sections) const MRPT_OVERRIDE
Returns a list with all the section names.
A class for storing a list of text lines.
Definition: CStringList.h:33
std::vector< std::string > vector_string
A type for passing a vector of strings.
Definition: types_simple.h:30
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
Definition: mrpt_macros.h:28
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
STL namespace.



Page generated by Doxygen 1.9.6 for MRPT 1.4.0 SVN: at Fri Jan 20 02:28:26 UTC 2023