SAGA Adaptor CPI v.1.0
|
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 // System Header Files 00009 00010 #include <iostream> 00011 00012 #include <boost/version.hpp> 00013 #include <saga/saga/version.hpp> 00014 #include <saga/saga/adaptors/utils/ini/ini.hpp> 00015 #include <saga/impl/engine/ini/ini.hpp> 00016 00017 // -------------------------------------------------------- 00018 // 00019 // 00020 // 00021 saga::ini::section::section (shared_sec impl) 00022 : impl_ (impl) 00023 { 00024 } 00025 00026 // -------------------------------------------------------- 00027 // 00028 // 00029 // 00030 saga::ini::section::section (std::string filename) 00031 : impl_ (new impl_sec (filename)) 00032 { 00033 } 00034 00035 // -------------------------------------------------------- 00036 // 00037 // 00038 // 00039 saga::ini::section::section (const section & in) 00040 : impl_ (in.get_impl()) 00041 { 00042 } 00043 00044 // -------------------------------------------------------- 00045 // 00046 // 00047 // 00048 saga::ini::section::section (impl_sec * in) 00049 #if BOOST_VERSION >= 103900 00050 : impl_ (in) 00051 #else 00052 : impl_ (in->_internal_weak_this.use_count() ? 00053 in->shared_from_this() : shared_sec(in)) 00054 #endif 00055 { 00056 } 00057 00058 // -------------------------------------------------------- 00059 // 00060 // 00061 // 00062 saga::ini::section::~section () 00063 { 00064 } 00065 00066 // -------------------------------------------------------- 00067 // 00068 // 00069 // 00070 void saga::ini::section::read (std::string filename) 00071 { 00072 impl_->read (filename); 00073 } 00074 00075 // -------------------------------------------------------- 00076 // 00077 // 00078 // 00079 void saga::ini::section::parse (std::string sourcename, 00080 std::vector <std::string> lines) 00081 { 00082 impl_->parse (sourcename, lines); 00083 } 00084 00085 // -------------------------------------------------------- 00086 // 00087 // 00088 // 00089 void saga::ini::section::merge (std::string second) 00090 { 00091 impl_->merge (second); 00092 } 00093 00094 // -------------------------------------------------------- 00095 // 00096 // 00097 // 00098 void saga::ini::section::merge (const saga::ini::section & second) 00099 { 00100 impl_->merge (second.impl_); 00101 } 00102 00103 // -------------------------------------------------------- 00104 // 00105 // 00106 // 00107 void saga::ini::section::dump (int ind, 00108 std::ostream & strm) const 00109 { 00110 impl_->dump (ind, strm); 00111 } 00112 00113 // -------------------------------------------------------- 00114 // 00115 // 00116 // 00117 void saga::ini::section::add_section (std::string sec_name, 00118 const section & sec) 00119 { 00120 impl_->get_section (sec_name)->merge (sec.impl_); 00121 } 00122 00123 // -------------------------------------------------------- 00124 // 00125 // 00126 // 00127 bool saga::ini::section::has_section (std::string sec_name) const 00128 { 00129 return impl_->has_section (sec_name); 00130 } 00131 00132 // -------------------------------------------------------- 00133 // 00134 // 00135 // 00136 bool saga::ini::section::has_section_full (std::string sec_name) const 00137 { 00138 return impl_->has_section_full (sec_name); 00139 } 00140 00141 // -------------------------------------------------------- 00142 // 00143 // 00144 // 00145 saga::ini::section saga::ini::section::get_section (std::string sec_name) const 00146 { 00147 return saga::ini::section (impl_->get_section (sec_name)); 00148 } 00149 00150 // -------------------------------------------------------- 00151 // 00152 // 00153 // 00154 saga::ini::section_map saga::ini::section::get_sections () const 00155 { 00156 typedef saga::impl::ini::section_map::reference section_impl; 00157 typedef saga::impl::ini::section_map::const_iterator iterator; 00158 00159 saga::ini::section_map out; 00160 iterator end = impl_->get_sections().end(); 00161 for (iterator it = impl_->get_sections().begin(); it != end; ++it) 00162 out[(*it).first] = saga::ini::section((*it).second); 00163 00164 return out; 00165 } 00166 00167 // -------------------------------------------------------- 00168 // 00169 // 00170 // 00171 void saga::ini::section::add_entry (std::string key, 00172 std::string val) 00173 { 00174 impl_->add_entry (key, val); 00175 } 00176 00177 // -------------------------------------------------------- 00178 // 00179 // 00180 // 00181 bool saga::ini::section::has_entry (std::string key) const 00182 { 00183 return impl_->has_entry (key); 00184 } 00185 00186 // -------------------------------------------------------- 00187 // 00188 // 00189 // 00190 std::string saga::ini::section::get_entry (std::string key) const 00191 { 00192 return impl_->get_entry (key); 00193 } 00194 00195 // -------------------------------------------------------- 00196 // 00197 // 00198 // 00199 std::string saga::ini::section::get_entry (std::string key, 00200 std::string dflt_val) const 00201 { 00202 return impl_->get_entry (key, dflt_val); 00203 } 00204 00205 // -------------------------------------------------------- 00206 // 00207 // 00208 // 00209 saga::ini::entry_map saga::ini::section::get_entries (void) const 00210 { 00211 return impl_->get_entries (); 00212 } 00213 00214 // -------------------------------------------------------- 00215 // 00216 // 00217 // 00218 saga::ini::section saga::ini::section::get_root (void) const 00219 { 00220 return saga::ini::section (impl_->get_root ()); 00221 } 00222 00223 // -------------------------------------------------------- 00224 // 00225 // 00226 // 00227 std::string saga::ini::section::get_name (void) const 00228 { 00229 return impl_->get_name (); 00230 } 00231 00232 // -------------------------------------------------------- 00233 // 00234 // 00235 // 00236 void saga::ini::section::debug (std::string msg) const 00237 { 00238 std::cout << "debuggin [" 00239 << impl_.use_count () 00240 << "] ======= " 00241 << impl_->get_name () 00242 << "\" -- \"" 00243 << msg 00244 << "\"" 00245 << std::endl; 00246 } 00247