Main MRPT website > C++ reference for MRPT 1.9.9
config/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-2018, 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 #pragma once
10 
12 #include <mrpt/core/pimpl.h>
13 #include <string>
14 #include <vector>
15 
16 namespace mrpt
17 {
18 namespace config
19 {
20 /** This class implements a config file-like interface over a memory-stored
21  * string list.
22 *
23  * Use base class `CConfigFileBase`'s methods
24  * `read_{int,float,double,string,...}()` and `write()` to actually read and
25  * write values.
26  *
27  * See: \ref config_file_format
28  * \ingroup mrpt_base_grp
29  */
31 {
32  public:
33  /** Empty constructor. Upon construction, call any of the "setContent"
34  * method */
36  /** Constructor and initialize from a list of strings */
37  CConfigFileMemory(const std::vector<std::string>& stringList);
38  /** Constructor and initialize from string with the whole "config file" */
39  CConfigFileMemory(const std::string& str);
40  /** dtor */
41  virtual ~CConfigFileMemory();
42 
43  /** Changes the contents of the virtual "config file" */
44  void setContent(const std::vector<std::string>& stringList);
45  /** Changes the contents of the virtual "config file" */
46  void setContent(const std::string& str);
47  /** Return the current contents of the virtual "config file" */
48  void getContent(std::string& str) const;
49  /** \overload */
50  inline std::string getContent() const
51  {
52  std::string s;
53  getContent(s);
54  return s;
55  }
56 
57  /** Returns a list with all the section names */
58  void getAllSections(std::vector<std::string>& sections) const override;
59  /** Returs a list with all the keys into a section */
60  void getAllKeys(const std::string& section, std::vector<std::string>& keys)
61  const override;
62 
63  private:
64  /** The IniFile object */
65  struct Impl;
67 
68  protected:
69  /** A virtual method to write a generic string */
70  void writeString(
71  const std::string& section, const std::string& name,
72  const std::string& str) override;
73  /** A virtual method to read a generic string */
75  const std::string& section, const std::string& name,
76  const std::string& defaultStr,
77  bool failIfNotFound = false) const override;
78 
79 }; // End of class def.
80 
81 } // End of namespace
82 } // end of namespace
This class implements a config file-like interface over a memory-stored string list.
CConfigFileMemory()
Empty constructor.
spimpl::impl_ptr< T > pimpl
Definition: pimpl.h:15
GLdouble s
Definition: glext.h:3676
void getAllKeys(const std::string &section, std::vector< std::string > &keys) const override
Returs a list with all the keys into a section.
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.
GLsizei const GLchar ** string
Definition: glext.h:4101
void getAllSections(std::vector< std::string > &sections) const override
Returns a list with all the section names.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void setContent(const std::vector< std::string > &stringList)
Changes the contents of the virtual "config file".
GLuint const GLchar * name
Definition: glext.h:4054
void writeString(const std::string &section, const std::string &name, const std::string &str) override
A virtual method to write a generic string.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019