forked from ElektraInitiative/libelektra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
coder.hpp
55 lines (39 loc) · 1 KB
/
coder.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
/**
* @file
*
* @brief Definition of string encoding and decoding class
*
* @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
*
*/
#ifndef ELEKTRA_CODER_HPP
#define ELEKTRA_CODER_HPP
#include <vector>
#include <kdblogger.h>
#include <keyset.hpp>
namespace elektra
{
using std::string;
using std::vector;
class Coder
{
using CppKeySet = kdb::KeySet;
using CppKey = kdb::Key;
vector<unsigned char> encode;
vector<unsigned char> decode;
unsigned char escapeCharacter;
void setDefaultConfig ();
void readConfig (CppKeySet const & config, CppKey const & root);
string encodeString (string const & text);
string decodeString (string const & text);
void encodeValue (CppKey & key);
void decodeValue (CppKey & key);
CppKey encodeName (CppKey const & key);
CppKey decodeName (CppKey const & key);
public:
explicit Coder (CppKeySet config);
CppKeySet encodeKeySet (CppKeySet const & keys);
CppKeySet decodeKeySet (CppKeySet const & keys);
};
} // end namespace elektra
#endif