Elektra: kdb::KDB Class Reference

Elektra 0.8.14

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- Data Structures
- Class Hierarchy
- Data Fields

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

  KDBException | if 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

  KDBException | if database could not be opened

kdb::KDB::KDB | ( | Key & | errorKey | ) |
| inline

Constructs a class KDB.

Parameters

  errorKey | is useful if you want to get the warnings in the successful case, when no exception is thrown.

Exceptions

  KDBException | if 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

  errorKey | is 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 kdb;
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

  returned | the keyset where the keys will be in
  keyname | the root keyname which should be used to get keys below it

Return values

  0 | if no key was updated
  1 | if user or system keys were updated
  2 | if user and system keys were updated

Exceptions

  KDBException | if 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

  returned | the keyset where the keys will be in
  parentKey | the parentKey of returned

Return values

  0 | if no key was updated
  1 | if user or system keys were updated
  2 | if user and system keys were updated

Exceptions

  KDBException | if there were problems with the database

void kdb::KDB::open | ( | Key & | errorKey | ) |
| inline

Open the database.

Parameters

  errorKey | is 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

  0 | if no key was updated
  1 | if user or system keys were updated
  2 | if user and system keys were updated

Parameters

  returned | the keyset where the keys will be in
  keyname | the keyname below the names should be set

Exceptions

  KDBException | if 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

  0 | if no key was updated
  1 | if user or system keys were updated
  2 | if user and system keys were updated

Parameters

  returned | the keyset where the keys are passed to the user
  parentKey | the parentKey of returned

Exceptions

  KDBException | if there were problems with the database

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

- kdb.hpp