std::string QKASClass::encode(std::string toEncode) { char current; std::string encoded = ""; for (unsigned int cl=0; cl < toEncode.length(); ++cl) { current = toEncode.at(cl); encoded += getRepr(current); if (cl < toEncode.length()-1) { encoded += reprSeparator; } } return encoded; }
void Stream::writeObject(SerializableBase *b) { if (!isOutput()) { throw dnnException()<< "Stream isn't open in output mode. Need output stream\n"; } vector<ProtoMessage> messages = b->getSerialized(); if (getRepr() == Text) { vector<string> buff; Document d; Value o(kObjectType); string temps = b->name(); if(!Factory::inst().isProtoType(temps)) { Value sub_o(kObjectType); for (auto &m : messages) { if(m->GetTypeName() != "Protos.ClassName") { Document *sub_d = Json::parseProtobuf(m); buff.push_back(m->GetTypeName()); sub_o.AddMember(StringRef(buff.back().c_str()), *sub_d, d.GetAllocator()); } } o.AddMember(StringRef(temps.c_str()), sub_o, d.GetAllocator()); } else { assert(messages.size() == 2); Document *sub_d = Json::parseProtobuf(messages[1]); o.AddMember(StringRef(temps.c_str()), *sub_d, d.GetAllocator()); } (*_output_str) << Json::stringify(o); } else if (getRepr() == Binary) { for (auto &m : messages) { writeBinaryMessage(m, _output_str); } } }