| Elektra 0.11.0

Public Member Functions | Static Public Member Functions | List of all members
kdb::ElektraDiff Class Reference

This class is a wrapper around the ElektraDiff C struct. More...

`#include <elektradiff.hpp>`

## Public Member Functions
| ElektraDiff (ckdb::ElektraDiff *cdiff)
| Constructs a diff out of a C diff.
| ElektraDiff (ElektraDiff &other)
| Takes a reference of another diff.
| ElektraDiff (ElektraDiff const &other)
| Takes a reference of another diff.
void | undo (KeySet &ks)
| Undo the changes represented in this diff.
void | operator++ (int) const
| Increment the reference counter of a ElektraDiff object.
void | operator++ () const
| Increment the reference counter of a ElektraDiff object.
void | operator-- (int) const
| Decrement the reference counter of a ElektraDiff object.
void | operator-- () const
| Decrement the reference counter of a ElektraDiff object.
ckdb::ElektraDiff * | getDiff () const
| Passes out the raw diff pointer.
ckdb::ElektraDiff * | operator* () const
| Passes out the raw diff pointer.
ElektraDiff & | operator= (const ElektraDiff &other)
| Assign a diff.
uint16_t | getReferenceCounter () const
| Returns the reference counter of a ElektraDiff object.
void | removeOther (std::string const &parentKeyName)
| Removes all the keys from the diff that are NOT same or below the given parentkey.
void | removeOther (const Key &parentKey)
| Removes all the keys from the diff that are NOT same or below the given parentkey.
void | removeSameOrBelow (std::string const &cutpointName)
| Removes all keys from the diff that are same or below the given cutpoint.
void | removeSameOrBelow (const Key &cutpoint)
| Removes all keys from the diff that are same or below the given cutpoint.
void | removeKey (std::string const &keyName)
| Remove the given key from the diff.
void | removeKey (const Key &key)
| Remove the given key from the diff.
ElektraDiff | cut (std::string const &cutpointName)
| Creates a new diff with all keys from `original` that are same or below `cutpoint`.
ElektraDiff | cut (const Key &cutpoint)
| Creates a new diff with all keys from `original` that are same or below `cutpoint`.
ElektraDiff | dup () const
| Duplicate the given diff.
bool | isEmpty () const
| Determine whether the given diff is empty.
KeySet | getAddedKeys () const
| Get the added keys.
KeySet | getModifiedKeys () const
| Get the modified keys.
KeySet | getRemovedKeys () const
| Get the removed keys.
KeySet | getAddedMetaKeys (std::string const &keyName) const
| Get metakeys added to the specific keys.
KeySet | getAddedMetaKeys (const Key &key) const
| Get metakeys added to the specific keys.
KeySet | getModifiedMetaKeys (std::string const &keyName) const
| Get modified metakeys of the specific keys.
KeySet | getModifiedMetaKeys (const Key &key) const
| Get modified metakeys of the specific keys.
KeySet | getRemovedMetaKeys (std::string const &keyName) const
| Get metakeys removed from the specific keys.
KeySet | getRemovedMetaKeys (const Key &key) const
| Get metakeys removed from the specific keys.

## Static Public Member Functions
static ElektraDiff | calculateDiff (const KeySet &newKeys, const KeySet &oldKeys, const std::string &parentKeyName)
| Calculates the difference between the given keysets The diff will contain the keys that were added, modified and removed in `newKeys`.
static ElektraDiff | calculateDiff (const KeySet &newKeys, const KeySet &oldKeys, const Key &parentKey)
| Calculates the difference between the given keysets The diff will contain the keys that were added, modified and removed in `newKeys`.

## Detailed Description

This class is a wrapper around the ElektraDiff C struct.

Invariant
  always holds an underlying ElektraDiff C object.

## Constructor & Destructor Documentation

## ◆ ElektraDiff() [1/3]

kdb::ElektraDiff::ElektraDiff | ( | ckdb::ElektraDiff * | cdiff | ) |
| inline explicit

Constructs a diff out of a C diff.

Parameters

  cdiff | the diff to work with

## ◆ ElektraDiff() [2/3]

kdb::ElektraDiff::ElektraDiff | ( | ElektraDiff & | other | ) |
| inline

Takes a reference of another diff.

The diff will not be copied, but the reference counter will be increased.

Parameters

  other | the diff to work with

## ◆ ElektraDiff() [3/3]

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

Takes a reference of another diff.

The diff will not be copied, but the reference counter will be increased.

Parameters

  other | the diff to work with

## Member Function Documentation

## ◆ calculateDiff() [1/2]

ElektraDiff kdb::ElektraDiff::calculateDiff | ( | const KeySet & | newKeys,
|  | const KeySet & | oldKeys,
|  | const Key & | parentKey
| ) |  |
| inline static

Calculates the difference between the given keysets The diff will contain the keys that were added, modified and removed in `newKeys`.

Parameters

  newKeys | the new keyset
  oldKeys | the old keyset
  parentKey | only changes same or below this key will be calculated

Returns
  diff of the two given keysets

## ◆ calculateDiff() [2/2]

ElektraDiff kdb::ElektraDiff::calculateDiff | ( | const KeySet & | newKeys,
|  | const KeySet & | oldKeys,
|  | const std::string & | parentKeyName
| ) |  |
| inline static

Calculates the difference between the given keysets The diff will contain the keys that were added, modified and removed in `newKeys`.

Parameters

  newKeys | the new keyset
  oldKeys | the old keyset
  parentKeyName | only changes same or below this key will be calculated

Returns
  diff of the two given keysets

## ◆ cut() [1/2]

ElektraDiff kdb::ElektraDiff::cut | ( | const Key & | cutpoint | ) |
| inline

Creates a new diff with all keys from `original` that are same or below `cutpoint`.

The affected keys are removed from `original`

Parameters

  original | the original diff
  cutpoint | the cutpoint

Returns
  new diff with all the keys same or below `cutpoint`, OR `NULL` if `original` is `NULL` OR `NULL` if `cutpoint` is `NULL`

## ◆ cut() [2/2]

ElektraDiff kdb::ElektraDiff::cut | ( | std::string const & | cutpointName | ) |
| inline

Creates a new diff with all keys from `original` that are same or below `cutpoint`.

The affected keys are removed from `original`

Parameters

  original | the original diff
  cutpoint | the cutpoint

Returns
  new diff with all the keys same or below `cutpoint`, OR `NULL` if `original` is `NULL` OR `NULL` if `cutpoint` is `NULL`

## ◆ dup()

ElektraDiff kdb::ElektraDiff::dup | ( |  | ) | const
| inline

Duplicate the given diff.

Parameters

  original | the diff to duplicate

Returns
  duplicated version of the given diff

## ◆ getAddedKeys()

KeySet kdb::ElektraDiff::getAddedKeys | ( |  | ) | const
| inline

Get the added keys.

Parameters

  ksd | the ElektraDiff

Returns
  a new KeySet containing the added keys OR `NULL` if `ksd` is `NULL`

## ◆ getAddedMetaKeys() [1/2]

KeySet kdb::ElektraDiff::getAddedMetaKeys | ( | const Key & | key | ) | const
| inline

Get metakeys added to the specific keys.

Parameters

  ksd | the ElektraDiff
  key | the key of which you want to get added metadata

Returns
  a new KeySet that contains metadata added to the key OR `NULL` if `ksd` is `NULL` OR `key` is `NULL` OR `ksd` does not contain `key`.

## ◆ getAddedMetaKeys() [2/2]

KeySet kdb::ElektraDiff::getAddedMetaKeys | ( | std::string const & | keyName | ) | const
| inline

Get metakeys added to the specific keys.

Parameters

  ksd | the ElektraDiff
  key | the key of which you want to get added metadata

Returns
  a new KeySet that contains metadata added to the key OR `NULL` if `ksd` is `NULL` OR `key` is `NULL` OR `ksd` does not contain `key`.

## ◆ getDiff()

ckdb::ElektraDiff * kdb::ElektraDiff::getDiff | ( |  | ) | const
| inline

Passes out the raw diff pointer.

This pointer can be used to directly change the underlying diff object.

Note
  that the ownership remains in the object

## ◆ getModifiedKeys()

KeySet kdb::ElektraDiff::getModifiedKeys | ( |  | ) | const
| inline

Get the modified keys.

This will return the old keys (pre modification).

Parameters

  ksd | the ElektraDiff

Returns
  a new KeySet containing the modified keys OR `NULL` if `ksd` is `NULL`

## ◆ getModifiedMetaKeys() [1/2]

KeySet kdb::ElektraDiff::getModifiedMetaKeys | ( | const Key & | key | ) | const
| inline

Get modified metakeys of the specific keys.

Parameters

  ksd | the ElektraDiff
  key | the key of which you want to get modified metadata

Returns
  a new KeySet that contains modified metadata of the key OR `NULL` if `ksd` is `NULL` OR `key` is `NULL` OR `ksd` does not contain `key`.

## ◆ getModifiedMetaKeys() [2/2]

KeySet kdb::ElektraDiff::getModifiedMetaKeys | ( | std::string const & | keyName | ) | const
| inline

Get modified metakeys of the specific keys.

Parameters

  ksd | the ElektraDiff
  key | the key of which you want to get modified metadata

Returns
  a new KeySet that contains modified metadata of the key OR `NULL` if `ksd` is `NULL` OR `key` is `NULL` OR `ksd` does not contain `key`.

## ◆ getReferenceCounter()

uint16_t kdb::ElektraDiff::getReferenceCounter | ( |  | ) | const
| inline

Returns the reference counter of a ElektraDiff object.

Parameters

  ksd | the ElektraDiff object whose reference counter should get returned

Returns
  the value of the reference counter

Return values

  UINT16_MAX | on `NULL` pointer

## ◆ getRemovedKeys()

KeySet kdb::ElektraDiff::getRemovedKeys | ( |  | ) | const
| inline

Get the removed keys.

Parameters

  ksd | the ElektraDiff

Returns
  a new KeySet containing the removed keys OR `NULL` if `ksd` is `NULL`

## ◆ getRemovedMetaKeys() [1/2]

KeySet kdb::ElektraDiff::getRemovedMetaKeys | ( | const Key & | key | ) | const
| inline

Get metakeys removed from the specific keys.

Parameters

  ksd | the ElektraDiff
  key | the key of which you want to get removed metadata

Returns
  a new KeySet that contains metadata removed from the key OR `NULL` if `ksd` is `NULL` OR `key` is `NULL` OR `ksd` does not contain `key`.

## ◆ getRemovedMetaKeys() [2/2]

KeySet kdb::ElektraDiff::getRemovedMetaKeys | ( | std::string const & | keyName | ) | const
| inline

Get metakeys removed from the specific keys.

Parameters

  ksd | the ElektraDiff
  key | the key of which you want to get removed metadata

Returns
  a new KeySet that contains metadata removed from the key OR `NULL` if `ksd` is `NULL` OR `key` is `NULL` OR `ksd` does not contain `key`.

## ◆ isEmpty()

bool kdb::ElektraDiff::isEmpty | ( |  | ) | const
| inline

Determine whether the given diff is empty.

Parameters

  ksd | the diff

Returns
  `true` if diff is empty, `false` otherwise. Will also return `true` if `ksd` is `NULL`.

## ◆ operator*()

ckdb::ElektraDiff * kdb::ElektraDiff::operator* | ( |  | ) | const
| inline

Passes out the raw diff pointer.

This pointer can be used to directly change the underlying diff object.

Note
  that the ownership remains in the object

## ◆ operator++() [1/2]

void kdb::ElektraDiff::operator++ | ( |  | ) | const
| inline

Increment the reference counter of a ElektraDiff object.

Note
  The reference counter can never exceed `UINT16_MAX - 1`. `UINT16_MAX` is reserved as an error code.

Postcondition
  `ksd's` reference counter is > 0
  `ksd's` reference counter is <= UINT16_MAX - 1

Parameters

  ksd | the ElektraDiff object whose reference counter should be increased

Returns
  the updated value of the reference counter

Return values

  UINT16_MAX | on `NULL` pointer
  UINT16_MAX | when the reference counter already was the maximum value `UINT16_MAX - 1`, the reference counter will not be modified in this case

## ◆ operator++() [2/2]

void kdb::ElektraDiff::operator++ | ( | int |  | ) | const
| inline

Increment the reference counter of a ElektraDiff object.

Note
  The reference counter can never exceed `UINT16_MAX - 1`. `UINT16_MAX` is reserved as an error code.

Postcondition
  `ksd's` reference counter is > 0
  `ksd's` reference counter is <= UINT16_MAX - 1

Parameters

  ksd | the ElektraDiff object whose reference counter should be increased

Returns
  the updated value of the reference counter

Return values

  UINT16_MAX | on `NULL` pointer
  UINT16_MAX | when the reference counter already was the maximum value `UINT16_MAX - 1`, the reference counter will not be modified in this case

## ◆ operator--() [1/2]

void kdb::ElektraDiff::operator-- | ( |  | ) | const
| inline

Decrement the reference counter of a ElektraDiff object.

Postcondition
  `ksd's` reference counter is >= 0
  `ksd's` reference counter is < UINT16_MAX - 1

Parameters

  ksd | the ElektraDiff object whose reference counter should get decreased

Returns
  the updated value of the reference counter

Return values

  UINT16_MAX | on `NULL` pointer
  0 | when the reference counter already was the minimum value 0, the reference counter will not be modified in this case

## ◆ operator--() [2/2]

void kdb::ElektraDiff::operator-- | ( | int |  | ) | const
| inline

Decrement the reference counter of a ElektraDiff object.

Postcondition
  `ksd's` reference counter is >= 0
  `ksd's` reference counter is < UINT16_MAX - 1

Parameters

  ksd | the ElektraDiff object whose reference counter should get decreased

Returns
  the updated value of the reference counter

Return values

  UINT16_MAX | on `NULL` pointer
  0 | when the reference counter already was the minimum value 0, the reference counter will not be modified in this case

## ◆ operator=()

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

Assign a diff.

Parameters

  other | the diff to assign

Returns
  reference to this

## ◆ removeKey() [1/2]

void kdb::ElektraDiff::removeKey | ( | const Key & | key | ) |
| inline

Remove the given key from the diff.

Parameters

  ksd | the diff
  toRemove | the key to remove

## ◆ removeKey() [2/2]

void kdb::ElektraDiff::removeKey | ( | std::string const & | keyName | ) |
| inline

Remove the given key from the diff.

Parameters

  ksd | the diff
  toRemove | the key to remove

## ◆ removeOther() [1/2]

void kdb::ElektraDiff::removeOther | ( | const Key & | parentKey | ) |
| inline

Removes all the keys from the diff that are NOT same or below the given parentkey.

Parameters

  ksd | the diff where the keys should be removed
  parentKey | the parent key

## ◆ removeOther() [2/2]

void kdb::ElektraDiff::removeOther | ( | std::string const & | parentKeyName | ) |
| inline

Removes all the keys from the diff that are NOT same or below the given parentkey.

Parameters

  ksd | the diff where the keys should be removed
  parentKey | the parent key

## ◆ removeSameOrBelow() [1/2]

void kdb::ElektraDiff::removeSameOrBelow | ( | const Key & | cutpoint | ) |
| inline

Removes all keys from the diff that are same or below the given cutpoint.

Parameters

  ksd | the diff where the keys should be removed
  cutpoint | the cutpoint

## ◆ removeSameOrBelow() [2/2]

void kdb::ElektraDiff::removeSameOrBelow | ( | std::string const & | cutpointName | ) |
| inline

Removes all keys from the diff that are same or below the given cutpoint.

Parameters

  ksd | the diff where the keys should be removed
  cutpoint | the cutpoint

## ◆ undo()

void kdb::ElektraDiff::undo | ( | KeySet & | ks | ) |
| inline

Undo the changes represented in this diff.

Parameters

  ks | the keyset where the changs should be undone

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

- elektradiff.hpp