33 #ifndef _IDENTT_UTILS_CFGFILEOPTIONS_HPP_ 34 #define _IDENTT_UTILS_CFGFILEOPTIONS_HPP_ 38 #include <boost/utility/value_init.hpp> 39 #include <boost/lexical_cast.hpp> 40 #include <boost/numeric/conversion/cast.hpp> 49 using pointer=std::shared_ptr<CfgFileOptions>;
50 using ssPairT=std::pair<std::string,std::string>;
51 using ssMapT=std::map<std::string,std::string>;
52 using sListT=std::list<std::string>;
61 static pointer
create(
const std::string InputFile)
81 bool Check(
const std::string Section,
const std::string Name);
99 T
Find(
const std::string Section,
const std::string Name,
bool NoThrow=
false)
101 auto it = SectionMap.find(
MakeKey(Section,Name));
102 if (it != SectionMap.end()) {
103 return ConvertAnyToAny<T>(it->second,NoThrow);
107 auto jt = InheritMap.find(Section);
108 while ( jt !=InheritMap.end()) {
109 it = SectionMap.find(
MakeKey(jt->second,Name));
110 if (it != SectionMap.end()) {
111 return ConvertAnyToAny<T>(it->second,NoThrow);
115 jt = InheritMap.find(jt->second);
138 T
FindList(
const std::string Section,
const sListT NameList,
bool NoThrow=
false)
141 for(
auto name : NameList) {
142 ValueList.push_back( this->Find<T::value_type>(Section,name,NoThrow));
168 void Update(
const std::string Section,
const std::string Name, std::string
Value);
182 std::string
MakeKey(std::string Section, std::string Name);
215 inline T ConvertAnyToAny(std::string InData,
bool NoThrow=
false)
220 OutData=boost::lexical_cast<T>(InData);
222 }
catch(std::exception& e) {
bool Check(const std::string Section, const std::string Name)
Check : Check if Value Exists.
Definition: CfgFileOptions.cc:60
T Find(const std::string Section, const std::string Name, bool NoThrow=false)
Find: Find an entry.
Definition: CfgFileOptions.hpp:99
Represents a JSON value. Use Value for UTF8 encoding and default allocator.
Definition: document.h:67
Definition: BaseUtils.hpp:80
void Show()
Show: Show all entries.
Definition: CfgFileOptions.cc:75
T FindList(const std::string Section, const sListT NameList, bool NoThrow=false)
FindList: Find several entries.
Definition: CfgFileOptions.hpp:138
Definition: CryptoBase.hpp:49
void Update(const std::string Section, const std::string Name, std::string Value)
Update: Update or Add an entry.
Definition: CfgFileOptions.cc:86
std::string MakeKey(std::string Section, std::string Name)
MakeKey: Merge Section and Name.
Definition: CfgFileOptions.cc:95
static pointer create(const std::string InputFile)
create
Definition: CfgFileOptions.hpp:61
Definition: CfgFileOptions.hpp:47