11#include < iostream>
2- #include < vector>
32#include < string>
3+ #include < typeinfo>
4+ #include < boost/core/demangle.hpp>
5+
46#include " ini/INIReader.h"
57using namespace inih ;
68
9+ namespace bc = boost::core;
10+
711int main () {
812 INIReader r{" ./test/fixtures/config.ini" };
913
10- const std::string v = r.Get <std::string>(" section1" , " any" );
11- const auto & v1 = r.Get <int >(" section1" , " any" );
12- const auto & v2 = r.Get <double >(" section1" , " any" );
14+ const auto & v1 = r.Get <std::string>(" section1" , " any" );
15+ const auto & v2 = r.Get <int >(" section1" , " any" );
16+ const auto & v3 = r.Get <double >(" section1" , " any" );
17+ const auto & v4 = r.GetVector <float >(" section2" , " any_vec" );
18+ const auto & v5{r.GetVector <std::string>(" section2" , " any_vec" )};
19+
20+ /* * output
21+ * v1 = "1" type: std::string
22+ * v2 = 1 type: int
23+ * v3 = 1.0 type: double
24+ * v4 = [1, 2, 3] type: std::vector<float>
25+ * v5 = ["1", "2", "3"] type: std::vector<std::string>
26+ */
1327
14- const std::vector<float > v3{r.GetVector <float >(" section2" , " any_vec" )};
15- const std::vector<std::string> v4{r.GetVector <std::string>(" section2" , " any_vec" )};
28+ std::cout << " v1 = " << v1 << " , which is type: " << bc::demangle (typeid (v1).name ()) << std::endl;
29+ std::cout << " v2 = " << v2 << " , which is type: " << bc::demangle (typeid (v2).name ()) << std::endl;
30+ std::cout << " v3 = " << v3 << " , which is type: " << bc::demangle (typeid (v3).name ()) << std::endl;
31+ std::cout << " v4 = " ; for (auto & v : v4) std::cout << v << " " ; std::cout << " , which is type: " << bc::demangle (typeid (v4).name ()) << std::endl;
32+ std::cout << " v5 = " ; for (auto & v : v5) std::cout << v << " " ; std::cout << " , which is type: " << bc::demangle (typeid (v5).name ()) << std::endl;
1633
1734 return 0 ;
1835}
0 commit comments