Beispiel #1
0
int main()
{
    std::stringstream ss;
    {
        Data mmm { 
            { Key {{{KeyElement { 1, 2 }, KeyElement { 3, 4 }} }}, 5 }, 
            { Key {{{KeyElement { 6, 7 }, KeyElement { 8, 9 }} }}, 42 },
        };
        boost::archive::text_oarchive oa(ss);

        oa << mmm;
    }

    std::cout << "Serialized:\t" << ss.str() << "\n";

    {
        boost::archive::text_iarchive iarch(ss);
        Data mmm; 
        iarch >> mmm;

        std::cout << "Roundtrip:\t";
        boost::archive::text_oarchive oa(std::cout);
        oa << mmm;
    }
}
Beispiel #2
0
Datastore::Datastore(std::istream& in) {
	try {
		auto pos = in.tellg();

		in.seekg(0, in.end);

		if (in.tellg() - pos == 0) {
			// empty input stream
			return;
		}
		in.seekg(pos);

		DatastoreInputArchiveType iarch(in);
		iarch >> _root;
	} catch (std::exception& e) {
		Logf(kLogLevelInfo, "unable to parse datastore input stream");
		_good = false;
	}
}
Beispiel #3
0
bool Journal::applyToDatastore(Datastore* ds) {
	if (!_dataStream) {
		throw std::runtime_error("no datastream connected to journal");
	}

	std::vector<std::vector<RecordEvent>> events;

	try {
		boost::archive::text_iarchive iarch(*_dataStream);
		while (true) {
			std::vector<RecordEvent> e;
			iarch >> e;
			events.push_back(std::move(e));
		}
	} catch (...) {}

	for (auto&& vec : events) {
		for (auto&& e : vec) {
			e(ds);
		}
	}

	return true;
}