keydata.cpp

Some exercise of keydata routines.

00001 // Copyright (C) 2006-2010 David Sugar, Tycho Softworks.
00002 //
00003 // This file is part of GNU uCommon C++.
00004 //
00005 // GNU uCommon C++ is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU Lesser General Public License as published
00007 // by the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // GNU uCommon C++ is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public License
00016 // along with GNU uCommon C++.  If not, see <http://www.gnu.org/licenses/>.
00017 
00018 #ifndef DEBUG
00019 #define DEBUG
00020 #endif
00021 
00022 #include <ucommon/ucommon.h>
00023 
00024 #include <stdio.h>
00025 
00026 using namespace UCOMMON_NAMESPACE;
00027 
00028 extern "C" int main()
00029 {
00030     keydata *keys;
00031     keyfile myfile("keydata.conf");
00032 
00033     keys = myfile.get();
00034     assert(eq_case(keys->get("key2"), "value2"));
00035 
00036     keys = myfile["section1"];
00037     assert(keys != NULL);
00038     assert(eq_case(keys->get("key1"), "this is value 1 quoted"));
00039 
00040     keys = myfile["section2"];
00041     assert(keys != NULL);
00042     assert(eq_case(keys->get("key1"), "replaced value"));
00043     return 0;
00044 }

Generated on 14 Aug 2013 for UCommon by  doxygen 1.4.7