bool Datastore::write(std::ostream& out) { if (!_good) { return false; } try { DatastoreOutputArchiveType oarch(out); oarch << _root; return true; } catch (...) {} return false; }
void Journal::writeTransaction(const std::vector<RecordEvent>& events) { if (!_dataStream) { throw std::runtime_error("no datastream connected to journal"); } std::stringstream ss; { boost::archive::text_oarchive oarch(ss); oarch << events; } *_dataStream << ss.rdbuf(); _dataStream->flush(); }
extern "C" int Function_ChangeBinaryToBaseParticles(void * input_string, void * output_string, int ptCount) { std::string input((char*)input_string); std::stringstream in_stream; in_stream << "{\"value0\": \""; in_stream << input; in_stream << "\"}"; // std::cout << in_stream.str() << std::endl; cereal::JSONInputArchive arch(in_stream); std::vector<CWrongPtBase> particles; for (int i = 0; i < ptCount; ++i) { particles.push_back(CWrongPtBase()); } arch.loadBinaryValue(&particles[0], sizeof(CWrongPtBase) * ptCount); std::vector<CParticleBase> saveParticles; for (int i = 0; i < ptCount; ++i){ auto pt = CParticleBase(); pt.Coordinates = particles[i].Coordinates; CQuaternion newOrient; newOrient.W = particles[i].Rotation.W; newOrient.V = particles[i].Rotation.V; pt.SetRotation(CQuaternion(newOrient)); saveParticles.push_back(pt); } std::stringstream out_stream; cereal::JSONOutputArchive oarch(out_stream); oarch.saveBinaryValue(&saveParticles[0], sizeof(CParticleBase)*ptCount); std::string out_string = out_stream.str(); for(int i = 17; i < out_string.length()-1; i++) { ((char*)output_string)[i-17] = out_string[i]; } return strlen((char*)output_string); }