aboutsummaryrefslogtreecommitdiffstats
path: root/samples/c++/sample3.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'samples/c++/sample3.cpp')
-rw-r--r--samples/c++/sample3.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/samples/c++/sample3.cpp b/samples/c++/sample3.cpp
new file mode 100644
index 0000000..da1de79
--- /dev/null
+++ b/samples/c++/sample3.cpp
@@ -0,0 +1,54 @@
+/*************************************************************************
+ ** Sample3
+ ** Load sample.cfg and try to add a setting "foo"..
+ ** on success save to testfoo.cfg
+ *************************************************************************/
+
+#include <iostream>
+#include <libconfig.h++>
+
+using namespace libconfig;
+using namespace std;
+
+/***************************************************************************/
+
+int main()
+{
+ Config cfg;
+ try
+ {
+ /* Load the configuration.. */
+ cout << "loading [sample.cfg]...";
+ cfg.readFile("sample.cfg");
+ cout << "ok" << endl;
+
+ /* Add setting "foo" */
+ cout << "add setting \"foo\"/...";
+ Setting &root = cfg.getRoot();
+ Setting &foo = root.add("foo", Setting::TypeInt);
+ foo = 1234;
+ cout << "ok" << endl;
+
+ /** Look up an array element */
+ cout << "looking up array element...";
+ Setting &elem = cfg.lookup("arrays.values.[0]");
+ int val = elem;
+ std::cout << "value is: " << val << std::endl;
+ std::cout << "path is: " << elem.getPath() << std::endl;
+
+ /* Save to "samplefoo.cfg" */
+ cout << "saving [samplefoo.cfg]...";
+ cfg.writeFile("samplefoo.cfg");
+ cout << "ok" << endl;
+
+ cout << "Done!" << endl;
+ }
+ catch (...)
+ {
+ cout << "failed" << endl;
+ }
+
+ return 0;
+}
+
+/***************************************************************************/
*/ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
# initial tuning data for some frequencies of for the San Francisco Bay Area
# includes San Francisco, San Jose, Oakland...

A 503000000 8VSB
A 551000000 8VSB
A 563000000 8VSB
A 593000000 8VSB
A 623000000 8VSB
A 635000000 8VSB
A 647000000 8VSB
A 659000000 8VSB
A 683000000 8VSB
A 689000000 8VSB
A 701000000 8VSB
A 725000000 8VSB
A 731000000 8VSB