From d5a93691e136b06b914effce3a8f2de6a6039d15 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Thu, 10 Oct 2013 10:34:37 +0100 Subject: [PATCH] [cache_dump/restore] Use base64 encoding for the hints --- caching/xml_format.cc | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/caching/xml_format.cc b/caching/xml_format.cc index 50180ff..f731c57 100644 --- a/caching/xml_format.cc +++ b/caching/xml_format.cc @@ -1,3 +1,4 @@ +#include "base/base64.h" #include "caching/xml_format.h" #include @@ -11,15 +12,6 @@ using namespace std; //---------------------------------------------------------------- namespace { - // base64 encoding? - string encode(vector const &data) { - return ""; - } - - vector decode(string const &data) { - return vector(); - } - //-------------------------------- // Emitter //-------------------------------- @@ -87,9 +79,11 @@ namespace { virtual void hint(block_address cblock, vector const &data) { + using namespace base; + out_ << "" << endl; } @@ -187,8 +181,18 @@ namespace { } void parse_hint(emitter *e, attributes const &attr) { - e->hint(get_attr(attr, "cache_block"), - decode(get_attr(attr, "data"))); + using namespace base; + + block_address cblock = get_attr(attr, "cache_block"); + decoded_or_error doe = base64_decode(get_attr(attr, "data")); + if (!get >(&doe)) { + ostringstream msg; + msg << "invalid base64 encoding of hint for cache block " + << cblock << ": " << get(doe); + throw runtime_error(msg.str()); + } + + e->hint(cblock, get >(doe)); } void start_tag(void *data, char const *el, char const **attr) {