plibsys
pinifile.h
Go to the documentation of this file.
1 /*
2  * The MIT License
3  *
4  * Copyright (C) 2012-2016 Alexander Saprykin <saprykin.spb@gmail.com>
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining
7  * a copy of this software and associated documentation files (the
8  * 'Software'), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sublicense, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be
15  * included in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25 
94 #if !defined (PLIBSYS_H_INSIDE) && !defined (PLIBSYS_COMPILATION)
95 # error "Header files shouldn't be included directly, consider using <plibsys.h> instead."
96 #endif
97 
98 #ifndef PLIBSYS_HEADER_PINIFILE_H
99 #define PLIBSYS_HEADER_PINIFILE_H
100 
101 #include <pmacros.h>
102 #include <ptypes.h>
103 #include <plist.h>
104 #include <perror.h>
105 
107 
109 typedef struct PIniFile_ PIniFile;
110 
117 P_LIB_API PIniFile * p_ini_file_new (const pchar *path);
118 
124 P_LIB_API void p_ini_file_free (PIniFile *file);
125 
134  PError **error);
135 
143 
154 
165 P_LIB_API PList * p_ini_file_keys (const PIniFile *file,
166  const pchar *section);
167 
177  const pchar *section,
178  const pchar *key);
179 
193  const pchar *section,
194  const pchar *key,
195  const pchar *default_val);
196 
208  const pchar *section,
209  const pchar *key,
210  pint default_val);
211 
223  const pchar *section,
224  const pchar *key,
225  double default_val);
238  const pchar *section,
239  const pchar *key,
240  pboolean default_val);
241 
256  const pchar *section,
257  const pchar *key);
258 
260 
261 #endif /* PLIBSYS_HEADER_PINIFILE_H */
P_LIB_API pboolean p_ini_file_parse(PIniFile *file, PError **error)
Parses given PIniFile.
#define P_END_DECLS
Closes .h file declarations to be exported as C functions, should be always used after P_BEGIN_DECLS...
Definition: pmacros.h:299
P_LIB_API PList * p_ini_file_sections(const PIniFile *file)
Gets all the sections from a given file.
P_LIB_API PList * p_ini_file_keys(const PIniFile *file, const pchar *section)
Gets all the keys from a given section.
typedefP_BEGIN_DECLS struct PList_ PList
Typedef for a list node.
Definition: plist.h:93
typedefP_BEGIN_DECLS struct PIniFile_ PIniFile
INI file opaque data structure.
Definition: pinifile.h:109
P_LIB_API pboolean p_ini_file_parameter_boolean(const PIniFile *file, const pchar *section, const pchar *key, pboolean default_val)
Gets specified parameter&#39;s value as a boolean.
int pint
Type for an int.
Definition: ptypes.h:120
char pchar
Type for a char.
Definition: ptypes.h:116
P_LIB_API pboolean p_ini_file_is_key_exists(const PIniFile *file, const pchar *section, const pchar *key)
Checks whether a key exists.
typedefP_BEGIN_DECLS struct PError_ PError
Opaque data structure for an error object.
Definition: perror.h:68
Miscellaneous macros.
P_LIB_API PList * p_ini_file_parameter_list(const PIniFile *file, const pchar *section, const pchar *key)
Gets specified parameter&#39;s value as a list of strings separated with the spaces or tabs...
P_LIB_API pchar * p_ini_file_parameter_string(const PIniFile *file, const pchar *section, const pchar *key, const pchar *default_val)
Gets specified parameter&#39;s value as a string.
Singly linked list.
signed int pboolean
Type for a bool.
Definition: ptypes.h:114
Error report system.
P_LIB_API double p_ini_file_parameter_double(const PIniFile *file, const pchar *section, const pchar *key, double default_val)
Gets specified parameter&#39;s value as a floating point.
P_LIB_API PIniFile * p_ini_file_new(const pchar *path)
Creates a new PIniFile for parsing.
P_LIB_API pboolean p_ini_file_is_parsed(const PIniFile *file)
Checks whether PIniFile was already parsed or not.
P_LIB_API void p_ini_file_free(PIniFile *file)
Frees memory and allocated resources of PIniFile.
#define P_LIB_API
Exports a symbol from a shared library.
Definition: pmacros.h:138
Types definitions.
P_LIB_API pint p_ini_file_parameter_int(const PIniFile *file, const pchar *section, const pchar *key, pint default_val)
Gets specified parameter&#39;s value as an integer.
#define P_BEGIN_DECLS
Starts .h file declarations to be exported as C functions.
Definition: pmacros.h:298