forked from ElektraInitiative/libelektra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
printer.cpp
71 lines (51 loc) · 1.48 KB
/
printer.cpp
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
/**
* @file
*
* @brief
*
* @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
*/
#include "printer.hpp"
#include <key.hpp>
#include <keyset.hpp>
#include <iostream>
#include <string>
using namespace std;
using namespace kdb;
namespace elektra
{
Printer::Printer (KeySet & ks, Key & parentKey) : nr_keys (0), nr_meta (0), current (ks), parent (parentKey)
{
}
void Printer::add_key (std::vector<char> const & c)
{
std::string s (c.begin (), c.end ());
keyname = s;
Key k (parent.getName (), KEY_END);
k.addName (keyname);
current.append (k);
// cout << "current key is: " << current.current().getName() << endl;
++nr_keys;
// std::cout << "[" << nr_keys << "] add key " << s << std::endl;
}
void Printer::add_val (std::vector<char> const & c)
{
std::string s (c.begin (), c.end ());
// std::cout << "[" << nr_keys << "] add val " << s << " to keyname " << keyname << std::endl;
// cout << "current key is: " << current.current().getName() << endl;
current.current ().setString (s);
}
void Printer::add_metakey (std::vector<char> const & c)
{
std::string s (c.begin (), c.end ());
++nr_meta;
metaname = s;
// std::cout << "[" << nr_meta << "] add metakey " << s << std::endl;
}
void Printer::add_metaval (std::vector<char> const & c)
{
std::string s (c.begin (), c.end ());
// std::cout << "[" << nr_meta << "] add metaval " << s << " to metaname " << metaname << std::endl;
current.current ().setMeta<string> (metaname, s);
}
} // end namespace elektra