8#include <framework/utilities/Stream.h>
10#include <framework/logging/Logger.h>
16#include <boost/algorithm/string/replace.hpp>
22 class StreamMsg :
public TMessage {
24 StreamMsg(
const void* buf,
int len) : TMessage(const_cast<void*>(buf), len)
26 this->SetBit(kIsOwner,
false);
34 TMessage::EnableSchemaEvolutionForAll();
36 TMessage msg(kMESS_OBJECT);
43 msg.SetCompressionLevel(0);
49 char* buf = msg.Buffer();
50 UInt_t len = msg.Length();
52 if (msg.CompBuffer()) {
53 B2FATAL(
"compression used, but broken thanks to ROOT");
60 const std::string& encodedStr(TBase64::Encode(buf, len).Data());
67 std::string newString(xmlString);
68 boost::replace_all(newString,
"]]>",
"]]]]><![CDATA[>");
69 return "<![CDATA[" + newString +
"]]>";
74 if (base64Data.empty())
78 const TString& data(TBase64::Decode(base64Data.c_str()));
80 StreamMsg msg(data.Data(), data.Length());
82 if (msg.What() != kMESS_OBJECT or msg.GetClass() ==
nullptr) {
85 auto* obj =
static_cast<TObject*
>(msg.ReadObjectAny(msg.GetClass()));
std::string escapeXML(const std::string &xmlString)
Escape given XML string as CDATA sequence.
std::string serializeAndEncode(const TObject *obj)
Convert given TObject into encoded byte stream (for storing in XML).
TObject * deserializeEncodedRawData(const std::string &base64Data)
Convert given serialized raw data back into TObject.
Abstract base class for different kinds of events.