Main MRPT website > C++ reference
MRPT logo
CConfigFileMemory.h
Go to the documentation of this file.
00001 /* +---------------------------------------------------------------------------+
00002    |          The Mobile Robot Programming Toolkit (MRPT) C++ library          |
00003    |                                                                           |
00004    |                       http://www.mrpt.org/                                |
00005    |                                                                           |
00006    |   Copyright (C) 2005-2011  University of Malaga                           |
00007    |                                                                           |
00008    |    This software was written by the Machine Perception and Intelligent    |
00009    |      Robotics Lab, University of Malaga (Spain).                          |
00010    |    Contact: Jose-Luis Blanco  <jlblanco@ctima.uma.es>                     |
00011    |                                                                           |
00012    |  This file is part of the MRPT project.                                   |
00013    |                                                                           |
00014    |     MRPT is free software: you can redistribute it and/or modify          |
00015    |     it under the terms of the GNU General Public License as published by  |
00016    |     the Free Software Foundation, either version 3 of the License, or     |
00017    |     (at your option) any later version.                                   |
00018    |                                                                           |
00019    |   MRPT is distributed in the hope that it will be useful,                 |
00020    |     but WITHOUT ANY WARRANTY; without even the implied warranty of        |
00021    |     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         |
00022    |     GNU General Public License for more details.                          |
00023    |                                                                           |
00024    |     You should have received a copy of the GNU General Public License     |
00025    |     along with MRPT.  If not, see <http://www.gnu.org/licenses/>.         |
00026    |                                                                           |
00027    +---------------------------------------------------------------------------+ */
00028 #ifndef  CConfigFileMemory_H
00029 #define  CConfigFileMemory_H
00030 
00031 #include <mrpt/utils/utils_defs.h>
00032 #include <mrpt/utils/CConfigFileBase.h>
00033 #include <mrpt/utils/CStringList.h>
00034 #include <mrpt/utils/safe_pointers.h>
00035 
00036 /*---------------------------------------------------------------
00037         Class
00038   ---------------------------------------------------------------*/
00039 namespace mrpt
00040 {
00041 namespace utils
00042 {
00043         /** This class implements a config file-like interface over a memory-stored string list.
00044          * \ingroup mrpt_base_grp
00045           */
00046         class BASE_IMPEXP CConfigFileMemory : public CConfigFileBase
00047         {
00048         private:
00049                 /** The IniFile object
00050                   */
00051                 void_ptr_noncopy                m_ini;
00052 
00053         protected:
00054                 /** A virtual method to write a generic string.
00055                   */
00056                 void  writeString(const std::string &section,const std::string &name, const std::string &str);
00057 
00058                 /** A virtual method to read a generic string.
00059                   */
00060                 std::string  readString(
00061             const std::string &section,
00062             const std::string &name,
00063             const std::string &defaultStr,
00064             bool failIfNotFound = false) const;
00065 
00066         public:
00067                 /** Constructor and initialize from a list of strings */
00068                 CConfigFileMemory( const utils::CStringList &stringList );
00069 
00070                 /** Constructor and initialize from string with the whole "config file"  */
00071                 CConfigFileMemory( const std::string &str );
00072 
00073                 /** Empty constructor. Upon construction, call any of the "setContent" method. */
00074                 CConfigFileMemory();
00075 
00076                 /** Copy constructor */
00077                 CConfigFileMemory(const CConfigFileMemory& o);
00078 
00079                 /** Copy operator */
00080                 CConfigFileMemory& operator = (const CConfigFileMemory& o);
00081 
00082                 /** Changes the contents of the virtual "config file" */
00083                 void setContent(  const utils::CStringList &stringList  );
00084 
00085                 /** Changes the contents of the virtual "config file" */
00086                 void setContent(  const std::string &str );
00087 
00088                 /** Return the currnet contents of the virtual "config file" */
00089                 void getContent(  std::string &str ) const;
00090 
00091                 /** Return the currnet contents of the virtual "config file" */
00092                 inline std::string getContent() const {  std::string s; getContent(s); return s; }
00093 
00094                 /** Destructor
00095                  */
00096                 virtual ~CConfigFileMemory( );
00097 
00098                 /** Returns a list with all the section names.
00099                   */
00100                 virtual void getAllSections( vector_string      &sections ) const;
00101 
00102                 /** Returs a list with all the keys into a section.
00103                   */
00104                 virtual void getAllKeys( const std::string section, vector_string       &keys ) const;
00105 
00106         }; // End of class def.
00107 
00108         } // End of namespace
00109 } // end of namespace
00110 #endif



Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011