Exiv2
ini.hpp
1 // Read an INI file into easy-to-access name/value pairs.
2 
3 // inih and INIReader are released under the New BSD license (see LICENSE.txt).
4 // Go to the project home page for more info:
5 //
6 // https://github.com/benhoyt/inih
7 
8 #ifndef __INIREADER_H__
9 #define __INIREADER_H__
10 
11 #include "exiv2lib_export.h"
12 
13 #include <map>
14 #include <string>
15 #include <stdio.h>
16 
17 namespace Exiv2 {
18 
19 /* inih -- simple .INI file parser
20 
21 inih is released under the New BSD license (see LICENSE.txt). Go to the project
22 home page for more info:
23 
24 https://github.com/benhoyt/inih
25 
26 */
27 
28 #ifndef __INI_H__
29 #define __INI_H__
30 
31 /* Make this header file easier to include in C++ code */
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
37 typedef int (*ini_handler)(void* user, const char* section,
38  const char* name, const char* value);
39 
41 typedef char* (*ini_reader)(char* str, int num, void* stream);
42 
63 int ini_parse(const char* filename, ini_handler handler, void* user);
64 
72 int ini_parse_file(FILE* file, ini_handler handler, void* user);
73 
83 int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
84  void* user);
85 
90 #ifndef INI_ALLOW_MULTILINE
91 #define INI_ALLOW_MULTILINE 1
92 #endif
93 
97 #ifndef INI_ALLOW_BOM
98 #define INI_ALLOW_BOM 1
99 #endif
100 
105 #ifndef INI_ALLOW_INLINE_COMMENTS
106 #define INI_ALLOW_INLINE_COMMENTS 1
107 #endif
108 #ifndef INI_INLINE_COMMENT_PREFIXES
109 #define INI_INLINE_COMMENT_PREFIXES ";"
110 #endif
111 
113 #ifndef INI_USE_STACK
114 #define INI_USE_STACK 1
115 #endif
116 
118 #ifndef INI_STOP_ON_FIRST_ERROR
119 #define INI_STOP_ON_FIRST_ERROR 0
120 #endif
121 
123 #ifndef INI_MAX_LINE
124 #define INI_MAX_LINE 200
125 #endif
126 
127 #ifdef __cplusplus
128 }
129 #endif
130 
131 #endif /* __INI_H__ */
132 
133 
137 class EXIV2API INIReader
138 {
139 public:
143  explicit INIReader(const std::string& filename);
144 
148  int ParseError();
149 
158  std::string Get(std::string section, std::string name,
159  std::string default_value);
160 
170  long GetInteger(std::string section, std::string name, long default_value);
171 
182  double GetReal(std::string section, std::string name, double default_value);
183 
194  bool GetBoolean(std::string section, std::string name, bool default_value);
195 
196 private:
197  int _error;
198  std::map<std::string, std::string> _values;
199  static std::string MakeKey(std::string section, std::string name);
200  static int ValueHandler(void* user, const char* section, const char* name,
201  const char* value);
202 };
203 } // namespace Exiv2
204 
205 #endif // __INIREADER_H__
int ini_parse(const char *filename, ini_handler handler, void *user)
Parse given INI-style file. May have [section]s, name=value pairs (whitespace stripped), and comments starting with &#39;;&#39; (semicolon). Section is "" if name=value pair parsed before any section heading. name:value pairs are also supported as a concession to Python&#39;s configparser.
Definition: ini.cpp:198
char *(* ini_reader)(char *str, int num, void *stream)
Typedef for prototype of fgets-style reader function.
Definition: ini.hpp:41
int ini_parse_file(FILE *file, ini_handler handler, void *user)
Same as ini_parse(), but takes a FILE* instead of filename. This doesn&#39;t close the file when it&#39;s fin...
Definition: ini.cpp:192
int(* ini_handler)(void *user, const char *section, const char *name, const char *value)
typedef for prototype of handler function.
Definition: ini.hpp:37
int ini_parse_stream(ini_reader reader, void *stream, ini_handler handler, void *user)
Same as ini_parse(), but takes an ini_reader function pointer instead of filename. Used for implementing custom or string-based I/O.
Definition: ini.cpp:88
IPTC string type.
Definition: types.hpp:147
Read an INI file into easy-to-access name/value pairs. (Note that I&#39;ve gone for simplicity here rathe...
Definition: ini.hpp:137
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: asfvideo.hpp:36