22 #include "eclipseclp_config.h"
25 #include <eclipseclass.h>
40 EclExternalConfig::EclExternalConfig()
42 if (m_instance == NULL) {
52 if (m_instance == NULL) {
85 throw Exception(
"No instance of type EclExternalConfig instantiated");
98 throw Exception(
"No instance of type Configuration instantiated");
116 if (EC_succeed != EC_arg(1).is_string(&path)) {
117 fprintf(stderr,
"p_get_config_value(): no path given\n");
123 std::vector<bool> vec = config->
get_bools(path);
125 for (std::vector<bool>::reverse_iterator it = vec.rbegin(); it != vec.rend(); ++it)
126 res = list(EC_word(*it), res);
127 if (EC_succeed != EC_arg(2).unify(res)) {
128 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
132 }
else if (config->
get_bool(path)) {
133 if (EC_succeed != EC_arg(2).unify(EC_atom((
char *)
"true"))) {
134 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
139 if (EC_succeed != EC_arg(2).unify(EC_atom((
char *)
"false"))) {
140 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
145 }
else if (config->
is_int(path)) {
147 std::vector<int> vec = config->
get_ints(path);
149 for (std::vector<int>::reverse_iterator it = vec.rbegin(); it != vec.rend(); ++it)
150 res = list(EC_word((
long)*it), res);
151 if (EC_succeed != EC_arg(2).unify(res)) {
152 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
156 }
else if (EC_succeed != EC_arg(2).unify(EC_word((
long)config->
get_int(path)))) {
157 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
161 }
else if (config->
is_uint(path)) {
163 std::vector<unsigned int> vec = config->
get_uints(path);
165 for (std::vector<unsigned int>::reverse_iterator it = vec.rend(); it != vec.rbegin(); --it)
166 res = list(EC_word((
long)*it), res);
167 if (EC_succeed != EC_arg(2).unify(res)) {
168 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
172 }
else if (EC_succeed != EC_arg(2).unify(EC_word((
long)config->
get_uint(path)))) {
173 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
181 std::vector<float> vec = config->
get_floats(path);
183 for (std::vector<float>::reverse_iterator it = vec.rbegin(); it != vec.rend(); ++it)
184 res = list(EC_word((
double)*it), res);
185 if (EC_succeed != EC_arg(2).unify(res)) {
186 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
191 if (EC_succeed != EC_arg(2).unify(EC_word((
double)config->
get_float(path)))) {
192 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
198 std::vector<std::string> vec = config->
get_strings(path);
200 for (std::vector<std::string>::reverse_iterator it = vec.rbegin(); it != vec.rend(); ++it)
201 res = list(EC_word((*it).c_str()), res);
202 if (EC_succeed != EC_arg(2).unify(res)) {
203 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
207 }
else if (EC_succeed != EC_arg(2).unify(EC_word(config->
get_string(path).c_str()))) {
208 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
214 "p_get_config_value(): could not find type of config value! Type: %s\n",