liblcf
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
inireader.h
Go to the documentation of this file.
1 /*
2  * Read an INI file into easy-to-access name/value pairs.
3  *
4  * Go to the project home page for more info:
5  * http://code.google.com/p/inih/
6  *
7  * inih and INIReader are released under the New BSD license:
8  *
9  * Copyright (c) 2009, Brush Technology
10  * All rights reserved.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions are met:
14  * * Redistributions of source code must retain the above copyright
15  * notice, this list of conditions and the following disclaimer.
16  * * Redistributions in binary form must reproduce the above copyright
17  * notice, this list of conditions and the following disclaimer in the
18  * documentation and/or other materials provided with the distribution.
19  * * Neither the name of Brush Technology nor the names of its contributors
20  * may be used to endorse or promote products derived from this software
21  * without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY BRUSH TECHNOLOGY ''AS IS'' AND ANY
24  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED. IN NO EVENT SHALL BRUSH TECHNOLOGY BE LIABLE FOR ANY
27  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 #ifndef LCF_INIREADER_H
36 #define LCF_INIREADER_H
37 
38 #include <map>
39 #include <string>
40 
45 class INIReader
46 {
47 public:
52  INIReader(std::string filename);
53 
58  int ParseError() const;
59 
63  std::string Get(std::string section, std::string name,
64  std::string default_value);
65 
70  long GetInteger(std::string section, std::string name, long default_value);
71 
72 private:
73  int _error;
74  std::map<std::string, std::string> _values;
75  static std::string MakeKey(std::string section, std::string name);
76  static int ValueHandler(void* user, const char* section, const char* name,
77  const char* value);
78 };
79 
80 #endif
INIReader(std::string filename)
Definition: inireader.cpp:42
static int ValueHandler(void *user, const char *section, const char *name, const char *value)
Definition: inireader.cpp:77
std::map< std::string, std::string > _values
Definition: inireader.h:74
int ParseError() const
Definition: inireader.cpp:47
int _error
Definition: inireader.h:73
long GetInteger(std::string section, std::string name, long default_value)
Definition: inireader.cpp:58
std::string Get(std::string section, std::string name, std::string default_value)
Definition: inireader.cpp:52
static std::string MakeKey(std::string section, std::string name)
Definition: inireader.cpp:68