Line data Source code
1 : /**
2 : * @file
3 : *
4 : * @brief Definition of string encoding and decoding class
5 : *
6 : * @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
7 : *
8 : */
9 :
10 : #ifndef ELEKTRA_CODER_HPP
11 : #define ELEKTRA_CODER_HPP
12 :
13 : #include <vector>
14 :
15 : #include <kdblogger.h>
16 :
17 : #include <keyset.hpp>
18 :
19 : namespace elektra
20 : {
21 :
22 : using std::string;
23 : using std::vector;
24 :
25 1410 : class Coder
26 : {
27 : using CppKeySet = kdb::KeySet;
28 : using CppKey = kdb::Key;
29 :
30 : vector<unsigned char> encode;
31 : vector<unsigned char> decode;
32 :
33 : unsigned char escapeCharacter;
34 :
35 : void setDefaultConfig ();
36 : void readConfig (CppKeySet const & config, CppKey const & root);
37 :
38 : string encodeString (string const & text);
39 : string decodeString (string const & text);
40 :
41 : void encodeValue (CppKey & key);
42 : void decodeValue (CppKey & key);
43 :
44 : CppKey encodeName (CppKey const & key);
45 : CppKey decodeName (CppKey const & key);
46 :
47 : public:
48 : explicit Coder (CppKeySet config);
49 : CppKeySet encodeKeySet (CppKeySet const & keys);
50 : CppKeySet decodeKeySet (CppKeySet const & keys);
51 : };
52 :
53 : } // end namespace elektra
54 :
55 : #endif
|