Main MRPT website > C++ reference for MRPT 1.5.7
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 string list.
22  *
23  * Use base class `CConfigFileBase`'s methods `read_{int,float,double,string,...}()` and `write()` to actually read and write values.
24  *
25  * See: \ref config_file_format
26  * \ingroup mrpt_base_grp
27  */
29  {
30  public:
31  CConfigFileMemory(); //!< Empty constructor. Upon construction, call any of the "setContent" method
32  CConfigFileMemory( const utils::CStringList &stringList ); //!< Constructor and initialize from a list of strings
33  CConfigFileMemory( const std::string &str ); //!< Constructor and initialize from string with the whole "config file"
34  virtual ~CConfigFileMemory(); //!< dtor
35 
36  CConfigFileMemory(const CConfigFileMemory& o); //!< Copy constructor
37  CConfigFileMemory& operator = (const CConfigFileMemory& o); //!< Copy operator
38 
39  void setContent( const utils::CStringList &stringList ); //!< Changes the contents of the virtual "config file"
40  void setContent( const std::string &str ); //!< Changes the contents of the virtual "config file"
41  void getContent(std::string &str) const; //!< Return the current contents of the virtual "config file"
42  /** \overload */
43  inline std::string getContent() const { std::string s; getContent(s); return s; }
44 
45  void getAllSections( vector_string &sections ) const MRPT_OVERRIDE; //!< Returns a list with all the section names
46  void getAllKeys( const std::string &section, vector_string &keys ) const MRPT_OVERRIDE; //!< Returs a list with all the keys into a section
47 
48  private:
49  void_ptr_noncopy m_ini; //!< The IniFile object
50  protected:
51  void writeString(const std::string &section, const std::string &name, const std::string &str) MRPT_OVERRIDE; //!< A virtual method to write a generic string
52  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
53 
54  }; // End of class def.
55 
56  } // End of namespace
57 } // end of namespace
58 #endif
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
GLdouble s
Definition: glext.h:3602
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::vector< std::string > vector_string
A type for passing a vector of strings.
Definition: types_simple.h:30
A class for storing a list of text lines.
Definition: CStringList.h:32
GLsizei const GLchar ** string
Definition: glext.h:3919
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLuint const GLchar * name
Definition: glext.h:3891
void_ptr_noncopy m_ini
The IniFile object.



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019