Elektra  0.8.14
Public Member Functions
kdb::KDB Class Reference

Constructs a class KDB. More...

#include <kdb.hpp>

Public Member Functions

 KDB ()
 Constructs a class KDB. More...
 
 KDB (Key &errorKey)
 Constructs a class KDB. More...
 
 ~KDB () throw ()
 The destructor closes the database. More...
 
void open (Key &errorKey)
 Open the database. More...
 
void close (Key &errorKey) throw ()
 Open the database. More...
 
int get (KeySet &returned, std::string const &keyname)
 Get all keys below keyname inside returned. More...
 
int get (KeySet &returned, Key &parentKey)
 Get all keys below parentKey inside returned. More...
 
int set (KeySet &returned, std::string const &keyname)
 Set all keys below keyname. More...
 
int set (KeySet &returned, Key &parentKey)
 Set all keys below parentKey. More...
 

Detailed Description

Constructs a class KDB.

Exceptions
KDBExceptionif database could not be opened

Access to the key database.

Invariant
the object holds an valid connection to the key database or is empty

Constructor & Destructor Documentation

kdb::KDB::KDB ( )
inline

Constructs a class KDB.

Exceptions
KDBExceptionif database could not be opened
kdb::KDB::KDB ( Key errorKey)
inline

Constructs a class KDB.

Parameters
errorKeyis useful if you want to get the warnings in the successful case, when no exception is thrown.
Exceptions
KDBExceptionif database could not be opened
kdb::KDB::~KDB ( )
throw (
)
inline

The destructor closes the database.

Member Function Documentation

void kdb::KDB::close ( Key errorKey)
throw (
)
inline

Open the database.

The return value does not matter because its only a null pointer check.

Parameters
errorKeyis useful if you want to get the warnings
int kdb::KDB::get ( KeySet returned,
std::string const &  keyname 
)
inline

Get all keys below keyname inside returned.

#include <kdb.hpp>
#include <keyio.hpp>
using namespace kdb;
int main()
{
KeySet config;
kdb.get(config, "/sw/MyApp");
Key k = config.lookup("/sw/MyApp/mykey");
if (k)
{
std::cout << k << " is " << k.get<int>() << std::endl;
}
else
{
std::cerr << "No key found" << std::endl;
return 1;
}
}
Parameters
returnedthe keyset where the keys will be in
keynamethe root keyname which should be used to get keys below it
Return values
0if no key was updated
1if user or system keys were updated
2if user and system keys were updated
Exceptions
KDBExceptionif there were problems with the database
See also
KDB::get (KeySet & returned, Key & parentKey)
int kdb::KDB::get ( KeySet returned,
Key parentKey 
)
inline

Get all keys below parentKey inside returned.

Parameters
returnedthe keyset where the keys will be in
parentKeythe parentKey of returned
Return values
0if no key was updated
1if user or system keys were updated
2if user and system keys were updated
Exceptions
KDBExceptionif there were problems with the database
void kdb::KDB::open ( Key errorKey)
inline

Open the database.

Parameters
errorKeyis useful if you want to get the warnings in the successful case, when no exception is thrown.
int kdb::KDB::set ( KeySet returned,
std::string const &  keyname 
)
inline

Set all keys below keyname.

If the keyname of the parentKey is invalid (e.g. empty) all keys will be set.

Return values
0if no key was updated
1if user or system keys were updated
2if user and system keys were updated
Parameters
returnedthe keyset where the keys will be in
keynamethe keyname below the names should be set
Exceptions
KDBExceptionif there were problems with the database
int kdb::KDB::set ( KeySet returned,
Key parentKey 
)
inline

Set all keys below parentKey.

If the keyname of the parentKey is invalid (e.g. empty) all keys will be set.

Return values
0if no key was updated
1if user or system keys were updated
2if user and system keys were updated
Parameters
returnedthe keyset where the keys are passed to the user
parentKeythe parentKey of returned
Exceptions
KDBExceptionif there were problems with the database

The documentation for this class was generated from the following file: