Ejemplo n.º 1
0
string WebSocketManager::createEventMsg(string event, ptree &data)
{
    ptree json;
    json.put<string>("event", event);

    if(data.size() > 1)
        json.put_child("data", data);
    else
        json.add("data", data.front().second.data());

    stringstream buffer;
    write_json(buffer, json);

    return buffer.str();
}
Ejemplo n.º 2
0
        a.set("Hello", "World");
        a.set("foo", "bar");
        a.set("baz", "quxx");
	REQUIRE(a.get("foo") == "bar");
	// Verify copies are distinct
        b = a;
        a.set("foo", "");
        REQUIRE(b.get("foo") == "bar");
        REQUIRE(a.get("foo") == "");
	// Verify merkle hashes are canonical and unique
        c.set("Hello", "World");
        c.set("baz", "quxx");
        REQUIRE(a.merkle() == c.merkle());
        REQUIRE(a.merkle() != b.merkle());
	// Verify size works
	REQUIRE(a.size() == 2);
	REQUIRE(b.size() == 3);
	REQUIRE(c.size() == 2);
}

TEST_CASE("Simple ptree serialization", "[ptree]") {
        ptree a;
        ptree b;

	// Set some values
        a.set("Hello", "World");
        a.set("foo", "bar");
        a.set("baz", "quxx");

	// Save data
	string_writer sw;
Ejemplo n.º 3
0
void ptree_root::set(const ptree& pt)
{
	merkle = pt.merkle();
	size = pt.size();
}