// Copyright (c) 2005-2007 Andre Merzky (andre@merzky.net) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #ifndef _SAGA_IMPL_INI_H_ #define _SAGA_IMPL_INI_H_ 1 #include #include #include #include #define SAGA_INI_MAXLEN 256 #define SAGA_INI_ERRLEN SAGA_INI_MAXLEN // suppress warnings about dependent classes not being exported from the dll #if defined(BOOST_MSVC) #pragma warning(push) #pragma warning(disable: 4091 4251 4231 4275 4660) #endif ////////////////////////////////////////// // // C++ interface // namespace saga { namespace impl { namespace ini { class section; typedef section ini; typedef std::map entry_map; typedef std::map section_map; class section { section *this_() { return this; } protected: static TR1::regex const regex_comment; static TR1::regex const regex_section; static TR1::regex const regex_entry; entry_map entries; section_map sections; void indent (int ind = 0) const; public: std::string name; section * root; section (std::string filename = ""); section (const section & in); ~section (void) { }; void read (std::string filename); void merge (std::string second); void merge (section & second); void dump (int ind = 0, std::ostream& strm = std::cout) const; void add_section (std::string sec_name, section & sec, section * root); bool has_section (std::string sec_name) const; bool has_section_full (std::string sec_name) const; section * get_section (std::string sec_name); const section_map & get_sections (void) const; void add_entry (std::string key, std::string val); bool has_entry (std::string key) const; std::string get_entry (std::string key) const; const entry_map & get_entries (void) const; std::string expand_entry (std::string in, std::string::size_type start = 0) const; void set_root (section * r) { root = r; } section * get_root (void) const { return (root); } std::string get_name (void) const { return (name); } section clone (section * root = NULL) const; }; } // namespace ini } // namespace impl } // namespace saga #endif // _SAGA_IMPL_INI_H_