Skip to content

Commit 5909817

Browse files
committed
Added generic config settings implementation.
1 parent 6faca11 commit 5909817

File tree

7 files changed

+628
-4
lines changed

7 files changed

+628
-4
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
Copyright (C) 2017 Statoil ASA, Norway.
3+
4+
The file 'config_settings.c' is part of ERT - Ensemble based Reservoir Tool.
5+
6+
ERT is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation, either version 3 of the License, or
9+
(at your option) any later version.
10+
11+
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
12+
WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
FITNESS FOR A PARTICULAR PURPOSE.
14+
15+
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
16+
for more details.
17+
*/
18+
19+
#ifndef ERT_CONFIG_SETTINGS_H
20+
#define ERT_CONFIG_SETTINGS_H
21+
22+
#ifdef __cplusplus
23+
extern "C" {
24+
#endif
25+
#include <stdbool.h>
26+
27+
#include <ert/util/stringlist.h>
28+
29+
#include <ert/config/config_parser.h>
30+
#include <ert/config/config_content.h>
31+
#include <ert/config/config_schema_item.h>
32+
33+
typedef struct config_settings_struct config_settings_type;
34+
35+
config_settings_type * config_settings_alloc( const char * root_key );
36+
void config_settings_free( config_settings_type * settings);
37+
bool config_settings_has_key( const config_settings_type * settings , const char * key);
38+
config_item_types config_settings_get_value_type( const config_settings_type * config_settings , const char * key);
39+
bool config_settings_set_value( const config_settings_type * config_settings , const char * key, const char * value);
40+
void config_settings_init_parser( const config_settings_type * config_settings, config_parser_type * config , bool required);
41+
void config_settings_init_parser__( const char * root_key , config_parser_type * config , bool required);
42+
void config_settings_apply(config_settings_type * config_settings , const config_content_type * config );
43+
stringlist_type * config_settings_alloc_keys( const config_settings_type * config_settings );
44+
45+
bool config_settings_add_setting(config_settings_type * settings , const char* key, config_item_types value_type , const char* initial_value);
46+
void config_settings_add_int_setting(config_settings_type * settings , const char* key, int initial_value);
47+
void config_settings_add_double_setting(config_settings_type * settings , const char* key, double initial_value);
48+
void config_settings_add_string_setting(config_settings_type * settings , const char* key, const char * initial_value);
49+
void config_settings_add_bool_setting(config_settings_type * settings , const char* key, bool initial_value);
50+
51+
52+
const char * config_settings_get_value( const config_settings_type * config_settings , const char * key);
53+
const char * config_settings_get_string_value( const config_settings_type * config_settings , const char * key);
54+
int config_settings_get_int_value( const config_settings_type * config_settings , const char * key);
55+
bool config_settings_get_bool_value( const config_settings_type * config_settings , const char * key);
56+
double config_settings_get_double_value( const config_settings_type * config_settings , const char * key);
57+
58+
bool config_settings_set_value( const config_settings_type * config_settings , const char * key, const char * value);
59+
bool config_settings_set_int_value( const config_settings_type * config_settings , const char * key, int value);
60+
bool config_settings_set_double_value( const config_settings_type * config_settings , const char * key, double value);
61+
bool config_settings_set_bool_value( const config_settings_type * config_settings , const char * key, bool value);
62+
bool config_settings_set_string_value( const config_settings_type * config_settings , const char * key, const char * value);
63+
64+
#ifdef __cplusplus
65+
}
66+
#endif
67+
#endif

libconfig/src/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
set( source_files config_parser.c config_content.c config_error.c config_schema_item.c config_content_item.c config_content_node.c config_root_path.c config_path_elm.c conf.c conf_util.c conf_data.c)
2-
set( header_files config_parser.h config_content.h config_error.h config_schema_item.h config_content_item.h config_content_node.h config_root_path.h config_path_elm.h conf.h conf_data.h)
1+
set( source_files config_parser.c config_content.c config_error.c config_schema_item.c config_content_item.c config_content_node.c config_root_path.c config_path_elm.c conf.c conf_util.c conf_data.c config_settings.c)
2+
set( header_files config_parser.h config_content.h config_error.h config_schema_item.h config_content_item.h config_content_node.h config_root_path.h config_path_elm.h conf.h conf_data.h config_settings.h)
33

44
add_library( config ${LIBRARY_TYPE} ${source_files} )
55
set_target_properties( config PROPERTIES VERSION ${ERT_VERSION_MAJOR}.${ERT_VERSION_MINOR} SOVERSION ${ERT_VERSION_MAJOR} )

0 commit comments

Comments
 (0)