Elektra: kdb::KeySet 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::KeySet Class Reference

A keyset holds together a set of keys. More...

`#include <keyset.hpp>`

## Public Member Functions
| KeySet ()
| Creates a new empty keyset with no keys. More...
| KeySet (ckdb::KeySet *k)
| Takes ownership of keyset! More...
| KeySet (const KeySet &other)
| Duplicate a keyset. More...
| KeySet (size_t alloc,...)
| Create a new keyset. More...
| KeySet (Va va, size_t alloc, va_list ap)
| Create a new keyset. More...
| ~KeySet ()
| Deconstruct a keyset. More...
ckdb::KeySet * | release ()
| If you don't want destruction of keyset at the end you can release the pointer.
ckdb::KeySet * | getKeySet () const
| Passes out the raw keyset pointer. More...
void | setKeySet (ckdb::KeySet *k)
| Take ownership of passed keyset. More...
KeySet & | operator= (KeySet const &other)
| Duplicate a keyset. More...
ssize_t | size () const
| The size of the keyset. More...
ckdb::KeySet * | dup () const
| Duplicate a keyset. More...
void | copy (const KeySet &other)
| Copy a keyset. More...
void | clear ()
| Clear the keyset. More...
ssize_t | append (const Key &toAppend)
| append a key More...
Key | head () const
Key | tail () const
void | rewind () const
Key | next () const
Key | current () const
void | setCursor (cursor_t cursor) const
cursor_t | getCursor () const
Key | pop ()
KeySet | cut (Key k)
Key | lookup (const Key &k, const option_t options=KDB_O_NONE) const
Key | lookup (std::string const &name, const option_t options=KDB_O_NONE) const
| Lookup a key by name. More...
Key | at (cursor_t pos) const
| Lookup a key by index. More...

## Detailed Description

A keyset holds together a set of keys.

Invariant
  always holds an underlying elektra keyset.

Note
  that the cursor is mutable, so it might be changed even in const functions as described.

## Constructor & Destructor Documentation

kdb::KeySet::KeySet | ( |  | ) |
| inline

Creates a new empty keyset with no keys.

kdb::KeySet::KeySet | ( | ckdb::KeySet * | k | ) |
| inline

Takes ownership of keyset!

Keyset will be destroyed at destructor you cant continue to use keyset afterwards!

Use KeySet::release() to avoid destruction.

Parameters

  k | the keyset to take the ownership from

See also
  release()
  setKeySet()

kdb::KeySet::KeySet | ( | const KeySet & | other | ) |
| inline

Duplicate a keyset.

This keyset will be a duplicate of the other afterwards.

Note
  that they still reference to the same Keys, so if you change key values also the keys in the original keyset will be changed.

So it is shallow copy, to create a deep copy you have to dup() every key (it still won't copy meta data, but they are COW):

kdb::KeySet ksDeepCopy(kdb::KeySet orig)
{
kdb::KeySet deepCopy;
orig.rewind();
while (orig.next())
{
deepCopy.append(orig.current().dup());
}
return deepCopy;
}

See also
  dup

kdb::KeySet::KeySet | ( | size_t | alloc,
|  |  | ...
| ) |  |
| inlineexplicit

Create a new keyset.

Parameters

  alloc | minimum number of keys to allocate
  ... | variable argument list

kdb::KeySet::KeySet | ( | Va | va,
|  | size_t | alloc,
|  | va_list | av
| ) |  |
| inlineexplicit

Create a new keyset.

Parameters

  alloc | minimum number of keys to allocate
  ap | variable arguments list

Use va as first argument to use this constructor, e.g.:

KeySet ks(va, 23, ...);

kdb::KeySet::~KeySet | ( |  | ) |
| inline

Deconstruct a keyset.

## Member Function Documentation

ssize_t kdb::KeySet::append | ( | const Key & | toAppend | ) |
| inline

append a key

Parameters

  toAppend | key to append

Returns
  number of keys in the keyset

Key kdb::KeySet::at | ( | cursor_t | pos | ) | const
| inline

Lookup a key by index.

Parameters

  pos | cursor position

Returns
  the found key

void kdb::KeySet::clear | ( |  | ) |
| inline

Clear the keyset.

Keyset will have no keys afterwards.

void kdb::KeySet::copy | ( | const KeySet & | other | ) |
| inline

Copy a keyset.

Parameters

  other | other keyset to copy

This is only a shallow copy. For a deep copy you need to dup every key.

Key kdb::KeySet::current | ( |  | ) | const
| inline

KeySet kdb::KeySet::cut | ( | Key | k | ) |
| inline

ckdb::KeySet * kdb::KeySet::dup | ( |  | ) | const
| inline

Duplicate a keyset.

Returns
  a copy of the keys

This is only a shallow copy. For a deep copy you need to dup every key.

cursor_t kdb::KeySet::getCursor | ( |  | ) | const
| inline

ckdb::KeySet * kdb::KeySet::getKeySet | ( |  | ) | const
| inline

Passes out the raw keyset pointer.

Returns
  pointer to internal ckdb KeySet

See also
  release()
  setKeySet()

Key kdb::KeySet::head | ( |  | ) | const
| inline

Returns
  alphabetical first key

Key kdb::KeySet::lookup | ( | const Key & | key,
|  | const option_t | options = `KDB_O_NONE`
| ) |  | const
| inline

Note
  That the internal key cursor will point to the found key

Key kdb::KeySet::lookup | ( | std::string const & | name,
|  | const option_t | options = `KDB_O_NONE`
| ) |  | const
| inline

Lookup a key by name.

Parameters

  name | the name to look for
  options | some options to pass

Returns
  the found key

See also
  lookup (const Key &key, const option_t options)

Note
  That the internal key cursor will point to the found key

Key kdb::KeySet::next | ( |  | ) | const
| inline

KeySet & kdb::KeySet::operator= | ( | KeySet const & | other | ) |
| inline

Duplicate a keyset.

This keyset will be a duplicate of the other afterwards.

Note
  that they still reference to the same Keys, so if you change key values also the keys in the original keyset will be changed.

Key kdb::KeySet::pop | ( |  | ) |
| inline

void kdb::KeySet::rewind | ( |  | ) | const
| inline

void kdb::KeySet::setCursor | ( | cursor_t | cursor | ) | const
| inline

void kdb::KeySet::setKeySet | ( | ckdb::KeySet * | k | ) |
| inline

Take ownership of passed keyset.

Parameters

  k | the keyset to take ownership from

See also
  release()
  getKeySet()

ssize_t kdb::KeySet::size | ( |  | ) | const
| inline

The size of the keyset.

Returns
  the number of keys in the keyset

Key kdb::KeySet::tail | ( |  | ) | const
| inline

Returns
  alphabetical last key

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

- keyset.hpp