Revision 278, 1.0 kB
(checked in by smidl, 15 years ago)
|
props
|
-
Property svn:eol-style set to
native
|
Line | |
---|
1 | /************************************************************************* |
---|
2 | ** Sample2 |
---|
3 | ** Load sample.cfg and access the "values" array |
---|
4 | *************************************************************************/ |
---|
5 | |
---|
6 | #include <iostream> |
---|
7 | #include <libconfig.h++> |
---|
8 | |
---|
9 | using namespace libconfig; |
---|
10 | using namespace std; |
---|
11 | |
---|
12 | /***************************************************************************/ |
---|
13 | |
---|
14 | int main() |
---|
15 | { |
---|
16 | Config cfg; |
---|
17 | try |
---|
18 | { |
---|
19 | /* Load the configuration.. */ |
---|
20 | cout << "loading [sample.cfg].."; |
---|
21 | cfg.readFile("sample.cfg"); |
---|
22 | cout << "ok" << endl; |
---|
23 | |
---|
24 | // Display the "values" array |
---|
25 | cout << "display the \"values\" array.."; |
---|
26 | Setting& s = cfg.lookup("values"); |
---|
27 | long value1 = s[0]; |
---|
28 | long value2 = s[1]; |
---|
29 | cout << "[" << value1 << "," << value2 << "].."; |
---|
30 | cout << "ok" << endl; |
---|
31 | |
---|
32 | cout << "Done!" << endl; |
---|
33 | } |
---|
34 | catch (...) |
---|
35 | { |
---|
36 | cout << "failed" << endl; |
---|
37 | } |
---|
38 | |
---|
39 | return 0; |
---|
40 | } |
---|
41 | |
---|
42 | |
---|
43 | /***************************************************************************/ |
---|