Couldn't find wdiff. Falling back to builtin diff colouring...
| libconfig.h | | libconfig.h | |
| /* ------------------------------------------------------------------------
---- | | /* ------------------------------------------------------------------------
---- | |
| libconfig - A library for processing structured configuration files | | libconfig - A library for processing structured configuration files | |
|
| Copyright (C) 2005-2009 Mark A Lindner | | Copyright (C) 2005-2010 Mark A Lindner | |
| | | | |
| This file is part of libconfig. | | This file is part of libconfig. | |
| | | | |
| This library is free software; you can redistribute it and/or | | This library is free software; you can redistribute it and/or | |
| modify it under the terms of the GNU Lesser General Public License | | modify it under the terms of the GNU Lesser General Public License | |
| as published by the Free Software Foundation; either version 2.1 of | | as published by the Free Software Foundation; either version 2.1 of | |
| the License, or (at your option) any later version. | | the License, or (at your option) any later version. | |
| | | | |
| This library is distributed in the hope that it will be useful, but | | This library is distributed in the hope that it will be useful, but | |
| WITHOUT ANY WARRANTY; without even the implied warranty of | | WITHOUT ANY WARRANTY; without even the implied warranty of | |
| | | | |
| skipping to change at line 42 | | skipping to change at line 42 | |
| #define LIBCONFIG_API | | #define LIBCONFIG_API | |
| #elif defined(LIBCONFIG_EXPORTS) | | #elif defined(LIBCONFIG_EXPORTS) | |
| #define LIBCONFIG_API __declspec(dllexport) | | #define LIBCONFIG_API __declspec(dllexport) | |
| #else /* ! LIBCONFIG_EXPORTS */ | | #else /* ! LIBCONFIG_EXPORTS */ | |
| #define LIBCONFIG_API __declspec(dllimport) | | #define LIBCONFIG_API __declspec(dllimport) | |
| #endif /* LIBCONFIG_STATIC */ | | #endif /* LIBCONFIG_STATIC */ | |
| #else /* ! WIN32 */ | | #else /* ! WIN32 */ | |
| #define LIBCONFIG_API | | #define LIBCONFIG_API | |
| #endif /* WIN32 */ | | #endif /* WIN32 */ | |
| | | | |
|
| | | #define LIBCONFIG_VER_MAJOR 1 | |
| | | #define LIBCONFIG_VER_MINOR 4 | |
| | | #define LIBCONFIG_VER_REVISION 5 | |
| | | | |
| #include <stdio.h> | | #include <stdio.h> | |
| | | | |
| #define CONFIG_TYPE_NONE 0 | | #define CONFIG_TYPE_NONE 0 | |
| #define CONFIG_TYPE_GROUP 1 | | #define CONFIG_TYPE_GROUP 1 | |
| #define CONFIG_TYPE_INT 2 | | #define CONFIG_TYPE_INT 2 | |
| #define CONFIG_TYPE_INT64 3 | | #define CONFIG_TYPE_INT64 3 | |
| #define CONFIG_TYPE_FLOAT 4 | | #define CONFIG_TYPE_FLOAT 4 | |
| #define CONFIG_TYPE_STRING 5 | | #define CONFIG_TYPE_STRING 5 | |
| #define CONFIG_TYPE_BOOL 6 | | #define CONFIG_TYPE_BOOL 6 | |
| #define CONFIG_TYPE_ARRAY 7 | | #define CONFIG_TYPE_ARRAY 7 | |
| | | | |
| skipping to change at line 64 | | skipping to change at line 68 | |
| #define CONFIG_FORMAT_DEFAULT 0 | | #define CONFIG_FORMAT_DEFAULT 0 | |
| #define CONFIG_FORMAT_HEX 1 | | #define CONFIG_FORMAT_HEX 1 | |
| | | | |
| #define CONFIG_OPTION_AUTOCONVERT 0x01 | | #define CONFIG_OPTION_AUTOCONVERT 0x01 | |
| | | | |
| #define CONFIG_TRUE (1) | | #define CONFIG_TRUE (1) | |
| #define CONFIG_FALSE (0) | | #define CONFIG_FALSE (0) | |
| | | | |
| typedef union config_value_t | | typedef union config_value_t | |
| { | | { | |
|
| long ival; | | int ival; | |
| long long llval; | | long long llval; | |
| double fval; | | double fval; | |
| char *sval; | | char *sval; | |
| struct config_list_t *list; | | struct config_list_t *list; | |
| } config_value_t; | | } config_value_t; | |
| | | | |
| typedef struct config_setting_t | | typedef struct config_setting_t | |
| { | | { | |
| char *name; | | char *name; | |
| short type; | | short type; | |
| short format; | | short format; | |
| config_value_t value; | | config_value_t value; | |
| struct config_setting_t *parent; | | struct config_setting_t *parent; | |
| struct config_t *config; | | struct config_t *config; | |
| void *hook; | | void *hook; | |
| unsigned int line; | | unsigned int line; | |
|
| | | const char *file; | |
| } config_setting_t; | | } config_setting_t; | |
| | | | |
|
| | | typedef enum | |
| | | { | |
| | | CONFIG_ERR_NONE = 0, | |
| | | CONFIG_ERR_FILE_IO = 1, | |
| | | CONFIG_ERR_PARSE = 2 | |
| | | } config_error_t; | |
| | | | |
| typedef struct config_list_t | | typedef struct config_list_t | |
| { | | { | |
| unsigned int length; | | unsigned int length; | |
|
| unsigned int capacity; | | | |
| config_setting_t **elements; | | config_setting_t **elements; | |
| } config_list_t; | | } config_list_t; | |
| | | | |
| typedef struct config_t | | typedef struct config_t | |
| { | | { | |
| config_setting_t *root; | | config_setting_t *root; | |
| void (*destructor)(void *); | | void (*destructor)(void *); | |
|
| int flags; | | unsigned short flags; | |
| | | unsigned short tab_width; | |
| const char *error_text; | | const char *error_text; | |
|
| | | const char *error_file; | |
| int error_line; | | int error_line; | |
|
| | | config_error_t error_type; | |
| | | const char **filenames; | |
| | | unsigned int num_filenames; | |
| } config_t; | | } config_t; | |
| | | | |
| extern LIBCONFIG_API int config_read(config_t *config, FILE *stream); | | extern LIBCONFIG_API int config_read(config_t *config, FILE *stream); | |
| extern LIBCONFIG_API void config_write(const config_t *config, FILE *stream
); | | extern LIBCONFIG_API void config_write(const config_t *config, FILE *stream
); | |
| | | | |
| extern LIBCONFIG_API void config_set_auto_convert(config_t *config, int fla
g); | | extern LIBCONFIG_API void config_set_auto_convert(config_t *config, int fla
g); | |
| extern LIBCONFIG_API int config_get_auto_convert(const config_t *config); | | extern LIBCONFIG_API int config_get_auto_convert(const config_t *config); | |
| | | | |
|
| | | extern LIBCONFIG_API int config_read_string(config_t *config, const char *s
tr); | |
| | | | |
| extern LIBCONFIG_API int config_read_file(config_t *config, | | extern LIBCONFIG_API int config_read_file(config_t *config, | |
| const char *filename); | | const char *filename); | |
| extern LIBCONFIG_API int config_write_file(config_t *config, | | extern LIBCONFIG_API int config_write_file(config_t *config, | |
| const char *filename); | | const char *filename); | |
| | | | |
| extern LIBCONFIG_API void config_set_destructor(config_t *config, | | extern LIBCONFIG_API void config_set_destructor(config_t *config, | |
| void (*destructor)(void *))
; | | void (*destructor)(void *))
; | |
| | | | |
| extern LIBCONFIG_API void config_init(config_t *config); | | extern LIBCONFIG_API void config_init(config_t *config); | |
| extern LIBCONFIG_API void config_destroy(config_t *config); | | extern LIBCONFIG_API void config_destroy(config_t *config); | |
| | | | |
|
| extern LIBCONFIG_API long config_setting_get_int( | | extern LIBCONFIG_API int config_setting_get_int( | |
| const config_setting_t *setting); | | const config_setting_t *setting); | |
| extern LIBCONFIG_API long long config_setting_get_int64( | | extern LIBCONFIG_API long long config_setting_get_int64( | |
| const config_setting_t *setting); | | const config_setting_t *setting); | |
| extern LIBCONFIG_API double config_setting_get_float( | | extern LIBCONFIG_API double config_setting_get_float( | |
| const config_setting_t *setting); | | const config_setting_t *setting); | |
| extern LIBCONFIG_API int config_setting_get_bool( | | extern LIBCONFIG_API int config_setting_get_bool( | |
| const config_setting_t *setting); | | const config_setting_t *setting); | |
| extern LIBCONFIG_API const char *config_setting_get_string( | | extern LIBCONFIG_API const char *config_setting_get_string( | |
| const config_setting_t *setting); | | const config_setting_t *setting); | |
| | | | |
| extern LIBCONFIG_API int config_setting_lookup_int( | | extern LIBCONFIG_API int config_setting_lookup_int( | |
|
| const config_setting_t *setting, const char *name, long *value); | | const config_setting_t *setting, const char *name, int *value); | |
| extern LIBCONFIG_API int config_setting_lookup_int64( | | extern LIBCONFIG_API int config_setting_lookup_int64( | |
| const config_setting_t *setting, const char *name, long long *value); | | const config_setting_t *setting, const char *name, long long *value); | |
| extern LIBCONFIG_API int config_setting_lookup_float( | | extern LIBCONFIG_API int config_setting_lookup_float( | |
| const config_setting_t *setting, const char *name, double *value); | | const config_setting_t *setting, const char *name, double *value); | |
| extern LIBCONFIG_API int config_setting_lookup_bool( | | extern LIBCONFIG_API int config_setting_lookup_bool( | |
| const config_setting_t *setting, const char *name, int *value); | | const config_setting_t *setting, const char *name, int *value); | |
| extern LIBCONFIG_API int config_setting_lookup_string( | | extern LIBCONFIG_API int config_setting_lookup_string( | |
| const config_setting_t *setting, const char *name, const char **value); | | const config_setting_t *setting, const char *name, const char **value); | |
| | | | |
| extern LIBCONFIG_API int config_setting_set_int(config_setting_t *setting, | | extern LIBCONFIG_API int config_setting_set_int(config_setting_t *setting, | |
|
| long value); | | int value); | |
| extern LIBCONFIG_API int config_setting_set_int64(config_setting_t *setting
, | | extern LIBCONFIG_API int config_setting_set_int64(config_setting_t *setting
, | |
| long long value); | | long long value); | |
| extern LIBCONFIG_API int config_setting_set_float(config_setting_t *setting
, | | extern LIBCONFIG_API int config_setting_set_float(config_setting_t *setting
, | |
| double value); | | double value); | |
| extern LIBCONFIG_API int config_setting_set_bool(config_setting_t *setting, | | extern LIBCONFIG_API int config_setting_set_bool(config_setting_t *setting, | |
| int value); | | int value); | |
| extern LIBCONFIG_API int config_setting_set_string(config_setting_t *settin
g, | | extern LIBCONFIG_API int config_setting_set_string(config_setting_t *settin
g, | |
| const char *value); | | const char *value); | |
| | | | |
| extern LIBCONFIG_API int config_setting_set_format(config_setting_t *settin
g, | | extern LIBCONFIG_API int config_setting_set_format(config_setting_t *settin
g, | |
| short format); | | short format); | |
| extern LIBCONFIG_API short config_setting_get_format(config_setting_t *sett
ing); | | extern LIBCONFIG_API short config_setting_get_format(config_setting_t *sett
ing); | |
| | | | |
|
| extern LIBCONFIG_API long config_setting_get_int_elem( | | extern LIBCONFIG_API int config_setting_get_int_elem( | |
| const config_setting_t *setting, int idx); | | const config_setting_t *setting, int idx); | |
| extern LIBCONFIG_API long long config_setting_get_int64_elem( | | extern LIBCONFIG_API long long config_setting_get_int64_elem( | |
| const config_setting_t *setting, int idx); | | const config_setting_t *setting, int idx); | |
| extern LIBCONFIG_API double config_setting_get_float_elem( | | extern LIBCONFIG_API double config_setting_get_float_elem( | |
| const config_setting_t *setting, int idx); | | const config_setting_t *setting, int idx); | |
| extern LIBCONFIG_API int config_setting_get_bool_elem( | | extern LIBCONFIG_API int config_setting_get_bool_elem( | |
| const config_setting_t *setting, int idx); | | const config_setting_t *setting, int idx); | |
| extern LIBCONFIG_API const char *config_setting_get_string_elem( | | extern LIBCONFIG_API const char *config_setting_get_string_elem( | |
| const config_setting_t *setting, int idx); | | const config_setting_t *setting, int idx); | |
| | | | |
| extern LIBCONFIG_API config_setting_t *config_setting_set_int_elem( | | extern LIBCONFIG_API config_setting_t *config_setting_set_int_elem( | |
|
| config_setting_t *setting, int idx, long value); | | config_setting_t *setting, int idx, int value); | |
| extern LIBCONFIG_API config_setting_t *config_setting_set_int64_elem( | | extern LIBCONFIG_API config_setting_t *config_setting_set_int64_elem( | |
| config_setting_t *setting, int idx, long long value); | | config_setting_t *setting, int idx, long long value); | |
| extern LIBCONFIG_API config_setting_t *config_setting_set_float_elem( | | extern LIBCONFIG_API config_setting_t *config_setting_set_float_elem( | |
| config_setting_t *setting, int idx, double value); | | config_setting_t *setting, int idx, double value); | |
| extern LIBCONFIG_API config_setting_t *config_setting_set_bool_elem( | | extern LIBCONFIG_API config_setting_t *config_setting_set_bool_elem( | |
| config_setting_t *setting, int idx, int value); | | config_setting_t *setting, int idx, int value); | |
| extern LIBCONFIG_API config_setting_t *config_setting_set_string_elem( | | extern LIBCONFIG_API config_setting_t *config_setting_set_string_elem( | |
| config_setting_t *setting, int idx, const char *value); | | config_setting_t *setting, int idx, const char *value); | |
| | | | |
| #define /* int */ config_setting_type(/* const config_setting_t * */ S) \ | | #define /* int */ config_setting_type(/* const config_setting_t * */ S) \ | |
| | | | |
| skipping to change at line 234 | | skipping to change at line 252 | |
| const char *name); | | const char *name); | |
| extern LIBCONFIG_API int config_setting_remove_elem(config_setting_t *paren
t, | | extern LIBCONFIG_API int config_setting_remove_elem(config_setting_t *paren
t, | |
| unsigned int idx); | | unsigned int idx); | |
| extern LIBCONFIG_API void config_setting_set_hook(config_setting_t *setting
, | | extern LIBCONFIG_API void config_setting_set_hook(config_setting_t *setting
, | |
| void *hook); | | void *hook); | |
| | | | |
| #define config_setting_get_hook(S) ((S)->hook) | | #define config_setting_get_hook(S) ((S)->hook) | |
| | | | |
| extern LIBCONFIG_API config_setting_t *config_lookup(const config_t *config
, | | extern LIBCONFIG_API config_setting_t *config_lookup(const config_t *config
, | |
| const char *path); | | const char *path); | |
|
| | | extern LIBCONFIG_API config_setting_t *config_lookup_from( | |
| | | config_setting_t *setting, const char *path); | |
| | | | |
| extern LIBCONFIG_API int config_lookup_int(const config_t *config, | | extern LIBCONFIG_API int config_lookup_int(const config_t *config, | |
|
| const char *path, long *value); | | const char *path, int *value); | |
| extern LIBCONFIG_API int config_lookup_int64(const config_t *config, | | extern LIBCONFIG_API int config_lookup_int64(const config_t *config, | |
| const char *path, | | const char *path, | |
| long long *value); | | long long *value); | |
| extern LIBCONFIG_API int config_lookup_float(const config_t *config, | | extern LIBCONFIG_API int config_lookup_float(const config_t *config, | |
| const char *path, double *valu
e); | | const char *path, double *valu
e); | |
| extern LIBCONFIG_API int config_lookup_bool(const config_t *config, | | extern LIBCONFIG_API int config_lookup_bool(const config_t *config, | |
| const char *path, int *value); | | const char *path, int *value); | |
| extern LIBCONFIG_API int config_lookup_string(const config_t *config, | | extern LIBCONFIG_API int config_lookup_string(const config_t *config, | |
| const char *path, | | const char *path, | |
| const char **value); | | const char **value); | |
| | | | |
| #define /* config_setting_t * */ config_root_setting( \ | | #define /* config_setting_t * */ config_root_setting( \ | |
| /* const config_t * */ C) \ | | /* const config_t * */ C) \ | |
| ((C)->root) | | ((C)->root) | |
| | | | |
|
| #define /* unsigned short */ config_setting_source_line( \ | | #define /* void */ config_set_tab_width(/* config_t * */ C, \ | |
| /* const config_t */ C) \ | | /* unsigned short */ W) \ | |
| ((C)->line) | | (C)->tab_width = ((W) & 0x0F) | |
| | | | |
| | | #define /* unsigned char */ config_get_tab_width(/* const config_t * */ C)
\ | |
| | | ((C)->tab_width) | |
| | | | |
| | | #define /* unsigned short */ config_setting_source_line( \ | |
| | | /* const config_setting_t * */ S) \ | |
| | | ((S)->line) | |
| | | | |
| | | #define /* const char */ config_setting_source_file( \ | |
| | | /* const config_setting_t * */ S) \ | |
| | | ((S)->file) | |
| | | | |
| #define /* const char * */ config_error_text(/* const config_t * */ C) \ | | #define /* const char * */ config_error_text(/* const config_t * */ C) \ | |
| ((C)->error_text) | | ((C)->error_text) | |
| | | | |
|
| | | #define /* const char * */ config_error_file(/* const config_t * */ C) \ | |
| | | ((C)->error_file) | |
| | | | |
| #define /* int */ config_error_line(/* const config_t * */ C) \ | | #define /* int */ config_error_line(/* const config_t * */ C) \ | |
| ((C)->error_line) | | ((C)->error_line) | |
| | | | |
|
| | | #define /* config_error_t */ config_error_type(/* const config_t * */ C) \ | |
| | | ((C)->error_type) | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| #endif /* __cplusplus */ | | #endif /* __cplusplus */ | |
| | | | |
| #endif /* __libconfig_h */ | | #endif /* __libconfig_h */ | |
| | | | |
End of changes. 20 change blocks. |
| 13 lines changed or deleted | | 50 lines changed or added | |
|
| libconfig.h++ | | libconfig.h++ | |
| /* ------------------------------------------------------------------------
---- | | /* ------------------------------------------------------------------------
---- | |
| libconfig - A library for processing structured configuration files | | libconfig - A library for processing structured configuration files | |
|
| Copyright (C) 2005-2009 Mark A Lindner | | Copyright (C) 2005-2010 Mark A Lindner | |
| | | | |
| This file is part of libconfig. | | This file is part of libconfig. | |
| | | | |
| This library is free software; you can redistribute it and/or | | This library is free software; you can redistribute it and/or | |
| modify it under the terms of the GNU Lesser General Public License | | modify it under the terms of the GNU Lesser General Public License | |
| as published by the Free Software Foundation; either version 2.1 of | | as published by the Free Software Foundation; either version 2.1 of | |
| the License, or (at your option) any later version. | | the License, or (at your option) any later version. | |
| | | | |
| This library is distributed in the hope that it will be useful, but | | This library is distributed in the hope that it will be useful, but | |
| WITHOUT ANY WARRANTY; without even the implied warranty of | | WITHOUT ANY WARRANTY; without even the implied warranty of | |
| | | | |
| skipping to change at line 27 | | skipping to change at line 27 | |
| You should have received a copy of the GNU Library General Public | | You should have received a copy of the GNU Library General Public | |
| License along with this library; if not, see | | License along with this library; if not, see | |
| <http://www.gnu.org/licenses/>. | | <http://www.gnu.org/licenses/>. | |
| ------------------------------------------------------------------------
---- | | ------------------------------------------------------------------------
---- | |
| */ | | */ | |
| | | | |
| #ifndef __libconfig_hpp | | #ifndef __libconfig_hpp | |
| #define __libconfig_hpp | | #define __libconfig_hpp | |
| | | | |
| #include <stdio.h> | | #include <stdio.h> | |
|
| | | #include <exception> | |
| #include <string> | | #include <string> | |
|
| #include <map> | | | |
| | | | |
|
| namespace libconfig | | #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) | |
| | | #if defined(LIBCONFIGXX_STATIC) | |
| | | #define LIBCONFIGXX_API | |
| | | #elif defined(LIBCONFIGXX_EXPORTS) | |
| | | #define LIBCONFIGXX_API __declspec(dllexport) | |
| | | #else /* ! LIBCONFIGXX_EXPORTS */ | |
| | | #define LIBCONFIGXX_API __declspec(dllimport) | |
| | | #endif /* LIBCONFIGXX_STATIC */ | |
| | | #else /* ! WIN32 */ | |
| | | #define LIBCONFIGXX_API | |
| | | #endif /* WIN32 */ | |
| | | | |
| | | #define LIBCONFIGXX_VER_MAJOR 1 | |
| | | #define LIBCONFIGXX_VER_MINOR 4 | |
| | | #define LIBCONFIGXX_VER_REVISION 5 | |
| | | | |
| | | struct config_t; // fwd decl | |
| | | struct config_setting_t; // fwd decl | |
| | | | |
| | | namespace libconfig { | |
| | | | |
| | | class LIBCONFIGXX_API ConfigException : public std::exception { }; | |
| | | | |
| | | class Setting; // fwd decl | |
| | | | |
| | | class LIBCONFIGXX_API SettingException : public ConfigException | |
| { | | { | |
|
| | | friend class Config; | |
| | | | |
|
| #include <libconfig.h> | | public: | |
| | | | |
|
| class LIBCONFIG_API ConfigException : public std::exception { }; | | SettingException(const SettingException &other); | |
| | | SettingException& operator=(const SettingException &other); | |
| | | | |
|
| class Setting; // fwd decl | | virtual ~SettingException() throw(); | |
| | | | |
|
| class LIBCONFIG_API SettingException : public ConfigException | | const char *getPath() const; | |
| { | | | |
| friend class Config; | | | |
| | | | |
|
| public: | | virtual const char *what() const throw(); | |
| | | | |
|
| SettingException(const SettingException &other); | | protected: | |
| SettingException& operator=(const SettingException &other); | | | |
| | | | |
|
| virtual ~SettingException() throw(); | | SettingException(const Setting &setting); | |
| | | SettingException(const Setting &setting, int idx); | |
| | | SettingException(const Setting &setting, const char *name); | |
| | | SettingException(const char *path); | |
| | | | |
|
| const char *getPath() const; | | private: | |
| | | | |
|
| virtual const char *what() const throw(); | | char *_path; | |
| | | }; | |
| | | | |
|
| protected: | | class LIBCONFIGXX_API SettingTypeException : public SettingException | |
| | | { | |
| | | friend class Config; | |
| | | friend class Setting; | |
| | | | |
|
| SettingException(const Setting &setting); | | public: | |
| SettingException(const Setting &setting, int idx); | | | |
| SettingException(const Setting &setting, const char *name); | | | |
| SettingException(const char *path); | | | |
| | | | |
|
| private: | | const char *what() const throw(); | |
| | | | |
|
| char *_path; | | private: | |
| }; | | | |
| | | | |
|
| class LIBCONFIG_API SettingTypeException : public SettingException | | SettingTypeException(const Setting &setting); | |
| { | | SettingTypeException(const Setting &setting, int idx); | |
| friend class Config; | | SettingTypeException(const Setting &setting, const char *name); | |
| friend class Setting; | | }; | |
| | | | |
|
| const char *what() const throw(); | | class LIBCONFIGXX_API SettingNotFoundException : public SettingException | |
| | | { | |
| | | friend class Config; | |
| | | friend class Setting; | |
| | | | |
|
| private: | | public: | |
| | | | |
|
| SettingTypeException(const Setting &setting); | | const char *what() const throw(); | |
| SettingTypeException(const Setting &setting, int idx); | | | |
| SettingTypeException(const Setting &setting, const char *name); | | | |
| }; | | | |
| | | | |
|
| class LIBCONFIG_API SettingNotFoundException : public SettingException | | private: | |
| { | | | |
| friend class Config; | | | |
| friend class Setting; | | | |
| | | | |
|
| const char *what() const throw(); | | SettingNotFoundException(const Setting &setting, int idx); | |
| | | SettingNotFoundException(const Setting &setting, const char *name); | |
| | | SettingNotFoundException(const char *path); | |
| | | }; | |
| | | | |
|
| private: | | class LIBCONFIGXX_API SettingNameException : public SettingException | |
| | | { | |
| | | friend class Config; | |
| | | friend class Setting; | |
| | | | |
|
| SettingNotFoundException(const Setting &setting, int idx); | | public: | |
| SettingNotFoundException(const Setting &setting, const char *name); | | | |
| SettingNotFoundException(const char *path); | | | |
| }; | | | |
| | | | |
|
| class LIBCONFIG_API SettingNameException : public SettingException | | const char *what() const throw(); | |
| { | | | |
| friend class Config; | | | |
| friend class Setting; | | | |
| | | | |
|
| const char *what() const throw(); | | private: | |
| | | | |
|
| private: | | SettingNameException(const Setting &setting, const char *name); | |
| | | }; | |
| | | | |
|
| SettingNameException(const Setting &setting, const char *name); | | class LIBCONFIGXX_API FileIOException : public ConfigException | |
| }; | | { | |
| | | public: | |
| | | | |
|
| class LIBCONFIG_API FileIOException : public ConfigException | | const char *what() const throw(); | |
| { | | }; | |
| const char *what() const throw(); | | | |
| }; | | | |
| | | | |
|
| class LIBCONFIG_API ParseException : public ConfigException | | class LIBCONFIGXX_API ParseException : public ConfigException | |
| { | | { | |
| friend class Config; | | friend class Config; | |
| | | | |
|
| public: | | public: | |
| | | | |
|
| virtual ~ParseException() throw(); | | ParseException(const ParseException &other); | |
| | | | |
|
| inline int getLine() throw() | | virtual ~ParseException() throw(); | |
| { return(_line); } | | | |
| | | | |
|
| inline const char *getError() throw() | | inline const char *getFile() const throw() | |
| { return(_error); } | | { return(_file); } | |
| | | | |
|
| const char *what() const throw(); | | inline int getLine() const throw() | |
| | | { return(_line); } | |
| | | | |
|
| private: | | inline const char *getError() const throw() | |
| | | { return(_error); } | |
| | | | |
|
| ParseException(int line, const char *error); | | const char *what() const throw(); | |
| | | | |
|
| int _line; | | private: | |
| const char *_error; | | | |
| }; | | | |
| | | | |
|
| class LIBCONFIG_API Setting | | ParseException(const char *file, int line, const char *error); | |
| { | | | |
| friend class Config; | | | |
| | | | |
|
| public: | | const char *_file; | |
| | | int _line; | |
| | | const char *_error; | |
| | | }; | |
| | | | |
|
| enum Type | | class LIBCONFIGXX_API Setting | |
| { | | { | |
| TypeNone = 0, | | friend class Config; | |
| // scalar types | | | |
| TypeInt, | | | |
| TypeInt64, | | | |
| TypeFloat, | | | |
| TypeString, | | | |
| TypeBoolean, | | | |
| // aggregate types | | | |
| TypeGroup, | | | |
| TypeArray, | | | |
| TypeList | | | |
| }; | | | |
| | | | |
|
| enum Format | | public: | |
| { | | | |
| FormatDefault = 0, | | | |
| FormatHex = 1 | | | |
| }; | | | |
| | | | |
|
| private: | | enum Type | |
| | | { | |
| | | TypeNone = 0, | |
| | | // scalar types | |
| | | TypeInt, | |
| | | TypeInt64, | |
| | | TypeFloat, | |
| | | TypeString, | |
| | | TypeBoolean, | |
| | | // aggregate types | |
| | | TypeGroup, | |
| | | TypeArray, | |
| | | TypeList | |
| | | }; | |
| | | | |
|
| config_setting_t *_setting; | | enum Format | |
| Type _type; | | { | |
| Format _format; | | FormatDefault = 0, | |
| | | FormatHex = 1 | |
| | | }; | |
| | | | |
|
| Setting(config_setting_t *setting); | | private: | |
| | | | |
|
| void assertType(Type type) const | | config_setting_t *_setting; | |
| throw(SettingTypeException); | | Type _type; | |
| static Setting & wrapSetting(config_setting_t *setting); | | Format _format; | |
| | | | |
|
| Setting(const Setting& other); // not supported | | Setting(config_setting_t *setting); | |
| Setting& operator=(const Setting& other); // not supported | | | |
| | | | |
|
| public: | | void assertType(Type type) const | |
| | | throw(SettingTypeException); | |
| | | static Setting & wrapSetting(config_setting_t *setting); | |
| | | | |
|
| virtual ~Setting() throw(); | | Setting(const Setting& other); // not supported | |
| | | Setting& operator=(const Setting& other); // not supported | |
| | | | |
|
| inline Type getType() const throw() { return(_type); } | | public: | |
| | | | |
|
| inline Format getFormat() const throw() { return(_format); } | | virtual ~Setting() throw(); | |
| void setFormat(Format format) throw(); | | | |
| | | | |
|
| operator bool() const throw(SettingTypeException); | | inline Type getType() const throw() { return(_type); } | |
| operator long() const throw(SettingTypeException); | | | |
| operator unsigned long() const throw(SettingTypeException); | | | |
| operator int() const throw(SettingTypeException); | | | |
| operator unsigned int() const throw(SettingTypeException); | | | |
| operator long long() const throw(SettingTypeException); | | | |
| operator unsigned long long() const throw(SettingTypeException); | | | |
| operator double() const throw(SettingTypeException); | | | |
| operator float() const throw(SettingTypeException); | | | |
| operator const char *() const throw(SettingTypeException); | | | |
| operator std::string() const throw(SettingTypeException); | | | |
| | | | |
|
| Setting & operator=(bool value) throw(SettingTypeException); | | inline Format getFormat() const throw() { return(_format); } | |
| Setting & operator=(long value) throw(SettingTypeException); | | void setFormat(Format format) throw(); | |
| Setting & operator=(int value) throw(SettingTypeException); | | | |
| Setting & operator=(const long long &value) throw(SettingTypeException)
; | | | |
| Setting & operator=(const double &value) throw(SettingTypeException); | | | |
| Setting & operator=(float value) throw(SettingTypeException); | | | |
| Setting & operator=(const char *value) throw(SettingTypeException); | | | |
| Setting & operator=(const std::string &value) throw(SettingTypeExceptio
n); | | | |
| | | | |
|
| Setting & operator[](const char * key) const | | operator bool() const throw(SettingTypeException); | |
| throw(SettingTypeException, SettingNotFoundException); | | operator int() const throw(SettingTypeException); | |
| | | operator unsigned int() const throw(SettingTypeException); | |
| | | operator long() const throw(SettingTypeException); | |
| | | operator unsigned long() const throw(SettingTypeException); | |
| | | operator long long() const throw(SettingTypeException); | |
| | | operator unsigned long long() const throw(SettingTypeException); | |
| | | operator double() const throw(SettingTypeException); | |
| | | operator float() const throw(SettingTypeException); | |
| | | operator const char *() const throw(SettingTypeException); | |
| | | operator std::string() const throw(SettingTypeException); | |
| | | | |
|
| inline Setting & operator[](const std::string & key) const | | inline const char *c_str() const throw(SettingTypeException) | |
| throw(SettingTypeException, SettingNotFoundException) | | { return operator const char*(); } | |
| { return(operator[](key.c_str())); } | | | |
| | | | |
|
| Setting & operator[](int index) const | | Setting & operator=(bool value) throw(SettingTypeException); | |
| throw(SettingTypeException, SettingNotFoundException); | | Setting & operator=(int value) throw(SettingTypeException); | |
| | | Setting & operator=(long value) throw(SettingTypeException); | |
| | | Setting & operator=(const long long &value) throw(SettingTypeException); | |
| | | Setting & operator=(const double &value) throw(SettingTypeException); | |
| | | Setting & operator=(float value) throw(SettingTypeException); | |
| | | Setting & operator=(const char *value) throw(SettingTypeException); | |
| | | Setting & operator=(const std::string &value) throw(SettingTypeException)
; | |
| | | | |
|
| bool lookupValue(const char *name, bool &value) const throw(); | | Setting & operator[](const char *key) const | |
| bool lookupValue(const char *name, long &value) const throw(); | | throw(SettingTypeException, SettingNotFoundException); | |
| bool lookupValue(const char *name, unsigned long &value) const throw(); | | | |
| bool lookupValue(const char *name, int &value) const throw(); | | | |
| bool lookupValue(const char *name, unsigned int &value) const throw(); | | | |
| bool lookupValue(const char *name, long long &value) const throw(); | | | |
| bool lookupValue(const char *name, unsigned long long &value) | | | |
| const throw(); | | | |
| bool lookupValue(const char *name, double &value) const throw(); | | | |
| bool lookupValue(const char *name, float &value) const throw(); | | | |
| bool lookupValue(const char *name, const char *&value) const throw(); | | | |
| bool lookupValue(const char *name, std::string &value) const throw(); | | | |
| | | | |
|
| inline bool lookupValue(const std::string &name, bool &value) | | inline Setting & operator[](const std::string &key) const | |
| const throw() | | throw(SettingTypeException, SettingNotFoundException) | |
| { return(lookupValue(name.c_str(), value)); } | | { return(operator[](key.c_str())); } | |
| | | | |
|
| inline bool lookupValue(const std::string &name, long &value) | | Setting & operator[](int index) const | |
| const throw() | | throw(SettingTypeException, SettingNotFoundException); | |
| { return(lookupValue(name.c_str(), value)); } | | | |
| | | | |
|
| inline bool lookupValue(const std::string &name, unsigned long &value) | | bool lookupValue(const char *name, bool &value) const throw(); | |
| const throw() | | bool lookupValue(const char *name, int &value) const throw(); | |
| { return(lookupValue(name.c_str(), value)); } | | bool lookupValue(const char *name, unsigned int &value) const throw(); | |
| | | bool lookupValue(const char *name, long long &value) const throw(); | |
| | | bool lookupValue(const char *name, unsigned long long &value) | |
| | | const throw(); | |
| | | bool lookupValue(const char *name, double &value) const throw(); | |
| | | bool lookupValue(const char *name, float &value) const throw(); | |
| | | bool lookupValue(const char *name, const char *&value) const throw(); | |
| | | bool lookupValue(const char *name, std::string &value) const throw(); | |
| | | | |
|
| inline bool lookupValue(const std::string &name, int &value) const thro
w() | | inline bool lookupValue(const std::string &name, bool &value) | |
| { return(lookupValue(name.c_str(), value)); } | | const throw() | |
| | | { return(lookupValue(name.c_str(), value)); } | |
| | | | |
|
| inline bool lookupValue(const std::string &name, unsigned int &value) | | inline bool lookupValue(const std::string &name, int &value) | |
| const throw() | | const throw() | |
| { return(lookupValue(name.c_str(), value)); } | | { return(lookupValue(name.c_str(), value)); } | |
| | | | |
|
| inline bool lookupValue(const std::string &name, long long &value) | | inline bool lookupValue(const std::string &name, unsigned int &value) | |
| const throw() | | const throw() | |
| { return(lookupValue(name.c_str(), value)); } | | { return(lookupValue(name.c_str(), value)); } | |
| | | | |
|
| inline bool lookupValue(const std::string &name, | | inline bool lookupValue(const std::string &name, long long &value) | |
| unsigned long long &value) const throw() | | const throw() | |
| { return(lookupValue(name.c_str(), value)); } | | { return(lookupValue(name.c_str(), value)); } | |
| | | | |
|
| inline bool lookupValue(const std::string &name, double &value) const | | inline bool lookupValue(const std::string &name, | |
| throw() | | unsigned long long &value) const throw() | |
| { return(lookupValue(name.c_str(), value)); } | | { return(lookupValue(name.c_str(), value)); } | |
| | | | |
|
| inline bool lookupValue(const std::string &name, float &value) const | | inline bool lookupValue(const std::string &name, double &value) const | |
| throw() | | throw() | |
| { return(lookupValue(name.c_str(), value)); } | | { return(lookupValue(name.c_str(), value)); } | |
| | | | |
|
| inline bool lookupValue(const std::string &name, const char *&value) co
nst | | inline bool lookupValue(const std::string &name, float &value) const | |
| throw() | | throw() | |
| { return(lookupValue(name.c_str(), value)); } | | { return(lookupValue(name.c_str(), value)); } | |
| | | | |
|
| inline bool lookupValue(const std::string &name, std::string &value) co
nst | | inline bool lookupValue(const std::string &name, const char *&value) cons
t | |
| throw() | | throw() | |
| { return(lookupValue(name.c_str(), value)); } | | { return(lookupValue(name.c_str(), value)); } | |
| | | | |
|
| void remove(const char *name) | | inline bool lookupValue(const std::string &name, std::string &value) cons
t | |
| throw(SettingTypeException, SettingNotFoundException); | | throw() | |
| | | { return(lookupValue(name.c_str(), value)); } | |
| | | | |
|
| inline void remove(const std::string & name) | | void remove(const char *name) | |
| throw(SettingTypeException, SettingNotFoundException) | | throw(SettingTypeException, SettingNotFoundException); | |
| { remove(name.c_str()); } | | | |
| | | | |
|
| void remove(unsigned int idx) | | inline void remove(const std::string & name) | |
| throw(SettingTypeException, SettingNotFoundException); | | throw(SettingTypeException, SettingNotFoundException) | |
| | | { remove(name.c_str()); } | |
| | | | |
|
| inline Setting & add(const std::string & name, Type type) | | void remove(unsigned int idx) | |
| throw(SettingNameException, SettingTypeException) | | throw(SettingTypeException, SettingNotFoundException); | |
| { return(add(name.c_str(), type)); } | | | |
| | | | |
|
| Setting & add(const char *name, Type type) | | inline Setting & add(const std::string & name, Type type) | |
| throw(SettingNameException, SettingTypeException); | | throw(SettingNameException, SettingTypeException) | |
| | | { return(add(name.c_str(), type)); } | |
| | | | |
|
| Setting & add(Type type) throw(SettingTypeException); | | Setting & add(const char *name, Type type) | |
| | | throw(SettingNameException, SettingTypeException); | |
| | | | |
|
| inline bool exists(const std::string & name) const throw() | | Setting & add(Type type) throw(SettingTypeException); | |
| { return(exists(name.c_str())); } | | | |
| | | | |
|
| bool exists(const char *name) const throw(); | | inline bool exists(const std::string &name) const throw() | |
| | | { return(exists(name.c_str())); } | |
| | | | |
|
| int getLength() const throw(); | | bool exists(const char *name) const throw(); | |
| const char *getName() const throw(); | | | |
| std::string getPath() const; | | | |
| int getIndex() const throw(); | | | |
| | | | |
|
| const Setting & getParent() const throw(SettingNotFoundException); | | int getLength() const throw(); | |
| Setting & getParent() throw(SettingNotFoundException); | | const char *getName() const throw(); | |
| | | std::string getPath() const; | |
| | | int getIndex() const throw(); | |
| | | | |
|
| bool isRoot() const throw(); | | const Setting & getParent() const throw(SettingNotFoundException); | |
| | | Setting & getParent() throw(SettingNotFoundException); | |
| | | | |
|
| inline bool isGroup() const throw() | | bool isRoot() const throw(); | |
| { return(_type == TypeGroup); } | | | |
| | | | |
|
| inline bool isArray() const throw() | | inline bool isGroup() const throw() | |
| { return(_type == TypeArray); } | | { return(_type == TypeGroup); } | |
| | | | |
|
| inline bool isList() const throw() | | inline bool isArray() const throw() | |
| { return(_type == TypeList); } | | { return(_type == TypeArray); } | |
| | | | |
|
| inline bool isAggregate() const throw() | | inline bool isList() const throw() | |
| { return(_type >= TypeGroup); } | | { return(_type == TypeList); } | |
| | | | |
|
| inline bool isScalar() const throw() | | inline bool isAggregate() const throw() | |
| { return((_type > TypeNone) && (_type < TypeGroup)); } | | { return(_type >= TypeGroup); } | |
| | | | |
|
| inline bool isNumber() const throw() | | inline bool isScalar() const throw() | |
| { return((_type == TypeInt) || (_type == TypeInt64) | | { return((_type > TypeNone) && (_type < TypeGroup)); } | |
| || (_type == TypeFloat)); } | | | |
| | | | |
|
| inline unsigned int getSourceLine() const throw() | | inline bool isNumber() const throw() | |
| { return(config_setting_source_line(_setting)); } | | { return((_type == TypeInt) || (_type == TypeInt64) | |
| }; | | || (_type == TypeFloat)); } | |
| | | | |
|
| class LIBCONFIG_API Config | | unsigned int getSourceLine() const throw(); | |
| { | | const char *getSourceFile() const throw(); | |
| private: | | }; | |
| | | | |
|
| config_t _config; | | class LIBCONFIGXX_API Config | |
| | | { | |
| | | private: | |
| | | | |
|
| static void ConfigDestructor(void *arg); | | config_t *_config; | |
| Config(const Config& other); // not supported | | | |
| Config& operator=(const Config& other); // not supported | | | |
| | | | |
|
| public: | | static void ConfigDestructor(void *arg); | |
| | | Config(const Config& other); // not supported | |
| | | Config& operator=(const Config& other); // not supported | |
| | | | |
|
| Config(); | | public: | |
| virtual ~Config(); | | | |
| | | | |
|
| void setAutoConvert(bool flag); | | Config(); | |
| bool getAutoConvert() const; | | virtual ~Config(); | |
| | | | |
|
| void read(FILE *stream) throw(ParseException); | | void setAutoConvert(bool flag); | |
| void write(FILE *stream) const; | | bool getAutoConvert() const; | |
| | | | |
|
| void readFile(const char *filename) throw(FileIOException, ParseExcepti
on); | | void setTabWidth(unsigned short width) throw(); | |
| void writeFile(const char *filename) throw(FileIOException); | | unsigned short getTabWidth() const throw(); | |
| | | | |
|
| inline Setting & lookup(const std::string &path) const | | void read(FILE *stream) throw(ParseException); | |
| throw(SettingNotFoundException) | | void write(FILE *stream) const; | |
| { return(lookup(path.c_str())); } | | | |
| | | | |
|
| Setting & lookup(const char *path) const throw(SettingNotFoundException
); | | void readString(const char *str) throw(ParseException); | |
| | | inline void readString(const std::string &str) throw(ParseException) | |
| | | { return(readString(str.c_str())); } | |
| | | | |
|
| inline bool exists(const std::string & path) const throw() | | void readFile(const char *filename) throw(FileIOException, ParseException
); | |
| { return(exists(path.c_str())); } | | void writeFile(const char *filename) throw(FileIOException); | |
| | | | |
|
| bool exists(const char *path) const throw(); | | inline Setting & lookup(const std::string &path) const | |
| | | throw(SettingNotFoundException) | |
| | | { return(lookup(path.c_str())); } | |
| | | | |
|
| bool lookupValue(const char *path, bool &value) const throw(); | | Setting & lookup(const char *path) const throw(SettingNotFoundException); | |
| bool lookupValue(const char *path, long &value) const throw(); | | | |
| bool lookupValue(const char *path, unsigned long &value) const throw(); | | | |
| bool lookupValue(const char *path, int &value) const throw(); | | | |
| bool lookupValue(const char *path, unsigned int &value) const throw(); | | | |
| bool lookupValue(const char *path, long long &value) const throw(); | | | |
| bool lookupValue(const char *path, unsigned long long &value) | | | |
| const throw(); | | | |
| bool lookupValue(const char *path, double &value) const throw(); | | | |
| bool lookupValue(const char *path, float &value) const throw(); | | | |
| bool lookupValue(const char *path, const char *&value) const throw(); | | | |
| bool lookupValue(const char *path, std::string &value) const throw(); | | | |
| | | | |
|
| inline bool lookupValue(const std::string &path, bool &value) const thr
ow() | | inline bool exists(const std::string & path) const throw() | |
| { return(lookupValue(path.c_str(), value)); } | | { return(exists(path.c_str())); } | |
| | | | |
|
| inline bool lookupValue(const std::string &path, long &value) const thr
ow() | | bool exists(const char *path) const throw(); | |
| { return(lookupValue(path.c_str(), value)); } | | | |
| | | | |
|
| inline bool lookupValue(const std::string &path, unsigned long &value) | | bool lookupValue(const char *path, bool &value) const throw(); | |
| const throw() | | bool lookupValue(const char *path, int &value) const throw(); | |
| { return(lookupValue(path.c_str(), value)); } | | bool lookupValue(const char *path, unsigned int &value) const throw(); | |
| | | bool lookupValue(const char *path, long long &value) const throw(); | |
| | | bool lookupValue(const char *path, unsigned long long &value) | |
| | | const throw(); | |
| | | bool lookupValue(const char *path, double &value) const throw(); | |
| | | bool lookupValue(const char *path, float &value) const throw(); | |
| | | bool lookupValue(const char *path, const char *&value) const throw(); | |
| | | bool lookupValue(const char *path, std::string &value) const throw(); | |
| | | | |
|
| inline bool lookupValue(const std::string &path, int &value) const thro
w() | | inline bool lookupValue(const std::string &path, bool &value) const throw
() | |
| { return(lookupValue(path.c_str(), value)); } | | { return(lookupValue(path.c_str(), value)); } | |
| | | | |
|
| inline bool lookupValue(const std::string &path, unsigned int &value) | | inline bool lookupValue(const std::string &path, int &value) const throw(
) | |
| const throw() | | { return(lookupValue(path.c_str(), value)); } | |
| { return(lookupValue(path.c_str(), value)); } | | | |
| | | | |
|
| inline bool lookupValue(const std::string &path, long long &value) | | inline bool lookupValue(const std::string &path, unsigned int &value) | |
| const throw() | | const throw() | |
| { return(lookupValue(path.c_str(), value)); } | | { return(lookupValue(path.c_str(), value)); } | |
| | | | |
|
| inline bool lookupValue(const std::string &path, | | inline bool lookupValue(const std::string &path, long long &value) | |
| unsigned long long &value) const throw() | | const throw() | |
| { return(lookupValue(path.c_str(), value)); } | | { return(lookupValue(path.c_str(), value)); } | |
| | | | |
|
| inline bool lookupValue(const std::string &path, double &value) | | inline bool lookupValue(const std::string &path, | |
| const throw() | | unsigned long long &value) const throw() | |
| { return(lookupValue(path.c_str(), value)); } | | { return(lookupValue(path.c_str(), value)); } | |
| | | | |
|
| inline bool lookupValue(const std::string &path, float &value) | | inline bool lookupValue(const std::string &path, double &value) | |
| const throw() | | const throw() | |
| { return(lookupValue(path.c_str(), value)); } | | { return(lookupValue(path.c_str(), value)); } | |
| | | | |
|
| inline bool lookupValue(const std::string &path, const char *&value) | | inline bool lookupValue(const std::string &path, float &value) | |
| const throw() | | const throw() | |
| { return(lookupValue(path.c_str(), value)); } | | { return(lookupValue(path.c_str(), value)); } | |
| | | | |
|
| inline bool lookupValue(const std::string &path, std::string &value) | | inline bool lookupValue(const std::string &path, const char *&value) | |
| const throw() | | const throw() | |
| { return(lookupValue(path.c_str(), value)); } | | { return(lookupValue(path.c_str(), value)); } | |
| | | | |
|
| Setting & getRoot() const; | | inline bool lookupValue(const std::string &path, std::string &value) | |
| }; | | const throw() | |
| | | { return(lookupValue(path.c_str(), value)); } | |
| | | | |
| | | Setting & getRoot() const; | |
| | | | |
| | | private: | |
| | | | |
| | | void handleError() const; | |
| | | }; | |
| | | | |
| } // namespace libconfig | | } // namespace libconfig | |
| | | | |
| #endif // __libconfig_hpp | | #endif // __libconfig_hpp | |
| | | | |
End of changes. 113 change blocks. |
| 284 lines changed or deleted | | 310 lines changed or added | |
|