From 495d2cb6b47b309070b31e0ef83fa5731a150a6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Mon, 27 Jan 2020 21:56:06 +0100 Subject: Storage: handle record items with unknown type --- src/storage.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/storage.cpp') diff --git a/src/storage.cpp b/src/storage.cpp index 6b2e4f8..db9f629 100644 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -574,6 +574,14 @@ optional RecordT::Item::asRef() const return nullopt; } +template +optional::Item::UnknownType> RecordT::Item::asUnknown() const +{ + if (holds_alternative(value)) + return std::get(value); + return nullopt; +} + template RecordT::RecordT(const vector & from): @@ -625,7 +633,8 @@ optional> RecordT::decode(const S & st, items->emplace_back(name, st.ref(Digest(value))); } } else - throw runtime_error("unknown record item type"); + items->emplace_back(name, + typename Item::UnknownType { type, value }); begin = newline + 1; } @@ -696,6 +705,9 @@ vector RecordT::encodeInner() const } else if (auto x = item.asRef()) { type = "r.b2"; value = string(x->digest()); + } else if (auto x = item.asUnknown()) { + type = x->type; + value = x->value; } else { throw runtime_error("unhandeled record item type"); } -- cgit v1.2.3