SAGA Adaptor CPI v.1.0
ini.hpp
Go to the documentation of this file.
00001 //  Copyright (c) 2005-2007 Andre Merzky (andre@merzky.net)
00002 //  Copyright (c) 2009 João Abecasis
00003 // 
00004 //  Use, modification and distribution is subject to the Boost Software
00005 //  License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
00006 //  http://www.boost.org/LICENSE_1_0.txt)
00007 
00008 #ifndef _SAGA_INI_H_
00009 #define _SAGA_INI_H_ 1
00010 
00011 #include <map>
00012 #include <list>
00013 #include <vector>
00014 #include <iostream>
00015 
00016 // other includes from SAGA
00017 #include <saga/saga/util.hpp>
00018 #include <saga/saga/types.hpp>
00019 
00020 // suppress warnings about dependent classes not being exported from the dll
00021 #if defined(BOOST_MSVC)
00022 #pragma warning(push)
00023 #pragma warning(disable: 4251 4231 4275 4660)
00024 #endif
00025 
00027 //
00028 // C++ interface
00029 //
00030 namespace saga
00031 {
00032   // forward declaration
00033   namespace impl 
00034   {
00035     namespace ini
00036     {
00037       class section;
00038     }
00039   }
00040 
00041   namespace ini
00042   {
00043     class   section;
00044 
00045     typedef section ini;
00046 
00047     typedef std::map <std::string, std::string> entry_map;
00048     typedef std::map <std::string, section>     section_map;
00049 
00050 #define SAGA_INI_EXPORT 
00051 
00052     class SAGA_EXPORT/*SAGA_INI_EXPORT*/ section
00053     {
00054       private:
00055         typedef saga::impl::ini::section impl_sec;
00056         typedef TR1::shared_ptr       <impl_sec> shared_sec;
00057 
00058         shared_sec impl_;
00059 
00060         shared_sec get_impl (void) const { return (impl_); }
00061 
00062         explicit section (shared_sec impl);
00063         explicit section (impl_sec * sec);
00064 
00065         void debug (std::string = "") const;
00066 
00067 
00068       public:
00069         section (std::string filename = "");
00070         section (const       section  & in);
00071        ~section (void);
00072 
00073 
00074         void           read              (std::string     filename);
00075         void           parse             (std::string     sourcename, 
00076                                           std::vector <std::string> lines);
00077         void           merge             (std::string     second);           
00078         void           merge             (
00079                                     const section       & second);           
00080         void           dump              (int             ind = 0, 
00081                                           std::ostream&   strm = std::cout)  const;
00082 
00083         void           add_section       (std::string     sec_name, 
00084                                     const section       & sec);
00085         bool           has_section       (std::string     sec_name) const;
00086         bool           has_section_full  (std::string     sec_name) const;
00087         section        get_section       (std::string     sec_name) const; 
00088         section_map    get_sections      (void)                     const;
00089 
00090         void           add_entry         (std::string     key,                 
00091                                           std::string     val);                      
00092         bool           has_entry         (std::string     key)      const;
00093         std::string    get_entry         (std::string     key)      const;
00094         std::string    get_entry         (std::string     key,
00095                                           std::string     dflt_val) const;
00096         entry_map      get_entries       (void)                     const;
00097 
00098         section        get_root          (void)                     const;
00099         std::string    get_name          (void)                     const;
00100     };
00101 
00102   } // namespace ini
00103 
00104 } // namespace saga
00105 
00106 #endif // _SAGA_INI_H_
00107 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines