Parent Directory
|
Revision Log
1 /* 2 * Copyright (C) 2009 Dialogic Corp. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 17 * 02110-1301, USA. 18 * Alternatively see <http://www.gnu.org/licenses/>. 19 * Or see the LICENSE file included within the source tree. 20 * 21 */ 22 23 /*! 24 * \file inifile.h 25 * \brief Simple loader for 'ini' style formatted files. 26 * \author John Tarlton <john.tarlton@dialogic.com> 27 * \version 0.1 28 */ 29 30 #ifndef _INIFILE_H 31 #define _INIFILE_H 32 33 /*------------------------------ Dependencies --------------------------------*/ 34 35 #include <string> 36 #include <map> 37 #include <vector> 38 39 /*----------------------------------------------------------------------------*/ 40 41 /*! 42 * \class IniFile 43 */ 44 class IniFile 45 { 46 public: 47 48 /*! 49 * Container for a section's parameters. A vector is used to preserve the 50 * order of the params and to allow multiple definitions of the same key. 51 */ 52 typedef std::vector<std::pair<std::string, std::string> > section_data_t; 53 54 /*! 55 * ctor 56 */ 57 IniFile() {} 58 59 /*! 60 * dtor 61 */ 62 ~IniFile() {} 63 64 /*! 65 * Load and parse an ini file. 66 * \param filename - file to load. 67 */ 68 bool load( const std::string& filename ); 69 70 /*! 71 * Read a the value of a key. return a default value if not found. 72 * \param section - name of the section 73 * \param key - name of the key. 74 * \param default_value - value returned if key in not found. 75 */ 76 const std::string& get( const std::string& section, 77 const std::string& key, 78 const std::string& default_value ) const; 79 80 /*! 81 * Read all key / values from a section. 82 * \param section - name of the section 83 * \param data - container to receive the information. 84 */ 85 bool getSection( const std::string& section, 86 section_data_t& data ) const; 87 88 /*! 89 * debug aid 90 */ 91 void print() const; 92 93 private: 94 95 void trim( std::string& s ); 96 97 private: 98 99 std::map<std::string, section_data_t > data_; 100 }; 101 102 #endif // _INIFILE_H 103 104 105 /* vim:ts=4:set nu: 106 * EOF 107 */ 108
| No admin address has been configured | ViewVC Help |
| Powered by ViewVC 1.0.8 |