Main MRPT website > C++ reference for MRPT 1.9.9
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-2017, 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 
12 #include <mrpt/utils/utils_defs.h>
14 #include <mrpt/utils/CStringList.h>
16 
17 namespace mrpt
18 {
19 namespace utils
20 {
21 /** This class implements a config file-like interface over a memory-stored
22  * string list.
23 *
24  * Use base class `CConfigFileBase`'s methods
25  * `read_{int,float,double,string,...}()` and `write()` to actually read and
26  * write values.
27  *
28  * See: \ref config_file_format
29  * \ingroup mrpt_base_grp
30  */
32 {
33  public:
34  /** Empty constructor. Upon construction, call any of the "setContent"
35  * method */
37  /** Constructor and initialize from a list of strings */
38  CConfigFileMemory(const utils::CStringList& stringList);
39  /** Constructor and initialize from string with the whole "config file" */
40  CConfigFileMemory(const std::string& str);
41  /** dtor */
42  virtual ~CConfigFileMemory();
43 
44  /** Copy constructor */
46  /** Copy operator */
48 
49  /** Changes the contents of the virtual "config file" */
50  void setContent(const utils::CStringList& stringList);
51  /** Changes the contents of the virtual "config file" */
52  void setContent(const std::string& str);
53  /** Return the current contents of the virtual "config file" */
54  void getContent(std::string& str) const;
55  /** \overload */
56  inline std::string getContent() const
57  {
58  std::string s;
59  getContent(s);
60  return s;
61  }
62 
63  /** Returns a list with all the section names */
64  void getAllSections(vector_string& sections) const override;
65  /** Returs a list with all the keys into a section */
66  void getAllKeys(
67  const std::string& section, vector_string& keys) const override;
68 
69  private:
70  /** The IniFile object */
72 
73  protected:
74  /** A virtual method to write a generic string */
75  void writeString(
76  const std::string& section, const std::string& name,
77  const std::string& str) override;
78  /** A virtual method to read a generic string */
80  const std::string& section, const std::string& name,
81  const std::string& defaultStr,
82  bool failIfNotFound = false) const override;
83 
84 }; // End of class def.
85 
86 } // End of namespace
87 } // end of namespace
88 #endif
void getAllSections(vector_string &sections) const override
Returns a list with all the section names.
GLdouble s
Definition: glext.h:3676
This class allows loading and storing values and vectors of different types from a configuration text...
std::string readString(const std::string &section, const std::string &name, const std::string &defaultStr, bool failIfNotFound=false) const override
A virtual method to read a generic string.
This class implements a config file-like interface over a memory-stored string list.
std::vector< std::string > vector_string
A type for passing a vector of strings.
Definition: types_simple.h:33
A class for storing a list of text lines.
Definition: CStringList.h:32
GLsizei const GLchar ** string
Definition: glext.h:4101
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
CConfigFileMemory & operator=(const CConfigFileMemory &o)
Copy operator.
GLuint const GLchar * name
Definition: glext.h:4054
void_ptr_noncopy m_ini
The IniFile object.
void writeString(const std::string &section, const std::string &name, const std::string &str) override
A virtual method to write a generic string.
void getAllKeys(const std::string &section, vector_string &keys) const override
Returs a list with all the keys into a section.
CConfigFileMemory()
Empty constructor.
void setContent(const utils::CStringList &stringList)
Changes the contents of the virtual "config file".



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019