28 #ifndef app_appConfigurator_hpp
29 #define app_appConfigurator_hpp
34 #include "../mxError.hpp"
89 typedef std::unordered_map<std::string, configTarget>::iterator
targetIterator;
95 std::unordered_map<std::string, configTarget>
m_targets;
124 void add(
const std::string &n,
125 const std::string &so,
126 const std::string &lo,
128 const std::string & s,
129 const std::string & kw,
131 const std::string & ht =
"",
132 const std::string & he =
""
138 const std::string & oneTarget =
""
146 bool reportFileNotFound =
true
154 bool isSet(
const std::string & name,
155 std::unordered_map<std::string, configTarget> & targets
165 bool isSet(
const std::string & name );
171 int count(
const std::string & name,
172 std::unordered_map<std::string, configTarget> & targets
181 int count(
const std::string & name );
190 std::unordered_map<std::string, configTarget> & targets
201 int verbosity(
const std::string & name );
210 template<
typename typeT>
212 const std::string & name,
214 std::unordered_map<std::string, configTarget> & targets
226 template<
typename typeT>
228 const std::string & name,
241 template<
typename typeT>
243 const std::string & name,
244 std::unordered_map<std::string, configTarget> & targets
256 template<
typename typeT>
258 const std::string & name
269 template<
typename typeT>
270 int get( std::vector<typeT> & v,
271 const std::string & name,
273 std::unordered_map<std::string, configTarget> & targets
284 template<
typename typeT>
285 int get( std::vector<typeT> & v,
286 const std::string & name,
298 template<
typename typeT>
299 int get( std::vector<typeT> & v,
300 const std::string & name,
301 std::unordered_map<std::string, configTarget> & targets
312 template<
typename typeT>
313 int get( std::vector<typeT> & v,
314 const std::string & name
322 template<
typename typeT>
324 const std::string & name
332 template<
typename typeT>
334 const std::string & key
342 template<
typename typeT>
344 const std::string & section,
345 const std::string & keyword
368 const std::string & valueStr,
369 const std::string & source
376 template<
typename typeT>
378 const std::string & name,
380 std::unordered_map<std::string, configTarget> & targets
383 targets[name].used =
true;
385 if(!
isSet(name, targets))
395 if( targets[name].values.size() <= i)
return -1;
397 v = ioutils::convertFromString<typeT>(targets[name].values[i]);
416 int appConfigurator::get<char>(
char & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
419 int appConfigurator::get<char16_t>( char16_t & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
422 int appConfigurator::get<char32_t>( char32_t & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
425 int appConfigurator::get<wchar_t>(
wchar_t & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
428 int appConfigurator::get<signed char>(
signed char & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
431 int appConfigurator::get<short>(
short & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
434 int appConfigurator::get<int>(
int & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
437 int appConfigurator::get<long>(
long & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
440 int appConfigurator::get<long long>(
long long & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
443 int appConfigurator::get<unsigned char>(
unsigned char & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
446 int appConfigurator::get<unsigned short>(
unsigned short & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
449 int appConfigurator::get<unsigned int>(
unsigned int & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
452 int appConfigurator::get<unsigned long>(
unsigned long & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
455 int appConfigurator::get<unsigned long long>(
unsigned long long & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
458 int appConfigurator::get<float>(
float & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
461 int appConfigurator::get<double>(
double & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
464 int appConfigurator::get<long double>(
long double & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
468 int appConfigurator::get<__float128>( __float128 & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
472 int appConfigurator::get<bool>(
bool & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
475 int appConfigurator::get<std::string>( std::string & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
479 template<
typename typeT>
481 const std::string & name,
490 int appConfigurator::get<char>(
char & v,
const std::string & name,
size_t i);
493 int appConfigurator::get<char16_t>( char16_t & v,
const std::string & name,
size_t i);
496 int appConfigurator::get<char32_t>( char32_t & v,
const std::string & name,
size_t i);
499 int appConfigurator::get<wchar_t>(
wchar_t & v,
const std::string & name,
size_t i);
502 int appConfigurator::get<signed char>(
signed char & v,
const std::string & name,
size_t i);
505 int appConfigurator::get<short>(
short & v,
const std::string & name,
size_t i);
508 int appConfigurator::get<int>(
int & v,
const std::string & name,
size_t i);
511 int appConfigurator::get<long>(
long & v,
const std::string & name,
size_t i);
514 int appConfigurator::get<long long>(
long long & v,
const std::string & name,
size_t i);
517 int appConfigurator::get<unsigned char>(
unsigned char & v,
const std::string & name,
size_t i);
520 int appConfigurator::get<unsigned short>(
unsigned short & v,
const std::string & name,
size_t i);
523 int appConfigurator::get<unsigned int>(
unsigned int & v,
const std::string & name,
size_t i);
526 int appConfigurator::get<unsigned long>(
unsigned long & v,
const std::string & name,
size_t i);
529 int appConfigurator::get<unsigned long long>(
unsigned long long & v,
const std::string & name,
size_t i);
532 int appConfigurator::get<float>(
float & v,
const std::string & name,
size_t i);
535 int appConfigurator::get<double>(
double & v,
const std::string & name,
size_t i);
538 int appConfigurator::get<long double>(
long double & v,
const std::string & name,
size_t i);
542 int appConfigurator::get<__float128>( __float128 & v,
const std::string & name,
size_t i);
546 int appConfigurator::get<bool>(
bool & v,
const std::string & name,
size_t i);
549 int appConfigurator::get<std::string>( std::string & v,
const std::string & name,
size_t i);
553 template<
typename typeT>
555 const std::string & name,
556 std::unordered_map<std::string, configTarget> & targets
559 targets[name].used =
true;
561 if(!
isSet(name, targets))
571 int i = targets[name].values.size() - 1;
575 return get(v, name, i, targets);
580 int appConfigurator::get<char>(
char & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
583 int appConfigurator::get<char16_t>( char16_t & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
586 int appConfigurator::get<char32_t>( char32_t & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
589 int appConfigurator::get<wchar_t>(
wchar_t & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
592 int appConfigurator::get<signed char>(
signed char & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
595 int appConfigurator::get<short>(
short & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
598 int appConfigurator::get<int>(
int & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
601 int appConfigurator::get<long>(
long & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
604 int appConfigurator::get<long long>(
long long & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
607 int appConfigurator::get<unsigned char>(
unsigned char & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
610 int appConfigurator::get<unsigned short>(
unsigned short & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
613 int appConfigurator::get<unsigned int>(
unsigned int & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
616 int appConfigurator::get<unsigned long>(
unsigned long & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
619 int appConfigurator::get<unsigned long long>(
unsigned long long & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
622 int appConfigurator::get<float>(
float & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
625 int appConfigurator::get<double>(
double & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
628 int appConfigurator::get<long double>(
long double & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
632 int appConfigurator::get<__float128>( __float128 & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
636 int appConfigurator::get<bool>(
bool & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
639 int appConfigurator::get<std::string>( std::string & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
643 template<
typename typeT>
645 const std::string & name)
652 int appConfigurator::get<char>(
char & v,
const std::string & name);
655 int appConfigurator::get<char16_t>( char16_t & v,
const std::string & name);
658 int appConfigurator::get<char32_t>( char32_t & v,
const std::string & name);
661 int appConfigurator::get<wchar_t>(
wchar_t & v,
const std::string & name);
664 int appConfigurator::get<signed char>(
signed char & v,
const std::string & name);
667 int appConfigurator::get<short>(
short & v,
const std::string & name);
670 int appConfigurator::get<int>(
int & v,
const std::string & name);
673 int appConfigurator::get<long>(
long & v,
const std::string & name);
676 int appConfigurator::get<long long>(
long long & v,
const std::string & name);
679 int appConfigurator::get<unsigned char>(
unsigned char & v,
const std::string & name);
682 int appConfigurator::get<unsigned short>(
unsigned short & v,
const std::string & name);
685 int appConfigurator::get<unsigned int>(
unsigned int & v,
const std::string & name);
688 int appConfigurator::get<unsigned long>(
unsigned long & v,
const std::string & name);
691 int appConfigurator::get<unsigned long long>(
unsigned long long & v,
const std::string & name);
694 int appConfigurator::get<float>(
float & v,
const std::string & name);
697 int appConfigurator::get<double>(
double & v,
const std::string & name);
700 int appConfigurator::get<long double>(
long double & v,
const std::string & name);
704 int appConfigurator::get<__float128>( __float128 & v,
const std::string & name);
708 int appConfigurator::get<bool>(
bool & v,
const std::string & name);
711 int appConfigurator::get<std::string>( std::string & v,
const std::string & name);
714 template<
typename typeT>
716 const std::string & name,
718 std::unordered_map<std::string, configTarget> & targets
721 targets[name].used =
true;
723 if(!
isSet(name, targets))
733 if( targets[name].values.size() <= i)
return -1;
738 s = ioutils::convertFromString<std::string>(targets[name].values[i]);
766 while(::isspace(s[st]) && st < s.size()-1) ++st;
768 com = s.find(
',', st);
772 while(com != std::string::npos)
774 v.push_back( ioutils::convertFromString<typeT>(s.substr(st, com-st)) );
776 while(::isspace(s[st]) && st < s.size()-1) ++st;
778 com = s.find(
',', st);
780 v.push_back( ioutils::convertFromString<typeT>(s.substr(st, s.size()-st)));
800 int appConfigurator::get<char>( std::vector<char> & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
803 int appConfigurator::get<char16_t>( std::vector<char16_t> & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
806 int appConfigurator::get<char32_t>( std::vector<char32_t> & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
809 int appConfigurator::get<wchar_t>( std::vector<wchar_t> & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
812 int appConfigurator::get<signed char>( std::vector<signed char> & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
815 int appConfigurator::get<short>( std::vector<short> & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
818 int appConfigurator::get<int>( std::vector<int> & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
821 int appConfigurator::get<long>( std::vector<long> & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
824 int appConfigurator::get<long long>( std::vector<long long> & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
827 int appConfigurator::get<unsigned char>( std::vector<unsigned char> & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
830 int appConfigurator::get<unsigned short>( std::vector<unsigned short> & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
833 int appConfigurator::get<unsigned int>( std::vector<unsigned int> & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
836 int appConfigurator::get<unsigned long>( std::vector<unsigned long> & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
839 int appConfigurator::get<unsigned long long>( std::vector<unsigned long long> & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
842 int appConfigurator::get<float>( std::vector<float> & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
845 int appConfigurator::get<double>( std::vector<double> & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
848 int appConfigurator::get<long double>( std::vector<long double> & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
852 int appConfigurator::get<__float128>( std::vector<__float128> & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
856 int appConfigurator::get<bool>( std::vector<bool> & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
859 int appConfigurator::get<std::string>( std::vector<std::string> & v,
const std::string & name,
size_t i, std::unordered_map<std::string, configTarget> & targets);
863 template<
typename typeT>
865 const std::string & name,
875 int appConfigurator::get<char>( std::vector<char> & v,
const std::string & name,
size_t i);
878 int appConfigurator::get<char16_t>( std::vector<char16_t> & v,
const std::string & name,
size_t i);
881 int appConfigurator::get<char32_t>( std::vector<char32_t> & v,
const std::string & name,
size_t i);
884 int appConfigurator::get<wchar_t>( std::vector<wchar_t> & v,
const std::string & name,
size_t i);
887 int appConfigurator::get<signed char>( std::vector<signed char> & v,
const std::string & name,
size_t i);
890 int appConfigurator::get<short>( std::vector<short> & v,
const std::string & name,
size_t i);
893 int appConfigurator::get<int>( std::vector<int> & v,
const std::string & name,
size_t i);
896 int appConfigurator::get<long>( std::vector<long> & v,
const std::string & name,
size_t i);
899 int appConfigurator::get<long long>( std::vector<long long> & v,
const std::string & name,
size_t i);
902 int appConfigurator::get<unsigned char>( std::vector<unsigned char> & v,
const std::string & name,
size_t i);
905 int appConfigurator::get<unsigned short>( std::vector<unsigned short> & v,
const std::string & name,
size_t i);
908 int appConfigurator::get<unsigned int>( std::vector<unsigned int> & v,
const std::string & name,
size_t i);
911 int appConfigurator::get<unsigned long>( std::vector<unsigned long> & v,
const std::string & name,
size_t i);
914 int appConfigurator::get<unsigned long long>( std::vector<unsigned long long> & v,
const std::string & name,
size_t i);
917 int appConfigurator::get<float>( std::vector<float> & v,
const std::string & name,
size_t i);
920 int appConfigurator::get<double>( std::vector<double> & v,
const std::string & name,
size_t i);
923 int appConfigurator::get<long double>( std::vector<long double> & v,
const std::string & name,
size_t i);
927 int appConfigurator::get<__float128>( std::vector<__float128> & v,
const std::string & name,
size_t i);
931 int appConfigurator::get<bool>( std::vector<bool> & v,
const std::string & name,
size_t i);
934 int appConfigurator::get<std::string>( std::vector<std::string> & v,
const std::string & name,
size_t i);
937 template<
typename typeT>
939 const std::string & name,
940 std::unordered_map<std::string, configTarget> & targets
943 targets[name].used =
true;
945 if(!
isSet(name, targets))
953 int i = targets[name].values.size() - 1;
957 return get(v, name, i, targets);
962 int appConfigurator::get<char>( std::vector<char> & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
965 int appConfigurator::get<char16_t>( std::vector<char16_t> & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
968 int appConfigurator::get<char32_t>( std::vector<char32_t> & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
971 int appConfigurator::get<wchar_t>( std::vector<wchar_t> & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
974 int appConfigurator::get<signed char>( std::vector<signed char> & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
977 int appConfigurator::get<short>( std::vector<short> & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
980 int appConfigurator::get<int>( std::vector<int> & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
983 int appConfigurator::get<long>( std::vector<long> & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
986 int appConfigurator::get<long long>( std::vector<long long> & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
989 int appConfigurator::get<unsigned char>( std::vector<unsigned char> & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
992 int appConfigurator::get<unsigned short>( std::vector<unsigned short> & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
995 int appConfigurator::get<unsigned int>( std::vector<unsigned int> & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
998 int appConfigurator::get<unsigned long>( std::vector<unsigned long> & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
1001 int appConfigurator::get<unsigned long long>( std::vector<unsigned long long> & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
1004 int appConfigurator::get<float>( std::vector<float> & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
1007 int appConfigurator::get<double>( std::vector<double> & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
1010 int appConfigurator::get<long double>( std::vector<long double> & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
1014 int appConfigurator::get<__float128>( std::vector<__float128> & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
1018 int appConfigurator::get<bool>( std::vector<bool> & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
1021 int appConfigurator::get<std::string>( std::vector<std::string> & v,
const std::string & name, std::unordered_map<std::string, configTarget> & targets);
1025 template<
typename typeT>
1027 const std::string & name
1035 int appConfigurator::get<char>( std::vector<char> & v,
const std::string & name);
1038 int appConfigurator::get<char16_t>( std::vector<char16_t> & v,
const std::string & name);
1041 int appConfigurator::get<char32_t>( std::vector<char32_t> & v,
const std::string & name);
1044 int appConfigurator::get<wchar_t>( std::vector<wchar_t> & v,
const std::string & name);
1047 int appConfigurator::get<signed char>( std::vector<signed char> & v,
const std::string & name);
1050 int appConfigurator::get<short>( std::vector<short> & v,
const std::string & name);
1053 int appConfigurator::get<int>( std::vector<int> & v,
const std::string & name);
1056 int appConfigurator::get<long>( std::vector<long> & v,
const std::string & name);
1059 int appConfigurator::get<long long>( std::vector<long long> & v,
const std::string & name);
1062 int appConfigurator::get<unsigned char>( std::vector<unsigned char> & v,
const std::string & name);
1065 int appConfigurator::get<unsigned short>( std::vector<unsigned short> & v,
const std::string & name);
1068 int appConfigurator::get<unsigned int>( std::vector<unsigned int> & v,
const std::string & name);
1071 int appConfigurator::get<unsigned long>( std::vector<unsigned long> & v,
const std::string & name);
1074 int appConfigurator::get<unsigned long long>( std::vector<unsigned long long> & v,
const std::string & name);
1077 int appConfigurator::get<float>( std::vector<float> & v,
const std::string & name);
1080 int appConfigurator::get<double>( std::vector<double> & v,
const std::string & name);
1083 int appConfigurator::get<long double>( std::vector<long double> & v,
const std::string & name);
1087 int appConfigurator::get<__float128>( std::vector<__float128> & v,
const std::string & name);
1091 int appConfigurator::get<bool>( std::vector<bool> & v,
const std::string & name);
1094 int appConfigurator::get<std::string>( std::vector<std::string> & v,
const std::string & name);
1098 template<
typename typeT>
1100 const std::string & name
1109 int appConfigurator::operator()<
char>(
char & v,
const std::string & name);
1112 int appConfigurator::operator()<char16_t>( char16_t & v,
const std::string & name);
1115 int appConfigurator::operator()<char32_t>( char32_t & v,
const std::string & name);
1118 int appConfigurator::operator()<
wchar_t>(
wchar_t & v,
const std::string & name);
1121 int appConfigurator::operator()<
signed char>(
signed char & v,
const std::string & name);
1124 int appConfigurator::operator()<
short>(
short & v,
const std::string & name);
1127 int appConfigurator::operator()<
int>(
int & v,
const std::string & name);
1130 int appConfigurator::operator()<
long>(
long & v,
const std::string & name);
1133 int appConfigurator::operator()<
long long>(
long long & v,
const std::string & name);
1136 int appConfigurator::operator()<
unsigned char>(
unsigned char & v,
const std::string & name);
1139 int appConfigurator::operator()<
unsigned short>(
unsigned short & v,
const std::string & name);
1142 int appConfigurator::operator()<
unsigned int>(
unsigned int & v,
const std::string & name);
1145 int appConfigurator::operator()<
unsigned long>(
unsigned long & v,
const std::string & name);
1148 int appConfigurator::operator()<
unsigned long long>(
unsigned long long & v,
const std::string & name);
1151 int appConfigurator::operator()<
float>(
float & v,
const std::string & name);
1154 int appConfigurator::operator()<
double>(
double & v,
const std::string & name);
1157 int appConfigurator::operator()<
long double>(
long double & v,
const std::string & name);
1161 int appConfigurator::operator()<__float128>( __float128 & v,
const std::string & name);
1165 int appConfigurator::operator()<
bool>(
bool & v,
const std::string & name);
1168 int appConfigurator::operator()<std::string>( std::string & v,
const std::string & name);
1172 template<
typename typeT>
1174 const std::string & key
1181 int appConfigurator::configUnused<char>(
char & v,
const std::string & key);
1184 int appConfigurator::configUnused<char16_t>( char16_t & v,
const std::string & key);
1187 int appConfigurator::configUnused<char32_t>( char32_t & v,
const std::string & key);
1190 int appConfigurator::configUnused<wchar_t>(
wchar_t & v,
const std::string & key);
1193 int appConfigurator::configUnused<signed char>(
signed char & v,
const std::string & key);
1196 int appConfigurator::configUnused<short>(
short & v,
const std::string & key);
1199 int appConfigurator::configUnused<int>(
int & v,
const std::string & key);
1202 int appConfigurator::configUnused<long>(
long & v,
const std::string & key);
1205 int appConfigurator::configUnused<long long>(
long long & v,
const std::string & key);
1208 int appConfigurator::configUnused<unsigned char>(
unsigned char & v,
const std::string & key);
1211 int appConfigurator::configUnused<unsigned short>(
unsigned short & v,
const std::string & key);
1214 int appConfigurator::configUnused<unsigned int>(
unsigned int & v,
const std::string & key);
1217 int appConfigurator::configUnused<unsigned long>(
unsigned long & v,
const std::string & key);
1220 int appConfigurator::configUnused<unsigned long long>(
unsigned long long & v,
const std::string & key);
1223 int appConfigurator::configUnused<float>(
float & v,
const std::string & key);
1226 int appConfigurator::configUnused<double>(
double & v,
const std::string & key);
1229 int appConfigurator::configUnused<long double>(
long double & v,
const std::string & key);
1233 int appConfigurator::configUnused<__float128>( __float128 & v,
const std::string & key);
1237 int appConfigurator::configUnused<bool>(
bool & v,
const std::string & key);
1240 int appConfigurator::configUnused<std::string>( std::string & v,
const std::string & key);
1243 template<
typename typeT>
1245 const std::string & section,
1246 const std::string & keyword
1253 int appConfigurator::configUnused<char>(
char & v,
const std::string & section,
const std::string & keyword);
1256 int appConfigurator::configUnused<char16_t>( char16_t & v,
const std::string & section,
const std::string & keyword);
1259 int appConfigurator::configUnused<char32_t>( char32_t & v,
const std::string & section,
const std::string & keyword);
1262 int appConfigurator::configUnused<wchar_t>(
wchar_t & v,
const std::string & section,
const std::string & keyword);
1265 int appConfigurator::configUnused<signed char>(
signed char & v,
const std::string & section,
const std::string & keyword);
1268 int appConfigurator::configUnused<short>(
short & v,
const std::string & section,
const std::string & keyword);
1271 int appConfigurator::configUnused<int>(
int & v,
const std::string & section,
const std::string & keyword);
1274 int appConfigurator::configUnused<long>(
long & v,
const std::string & section,
const std::string & keyword);
1277 int appConfigurator::configUnused<long long>(
long long & v,
const std::string & section,
const std::string & keyword);
1280 int appConfigurator::configUnused<unsigned char>(
unsigned char & v,
const std::string & section,
const std::string & keyword);
1283 int appConfigurator::configUnused<unsigned short>(
unsigned short & v,
const std::string & section,
const std::string & keyword);
1286 int appConfigurator::configUnused<unsigned int>(
unsigned int & v,
const std::string & section,
const std::string & keyword);
1289 int appConfigurator::configUnused<unsigned long>(
unsigned long & v,
const std::string & section,
const std::string & keyword);
1292 int appConfigurator::configUnused<unsigned long long>(
unsigned long long & v,
const std::string & section,
const std::string & keyword);
1295 int appConfigurator::configUnused<float>(
float & v,
const std::string & section,
const std::string & keyword);
1298 int appConfigurator::configUnused<double>(
double & v,
const std::string & section,
const std::string & keyword);
1301 int appConfigurator::configUnused<long double>(
long double & v,
const std::string & section,
const std::string & keyword);
1305 int appConfigurator::configUnused<__float128>( __float128 & v,
const std::string & section,
const std::string & keyword);
1309 int appConfigurator::configUnused<bool>(
bool & v,
const std::string & section,
const std::string & keyword);
1312 int appConfigurator::configUnused<std::string>( std::string & v,
const std::string & section,
const std::string & keyword);
1345 const std::vector<std::string> & sections,
1346 const std::vector<std::string> & keywords,
1347 const std::vector<std::string> & values
void writeConfigFile(const std::string &fname, const std::vector< std::string > §ions, const std::vector< std::string > &keywords, const std::vector< std::string > &values)
A simple config file writing function, useful for testing.
Targets for the configuration manager, and utiltities.
std::string convertToString(const typeT &value, int precision=0)
Convert a numerical value to a string.
Declares and defines an ini-style (toml) file parser.
Class to manage a set of configurable values, and read their values from config/ini files and the com...
std::unordered_map< std::string, configTarget > m_targets
The targets are stored in an unordered_map for fast access by key.
int readConfig(const std::string &fname, bool reportFileNotFound=true)
Read and parse a config/ini file, updating the targets.
int operator()(typeT &v, const std::string &name)
Access operator, configures a value by calling get.
void add(const configTarget &tgt)
Add a configTarget.
bool m_sources
Flag controlling whether or not to record config sources.
int get(typeT &v, const std::string &name, size_t i, std::unordered_map< std::string, configTarget > &targets)
Get the i-th value of the target, converted to the specified type.
std::vector< std::string > nonOptions
Non-option arguments from the command line.
int configUnused(typeT &v, const std::string &key)
Configure a value from the unused map, using the iniFile key.
void(* configLog)(const std::string &name, const int &code, const std::string &valueStr, const std::string &source)
Call an external logging function whenever a config value is accessed by get or operator().
int verbosity(const std::string &name, std::unordered_map< std::string, configTarget > &targets)
Get the command line verbosity count for this option.
int isSetUnused(const std::string &name)
Check if a target has been set in the unused configuration.
bool isSet(const std::string &name, std::unordered_map< std::string, configTarget > &targets)
Check if a target has been set by the configuration.
void clear()
Clear the containers and free up the associated memory.
int unusedSections(std::vector< std::string > §ions)
Get the unique sections in the unused config targets.
int numUnknownOptions()
Get the number of unknown options found during config processing.
std::list< configTarget > clOnlyTargets
Targets which are only for the command line are stored separately in a list.
int count(const std::string &name, std::unordered_map< std::string, configTarget > &targets)
Get the number of different values set for the specified config target.
void parseCommandLine(int argc, char **argv, const std::string &oneTarget="")
Parse the command line, updating the targets.
std::unordered_map< std::string, configTarget >::iterator targetIterator
Iterator for the targets unordered_map.
int nAdded
Running count of options added, used to track order.
std::unordered_map< std::string, configTarget > m_unusedConfigs
Config file entries present in the file(s), but not corresponding to a target when parsed....
std::list< configTarget >::iterator clOnlyTargetIterator
Iterator for the clOnlyTargets list.
static std::string makeKey(const std::string §ion, const std::string &name)
Return a key generated from the section and name.