diff options
author | Michael Tritz <mtritz@us.ibm.com> | 2017-08-02 15:25:51 -0500 |
---|---|---|
committer | Michael Tritz <mtritz@us.ibm.com> | 2017-08-02 15:27:04 -0500 |
commit | 5c90711a8aaa6b1d760388a5116e36831ce5e7ab (patch) | |
tree | d1472f81b6dab8f028c6e16f188aabcab29eb205 /serialize.cpp | |
parent | 1cb127fbc5c34ec8f1e61c8800985db36f50ae8b (diff) | |
download | openpower-pnor-code-mgmt-5c90711a8aaa6b1d760388a5116e36831ce5e7ab.tar.gz openpower-pnor-code-mgmt-5c90711a8aaa6b1d760388a5116e36831ce5e7ab.zip |
Change persistence file format from binary to JSON
This commit changes the storage format for the PNOR activation
persistence file from binary to JSON so that it is human-readable
and parseable.
Change-Id: I7ad6bd9c34284cccd281707052b962c069f50676
Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
Diffstat (limited to 'serialize.cpp')
-rw-r--r-- | serialize.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/serialize.cpp b/serialize.cpp index e2e8bfd22..8e957272b 100644 --- a/serialize.cpp +++ b/serialize.cpp @@ -1,6 +1,6 @@ #include "config.h" #include <experimental/filesystem> -#include <cereal/archives/binary.hpp> +#include <cereal/archives/json.hpp> #include <fstream> #include "serialize.hpp" @@ -21,9 +21,9 @@ void storeToFile(std::string versionId, uint8_t priority) } std::string path = PERSIST_DIR + versionId; - std::ofstream os(path.c_str(), std::ios::binary); - cereal::BinaryOutputArchive oarchive(os); - oarchive(priority); + std::ofstream os(path.c_str()); + cereal::JSONOutputArchive oarchive(os); + oarchive(cereal::make_nvp("priority", priority)); } void restoreFromFile(std::string versionId, uint8_t *priority) @@ -31,9 +31,9 @@ void restoreFromFile(std::string versionId, uint8_t *priority) std::string path = PERSIST_DIR + versionId; if (fs::exists(path)) { - std::ifstream is(path.c_str(), std::ios::in | std::ios::binary); - cereal::BinaryInputArchive iarchive(is); - iarchive(*priority); + std::ifstream is(path.c_str(), std::ios::in); + cereal::JSONInputArchive iarchive(is); + iarchive(cereal::make_nvp("priority", *priority)); } } |