Main MRPT website > C++ reference for MRPT 1.3.2
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-2015, 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  /** The IniFile object
31  */
33 
34  protected:
35  /** A virtual method to write a generic string.
36  */
37  void writeString(const std::string &section,const std::string &name, const std::string &str);
38 
39  /** A virtual method to read a generic string.
40  */
41  std::string readString(
42  const std::string &section,
43  const std::string &name,
44  const std::string &defaultStr,
45  bool failIfNotFound = false) const;
46 
47  public:
48  /** Constructor and initialize from a list of strings */
49  CConfigFileMemory( const utils::CStringList &stringList );
50 
51  /** Constructor and initialize from string with the whole "config file" */
52  CConfigFileMemory( const std::string &str );
53 
54  /** Empty constructor. Upon construction, call any of the "setContent" method. */
56 
57  /** Copy constructor */
59 
60  /** Copy operator */
61  CConfigFileMemory& operator = (const CConfigFileMemory& o);
62 
63  /** Changes the contents of the virtual "config file" */
64  void setContent( const utils::CStringList &stringList );
65 
66  /** Changes the contents of the virtual "config file" */
67  void setContent( const std::string &str );
68 
69  /** Return the currnet contents of the virtual "config file" */
70  void getContent( std::string &str ) const;
71 
72  /** Return the currnet contents of the virtual "config file" */
73  inline std::string getContent() const { std::string s; getContent(s); return s; }
74 
75  /** Destructor
76  */
77  virtual ~CConfigFileMemory( );
78 
79  /** Returns a list with all the section names.
80  */
81  virtual void getAllSections( vector_string &sections ) const;
82 
83  /** Returs a list with all the keys into a section.
84  */
85  virtual void getAllKeys( const std::string &section, vector_string &keys ) const;
86 
87  }; // End of class def.
88 
89  } // End of namespace
90 } // end of namespace
91 #endif
This class allows loading and storing values and vectors of different types from a configuration text...
std::string getContent() const
Return the currnet contents of the virtual "config file".
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
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.12 for MRPT 1.3.2 SVN: at Mon Oct 3 19:22:36 UTC 2016