16
16
17
17
#define TEST_LOGIC
18
18
#ifdef TEST_LOGIC
19
- #define LOG_TEELN (FMT, ...) printf(FMT, __VA_ARGS__)
19
+ #define LOG_TEELN (FMT, ...) printf(FMT" \n " , __VA_ARGS__)
20
20
#else
21
21
#include " log.h"
22
22
#endif
@@ -50,13 +50,13 @@ std::string str_trim(std::string sin) {
50
50
return sin;
51
51
}
52
52
53
- bool sc_load (std::string &fname) {
53
+ void sc_load (std::string &fname) {
54
54
std::ifstream f {fname};
55
55
if (!f) {
56
- LOG_TEELN (" ERRR:%s:%s:failed to load..." , __func__, fname);
56
+ LOG_TEELN (" ERRR:%s:%s:failed to load..." , __func__, fname. c_str () );
57
57
throw std::runtime_error { " ERRR:SimpCfg:File not found" };
58
58
} else {
59
- LOG_TEELN (" DBUG:%s:%s" , __func__, fname);
59
+ LOG_TEELN (" DBUG:%s:%s" , __func__, fname. c_str () );
60
60
}
61
61
std::string group;
62
62
int iLine = 0 ;
@@ -74,24 +74,24 @@ bool sc_load(std::string &fname) {
74
74
curL = str_trim (curL);
75
75
if (bGroup) {
76
76
group = curL;
77
- LOG_TEELN (" DBUG:%s:%s:%s:%s " , __func__, group);
77
+ LOG_TEELN (" DBUG:%s:%s" , __func__, group. c_str () );
78
78
continue ;
79
79
}
80
80
auto dPos = curL.find (' :' );
81
81
if (dPos == std::string::npos) {
82
- LOG_TEELN (" ERRR:%s:%d:invalid key value line:%s" , __func__, iLine, curL);
82
+ LOG_TEELN (" ERRR:%s:%d:invalid key value line:%s" , __func__, iLine, curL. c_str () );
83
83
throw std::runtime_error { " ERRR:SimpCfg:Invalid key value line" };
84
84
}
85
85
auto dEnd = curL.length () - dPos;
86
86
if ((dPos == 0 ) || (dEnd < 2 )) {
87
- LOG_TEELN (" ERRR:%s:%d:invalid key value line:%s" , __func__, iLine, curL);
87
+ LOG_TEELN (" ERRR:%s:%d:invalid key value line:%s" , __func__, iLine, curL. c_str () );
88
88
throw std::runtime_error { " ERRR:SimpCfg:Invalid key value line" };
89
89
}
90
90
std::string key = curL.substr (0 , dPos);
91
91
key = str_trim (key);
92
92
std::string value = curL.substr (dPos+1 );
93
93
value = str_trim (value);
94
- LOG_TEELN (" DBUG:%s:%s:%s:%s" , __func__, group, key, value);
94
+ LOG_TEELN (" DBUG:%s:%s:%s:%s" , __func__, group. c_str () , key. c_str () , value. c_str () );
95
95
sc_set_string (group, key, value);
96
96
}
97
97
}
0 commit comments