//  // //  ### ##### # # -= Confix Library =-  // // # # # ## ## Demo.cpp - Confix demonstration application  // // # #### ###  // // # # ### Representation of a configuration file variable  // // # # # ## ##  // //  ### # # # R1 (C)2002 Markus Ewald -> License.txt  // //  // #include #include "Confix/Confix.h" using namespace std; using namespace Confix; // ####################################################################### // // # main() # // // ####################################################################### // /** Program entry point */ int main(void) { const char pszConfigFile[] = "# Simple configuration file\n" "Test = 123 // With comments\n" "String = Hello\n" "\n" "[Section ]\n" "String = World\n" "Test = 123.456\n"; try { Configuration CFG(pszConfigFile); cout << CFG.getFileContents() << endl; cout << "========================================" << endl; // Reading variables cout << "Global entries: " << CFG.getSection(0).getVariableCount() << endl; cout << "Value of Test: " << long(CFG.getSection(0).getVariable("Test")) << endl; // Changing CFG.getVariable("Test") = 456; CFG.getSection("Section").setName("NewName"); // Removing / adding CFG.getSection(0).removeVariable("String"); CFG.getSection("NewName").addVariable(Variable("String = Hello")); // Show changed contents cout << "========================================" << endl << endl; cout << CFG.getFileContents() << endl; } catch(const exception &e) { cerr << e.what(); //throw; } return 0; }