11 inline bool to(
const std::string& a_string,
bool& a_value,
bool a_def =
false){
13 ||(a_string==
"true")||(a_string==
"TRUE")||(a_string==
"True")
14 ||(a_string==
"yes")||(a_string==
"YES")||(a_string==
"Yes")
15 ||(a_string==
"on")||(a_string==
"ON")||(a_string==
"On")
19 }
else if((a_string==
"0")
20 ||(a_string==
"false")||(a_string==
"FALSE")||(a_string==
"False")
21 ||(a_string==
"no")||(a_string==
"NO")||(a_string==
"No")
22 ||(a_string==
"off")||(a_string==
"OFF")||(a_string==
"Off")
32 inline bool tob(
const std::string& a_string,
bool& a_value,
bool a_def =
false) {
return to(a_string,a_value,a_def);}
41 inline bool to(
const std::string& a_s,T& a_v,
const T& a_def = T()) {
42 if(a_s.empty()) {a_v = a_def;
return false;}
43 std::istringstream strm(a_s.c_str());
45 if(strm.fail()) {a_v = a_def;
return false;}
50 inline bool to(T& a_field,
const std::string& a_s,
bool& a_changed){
53 if(!
to(a_s,a_field)) {a_field = old;a_changed=
false;
return false;}
54 a_changed = a_field==old?
false:
true;
65 inline bool to(std::ostream& a_out,
const std::string& a_string,T& a_value){
66 if(!to<T>(a_string,a_value)) {
67 a_out <<
"Passed value \"" << a_string <<
"\""
75 inline bool to(std::ostream& a_out,
const std::string& a_string,
bool& a_value){
76 if(!
to(a_string,a_value)) {
77 a_out <<
"Passed value \"" << a_string <<
"\""
78 <<
" is not a boolean."
92 inline bool to_size_t(
const std::string& a_string,
size_t& a_value,
const size_t& a_def = 0){
93 if(
sizeof(
size_t)==8) {
95 bool status = to<uint64>(a_string,v,a_def);
100 bool status = to<uint32>(a_string,v,(
uint32)a_def);