blob: 60fcec884db69b20c9108e07b2629a3b602c5b86 (
plain)
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
|
#ifndef BRICE_H_
#define BRICE_H_
#include <unordered_map>
#include <string>
#include <istream>
#include <fstream>
#include <common.hpp>
class Brice {
private:
std::unordered_map<std::string, std::string> ice;
public:
Brice(void){}
~Brice(void){}
std::string getValue(const std::string& id) const {
auto item = ice.find(id);
return (item == std::end(ice)) ? "" : item->second;
}
void addValue(const std::string &id, const std::string& value) {
ice.emplace(std::make_pair(id, value));
}
void save(void) const {
std::ofstream out ("brice.dat", std::ios::out | std::ios::binary);
std::string data = std::to_string(ice.size()) + '\n';
if (!out.is_open())
UserError("Cannot open brice data file");
for (const auto& i : ice) {
data.append(i.first + ',' );
data.append(i.second + '\n');
}
out.write(data.data(), data.size());
out.close();
}
void load(void) {
const std::string data = readFile("brice.dat");
}
};
#endif // BRICE_H_
|