2009-08-20 23:32:33 +00:00
|
|
|
// Example that shows simple usage of the INIReader class
|
2009-08-20 21:59:32 +00:00
|
|
|
|
|
|
|
#include <iostream>
|
2016-09-15 13:23:49 -04:00
|
|
|
#include "../cpp/INIReader.h"
|
2009-08-20 21:59:32 +00:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
INIReader reader("../examples/test.ini");
|
|
|
|
|
|
|
|
if (reader.ParseError() < 0) {
|
2009-08-20 23:32:33 +00:00
|
|
|
std::cout << "Can't load 'test.ini'\n";
|
2009-08-20 21:59:32 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2009-08-20 23:32:33 +00:00
|
|
|
std::cout << "Config loaded from 'test.ini': version="
|
|
|
|
<< reader.GetInteger("protocol", "version", -1) << ", name="
|
|
|
|
<< reader.Get("user", "name", "UNKNOWN") << ", email="
|
2013-08-14 21:58:41 +00:00
|
|
|
<< reader.Get("user", "email", "UNKNOWN") << ", pi="
|
|
|
|
<< reader.GetReal("user", "pi", -1) << ", active="
|
2011-06-24 18:23:13 +00:00
|
|
|
<< reader.GetBoolean("user", "active", true) << "\n";
|
2009-08-20 21:59:32 +00:00
|
|
|
return 0;
|
|
|
|
}
|