]> oss.titaniummirror.com Git - repo_shell.git/blobdiff - inih/cpp/INIReaderTest.cpp
Add support for /etc/repo_shell.cfg
[repo_shell.git] / inih / cpp / INIReaderTest.cpp
diff --git a/inih/cpp/INIReaderTest.cpp b/inih/cpp/INIReaderTest.cpp
new file mode 100644 (file)
index 0000000..abbf219
--- /dev/null
@@ -0,0 +1,20 @@
+// Example that shows simple usage of the INIReader class
+
+#include <iostream>
+#include "INIReader.h"
+
+int main()
+{
+    INIReader reader("../examples/test.ini");
+
+    if (reader.ParseError() < 0) {
+        std::cout << "Can't load 'test.ini'\n";
+        return 1;
+    }
+    std::cout << "Config loaded from 'test.ini': version="
+              << reader.GetInteger("protocol", "version", -1) << ", name="
+              << reader.Get("user", "name", "UNKNOWN") << ", email="
+              << reader.Get("user", "email", "UNKNOWN") << ", active="
+              << reader.GetBoolean("user", "active", true) << "\n";
+    return 0;
+}