From 095293277dbca80e91c4f25b05923b7cb3a79396 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Wed, 4 May 2016 08:48:24 -0400 Subject: fade fixes --- include/brice.hpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 include/brice.hpp (limited to 'include') diff --git a/include/brice.hpp b/include/brice.hpp new file mode 100644 index 0000000..60fcec8 --- /dev/null +++ b/include/brice.hpp @@ -0,0 +1,48 @@ +#ifndef BRICE_H_ +#define BRICE_H_ + +#include +#include +#include +#include + +#include + +class Brice { +private: + std::unordered_map 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_ -- cgit v1.2.3