project_files/frontlib/util/inihelper.h
changeset 7224 5143861c83bd
parent 7179 f84805e6df03
child 7227 1c859f572d72
equal deleted inserted replaced
7221:8d04e85ca204 7224:5143861c83bd
     1 /**
     1 /**
     2  * Some helper functions for working with the iniparser functions - in particular,
     2  * Convenience interface for ini reading/writing.
     3  * for interoperability with the ini format used by the QtSettings class.
     3  *
       
     4  * We currently use iniparser in the background, but using its interface directly is a bit verbose.
       
     5  * This module is supposed to 1. make ini reading and writing a bit more convenient, and 2. hide
       
     6  * the iniparser dependency so it can at need be easily replaced.
     4  */
     7  */
     5 
     8 
     6 #ifndef INIHELPER_H_
     9 #ifndef INIHELPER_H_
     7 #define INIHELPER_H_
    10 #define INIHELPER_H_
     8 
    11 
     9 #include "../iniparser/iniparser.h"
    12 #include "../iniparser/iniparser.h"
    10 
    13 
    11 #include <stdbool.h>
    14 #include <stdbool.h>
       
    15 
       
    16 struct _flib_ini;
       
    17 typedef struct _flib_inihelper flib_ini;
    12 
    18 
    13 /**
    19 /**
    14  * Returned buffer must be free()d
    20  * Returned buffer must be free()d
    15  */
    21  */
    16 char *inihelper_urlencode(const char *inbuf);
    22 char *inihelper_urlencode(const char *inbuf);
    46 /**
    52 /**
    47  * Sets error to true if something goes wrong, leaves it unchanged otherwise.
    53  * Sets error to true if something goes wrong, leaves it unchanged otherwise.
    48  */
    54  */
    49 bool inihelper_getbool(dictionary *inifile, bool *error, const char *sectionName, const char *keyName);
    55 bool inihelper_getbool(dictionary *inifile, bool *error, const char *sectionName, const char *keyName);
    50 
    56 
       
    57 /**
       
    58  * Returns a nonzero value on error.
       
    59  */
    51 int inihelper_setstr(dictionary *dict, const char *sectionName, const char *keyName, const char *value);
    60 int inihelper_setstr(dictionary *dict, const char *sectionName, const char *keyName, const char *value);
       
    61 
       
    62 /**
       
    63  * Returns a nonzero value on error.
       
    64  */
    52 int inihelper_setint(dictionary *dict, const char *sectionName, const char *keyName, int value);
    65 int inihelper_setint(dictionary *dict, const char *sectionName, const char *keyName, int value);
       
    66 
       
    67 /**
       
    68  * Set an ini setting to "true" or "false".
       
    69  * Returns a nonzero value on error.
       
    70  */
    53 int inihelper_setbool(dictionary *dict, const char *sectionName, const char *keyName, bool value);
    71 int inihelper_setbool(dictionary *dict, const char *sectionName, const char *keyName, bool value);
       
    72 
    54 #endif /* INIHELPER_H_ */
    73 #endif /* INIHELPER_H_ */