blob: ef82601ecc7a75735cedf93f6a0f927a2c9e0998 [file] [log] [blame]
dburgess82c46ff2011-10-07 02:40:51 +00001/*
2* Copyright 2009, 2010 Free Software Foundation, Inc.
3* Copyright 2010 Kestrel Signal Processing, Inc.
4*
5*
6* This software is distributed under the terms of the GNU Affero Public License.
7* See the COPYING file in the main directory for details.
8*
9* This use of this software may be subject to additional restrictions.
10* See the LEGAL file in the main directory for details.
11
12 This program is free software: you can redistribute it and/or modify
13 it under the terms of the GNU Affero General Public License as published by
14 the Free Software Foundation, either version 3 of the License, or
15 (at your option) any later version.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU Affero General Public License for more details.
21
22 You should have received a copy of the GNU Affero General Public License
23 along with this program. If not, see <http://www.gnu.org/licenses/>.
24
25*/
26
27
28
29#include "Configuration.h"
30#include <iostream>
31
32using namespace std;
33
34ConfigurationTable gConfig("exampleconfig.db");
35
36void purgeConfig(void*,int,char const*, char const*, sqlite3_int64)
37{
38 //cout << "update hook" << endl;
39 gConfig.purge();
40}
41
42
43int main(int argc, char *argv[])
44{
45
46 gConfig.setUpdateHook(purgeConfig);
47
48 char *keys[5] = {"key1", "key2", "key3", "key4", "key5"};
49
50 for (int i=0; i<5; i++) {
51 gConfig.set(keys[i],i);
52 }
53
54 for (int i=0; i<5; i++) {
55 cout << "table[" << keys[i] << "]=" << gConfig.getStr(keys[i]) << endl;
56 cout << "table[" << keys[i] << "]=" << gConfig.getNum(keys[i]) << endl;
57 }
58
59 gConfig.unset("key1");
60 for (int i=0; i<5; i++) {
61 cout << "defined table[" << keys[i] << "]=" << gConfig.defines(keys[i]) << endl;
62 }
63
64 gConfig.set("key5","100 200 300 400");
65 std::vector<unsigned> vect = gConfig.getVector("key5");
66 cout << "vect length " << vect.size() << ": ";
67 for (unsigned i=0; i<vect.size(); i++) cout << " " << vect[i];
68 cout << endl;
69}