This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 123
/
directoryvalue_delegate.hpp
73 lines (60 loc) · 2.5 KB
/
directoryvalue_delegate.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**
* @file
*
* @brief Delegate definitions for the `directoryvalue` plugin
*
* @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
*
*/
#ifndef ELEKTRA_CPP_DIRECTORY_VALUE_DELEGATE_HPP
#define ELEKTRA_CPP_DIRECTORY_VALUE_DELEGATE_HPP
#include <kdb.hpp>
#define DIRECTORY_POSTFIX "___dirdata"
#define ARRAY_VALUE_PREFIX "___dirdata:"
constexpr ssize_t arrayValuePrefixSize = sizeof (ARRAY_VALUE_PREFIX) - 1;
namespace elektra
{
// -- Functions ----------------------------------------------------------------------------------------------------------------------------
/**
* @brief Increase the array index of array elements by one.
*
* Since it is also possible that one of the array parents is part of another array, this function also updates the indices of the given
* array parents.
*
* @param parents This parameter contains the array parents for which this function increases the index by one.
* @param parents This variable stores the arrays elements this function updates.
*
* @return A pair containing a copy of `parents` and `arrays`, where all indices specified by `parents` are increased by one
*/
std::pair<kdb::KeySet, kdb::KeySet> increaseArrayIndices (kdb::KeySet const & parents, kdb::KeySet const & arrays);
// -- Class --------------------------------------------------------------------------------------------------------------------------------
class DirectoryValueDelegate
{
public:
/**
* @brief This constructor creates a new delegate object used by the `directoryvalue` plugin
*
* @param config This key set contains configuration values provided by the `directoryvalue` plugin
*/
explicit DirectoryValueDelegate (kdb::KeySet config);
/**
* @brief This method converts all leaf keys in the given key set to directory keys.
*
* @param keys This parameter specifies the key set this function converts.
*
* @retval ELEKTRA_PLUGIN_STATUS_SUCCESS if the plugin converted any value in the given key set
* @retval ELEKTRA_PLUGIN_STATUS_NO_UPDATE if the plugin did not update `keys`
*/
int convertToDirectories (kdb::KeySet & keys);
/**
* @brief This method converts all directory keys in the given key set to leaf keys.
*
* @param keys This parameter specifies the key set this function converts.
*
* @retval ELEKTRA_PLUGIN_STATUS_SUCCESS if the plugin converted any value in the given key set
* @retval ELEKTRA_PLUGIN_STATUS_NO_UPDATE if the plugin did not update `keys`
*/
int convertToLeaves (kdb::KeySet & keys);
};
} // end namespace elektra
#endif