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 
12 #include <mrpt/utils/utils_defs.h>
14 #include <mrpt/utils/CStringList.h>
16 
17 /*---------------------------------------------------------------
18  Class
19  ---------------------------------------------------------------*/
20 namespace mrpt
21 {
22 namespace 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  */
74  virtual ~CConfigFileMemory( );
75 
76  /** Returns a list with all the section names */
77  void getAllSections( vector_string &sections ) const MRPT_OVERRIDE;
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
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
STL namespace.
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
std::string getContent() const
Return the currnet contents of the virtual "config file".
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void_ptr_noncopy m_ini
The IniFile object.



Page generated by Doxygen 1.8.11 for MRPT 1.4.0 SVN: at Mon Aug 15 11:50:21 UTC 2016