当前位置: 首页>>代码示例>>C++>>正文


C++ Document::GetAllocator方法代码示例

本文整理汇总了C++中Document::GetAllocator方法的典型用法代码示例。如果您正苦于以下问题:C++ Document::GetAllocator方法的具体用法?C++ Document::GetAllocator怎么用?C++ Document::GetAllocator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Document的用法示例。


在下文中一共展示了Document::GetAllocator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: serialize

      Document JsonBlockFactory::serialize(const Block &block) {
        Document document;
        auto &allocator = document.GetAllocator();
        document.SetObject();

        Value signatures;
        signatures.SetArray();
        for (const auto &signature : block.sigs) {
          signatures.PushBack(serializeSignature(signature, allocator),
                              allocator);
        }
        document.AddMember("signatures", signatures, allocator);

        document.AddMember("created_ts", block.created_ts, allocator);
        document.AddMember("hash", block.hash.to_hexstring(), allocator);
        document.AddMember(
            "prev_hash", block.prev_hash.to_hexstring(), allocator);
        document.AddMember("height", block.height, allocator);
        document.AddMember("txs_number", block.txs_number, allocator);

        Value commands;
        commands.SetArray();
        for (auto &&transaction : block.transactions) {
          commands.PushBack(
              Document(&allocator)
                  .CopyFrom(factory_.serialize(transaction), allocator),
              allocator);
        }
        document.AddMember("transactions", commands, allocator);

        return document;
      }
开发者ID:kevinmcmahon,项目名称:iroha,代码行数:32,代码来源:json_block_factory.cpp

示例2: accept_binary_message

 void accept_binary_message(binary_message const& msg,Value& val,Document& doc,vector<shared_ptr<const string> >& buffers)
 {
     val.SetObject();
     Value boolVal;
     boolVal.SetBool(true);
     val.AddMember(kBIN_PLACE_HOLDER, boolVal, doc.GetAllocator());
     Value numVal;
     numVal.SetInt((int)buffers.size());
     val.AddMember("num", numVal, doc.GetAllocator());
     //FIXME can not avoid binary copy here.
     shared_ptr<string> write_buffer = make_shared<string>();
     write_buffer->reserve(msg.get_binary()->size()+1);
     char frame_char = packet::frame_message;
     write_buffer->append(&frame_char,1);
     write_buffer->append(*(msg.get_binary()));
     buffers.push_back(write_buffer);
 }
开发者ID:4ker,项目名称:CamFiQt,代码行数:17,代码来源:sio_packet.cpp

示例3: setShootMode

Document Device::setShootMode(const CString &shootMode)
{
	Document d;
	CString type = "camera";
	Value method;
	method = "setShootMode";
	Value params;
	params.SetArray();
	if (shootMode == "still")
	params.PushBack("still", d.GetAllocator());
	if (shootMode == "movie")
		params.PushBack("movie", d.GetAllocator());
	Value version;
	version = "1.0";
	return sendApi(type, method, params, version);

}
开发者ID:zkq,项目名称:SonyRemoteControlCamera,代码行数:17,代码来源:device.cpp

示例4: accept_array_message

 void accept_array_message(array_message const& msg,Value& val,Document& doc,vector<shared_ptr<const string> >& buffers)
 {
     val.SetArray();
     for (vector<message::ptr>::const_iterator it = msg.get_vector().begin(); it!=msg.get_vector().end(); ++it) {
         Value child;
         accept_message(*(*it), child, doc,buffers);
         val.PushBack(child, doc.GetAllocator());
     }
 }
开发者ID:4ker,项目名称:CamFiQt,代码行数:9,代码来源:sio_packet.cpp

示例5: Convert

rapidjson::Document SceneConvertor::Convert( const Scene* scene )
{
	Document json;
	json.SetObject();
	Document::AllocatorType& al = json.GetAllocator();

	
	json.AddMember( "FILE_TYPE",		"SCENE",							al );

	Value stringNode;
	Value nullNode;
	nullNode.SetNull();

	Material* skyboxMat = scene->GetSkyboxMaterial();
	if (skyboxMat != NULL)
	{
		stringNode.SetString( skyboxMat->GetName().ToChar(),				al );
		json.AddMember( "skyboxMaterial",	stringNode,						al );
	}
	else
	{
		json.AddMember( "skyboxMaterial",	nullNode,						al );
	}

	json.AddMember( "skyboxSize",	scene->GetSkyboxSize(),					al );

	Value vec3Node = _Vec3_to_JSON( scene->GetAmbientLight(), al );
	json.AddMember( "ambientLight",	vec3Node,								al );

		
	if ( scene->GetMainCamera() != NULL )
	{
		stringNode.SetString( scene->GetMainCamera()->GetName().ToChar(),	al );
		json.AddMember( "mainCamera",	stringNode,							al );
	}
	else
	{
		json.AddMember( "mainCamera",	nullNode,							al );
	}

	Value arrayNode;
	arrayNode.SetArray();
	for (uint i = 0; i < scene->GetGameObjectCount(); ++i)
	{
		GameObject* gameObject = scene->GetGameObjectAt(i);
		if ( gameObject->GetParentNode() == NULL && (_useAll || gameObject->IsSavable()) )
		{
			arrayNode.PushBack( _GameObject_to_JSON(gameObject, al),		al );
		}
	}

	json.AddMember( "gameObjects",		arrayNode,							al );


	return json;
}
开发者ID:MorcoFreeCode,项目名称:2015__MorcoEngine3D,代码行数:56,代码来源:SceneConvertor.cpp

示例6: writer

// Issue 226: Value of string type should not point to NULL
TEST(Document, AssertAcceptInvalidNameType) {
    Document doc;
    doc.SetObject();
    doc.AddMember("a", 0, doc.GetAllocator());
    doc.FindMember("a")->name.SetNull(); // Change name to non-string type.

    OutputStringStream os;
    Writer<OutputStringStream> writer(os);
    ASSERT_THROW(doc.Accept(writer), AssertException);
}
开发者ID:Longhui,项目名称:mysql-5.7.9-readcode,代码行数:11,代码来源:documenttest.cpp

示例7: actZoom

Document Device::actZoom(CString direction, CString movement)
{
	Document d;
	CString type = "camera";
	Value method;
	method = "actZoom";

	Value params;
	params.SetArray();
	//direction
	Value s;
	s.SetString(direction, d.GetAllocator());
	params.PushBack(s, d.GetAllocator());
	//movement
	s.SetString(movement, d.GetAllocator());
	params.PushBack(s, d.GetAllocator());

	Value version;
	version = "1.0";
	return sendApi(type, method, params, version);
}
开发者ID:zkq,项目名称:SonyRemoteControlCamera,代码行数:21,代码来源:device.cpp

示例8: setPostviewImageSize

Document Device::setPostviewImageSize(){
	Document d;
	CString type = "camera";
	Value method;
	method = "setPostviewImageSize";
	Value params;
	params.SetArray();
	params.PushBack("Original", d.GetAllocator());

	Value version;
	version = "1.0";
	return sendApi(type, method, params, version);

}
开发者ID:zkq,项目名称:SonyRemoteControlCamera,代码行数:14,代码来源:device.cpp

示例9: do_read

	void do_read()
	{
		auto self(shared_from_this());
		socket_.async_read_some(boost::asio::buffer(data_, max_length),
			[this, self](boost::system::error_code ec, std::size_t length)
		{
			if (!ec)
			{
				TMP_PACKET* packet = (TMP_PACKET*)(data_);
				Document d;
				d.Parse(packet->strdata);
				Value& ss = d["stars"];
				ss.SetInt(ss.GetInt() + 1);
				OutputDebugString("recv packet");

				Document sendJson;
				sendJson.SetObject();
				Document::AllocatorType& allocator = sendJson.GetAllocator();
				sendJson.AddMember("cmd", 1, allocator);
				sendJson.AddMember("ret", 1, allocator);

				// Convert JSON document to string
				rapidjson::StringBuffer strbuf;
				rapidjson::Writer<rapidjson::StringBuffer> writer(strbuf);
				sendJson.Accept(writer);
				
				static int totalcnt = 0;
				totalcnt++;

				TCP_PACKET_H hdr;
				hdr.PacketSize = strbuf.GetSize()+ 1 + sizeof(TCP_PACKET_H);
				memcpy_s(_sendData, sizeof(TCP_PACKET_H), (void*)&hdr, sizeof(TCP_PACKET_H));
				std::cout << strbuf.GetString() << strbuf.GetSize() << " total:"<< totalcnt << std::endl;
				//std::cout << strbuf.GetSize() << std::endl;
				sprintf_s(_sendData + sizeof(TCP_PACKET_H), strbuf.GetSize()+1, "%s",strbuf.GetString());


				
				
				// 오류코드 없으면, 패킷데이터 처리..
				// 헤더검사 등의 예외처리 필요..
				//TMP_PACKET sendPkt;
				//sendPkt.Header.PacketSize = strbuf.GetSize()+;
				do_write(hdr.PacketSize);

				do_read();

			}
		});
	}
开发者ID:ak47-nexon,项目名称:asioserver,代码行数:50,代码来源:main.cpp

示例10: SetField

int ConfigParser::SetField(const char* field, const char* value)
{
    stringstream err;
    FILE* fpRead = fopen(configPath.c_str(), "rb");

    if(!fpRead){
        err << "Could not open file " << configPath << "!";
        errors.push_back(err.str());
        return -1; 
    }
    char readBuffer[CONFIGPARSER_BUF_SIZE] = {};
    FileReadStream configStream(fpRead, readBuffer, sizeof(readBuffer));

    Document d;
    d.ParseStream(configStream);

    if(d.HasMember(field)){
        Value& tmp(d[field]);
        tmp.SetString(StringRef(value));
    }
    else
    {
        Value::AllocatorType& a(d.GetAllocator());
        d.AddMember(StringRef(field), StringRef(value), a);
        if(!d.HasMember(field)){
            fclose(fpRead);
            err << "Failed to set field '" << field << "'' in config file " << configPath << "!";
            errors.push_back(err.str());
            return -1; 
        }
    }
    fclose(fpRead);

    FILE* fpWrite = fopen(configPath.c_str(), "wb");
    if(!fpWrite){
        err << "Could not open file " << configPath << "!";
        errors.push_back(err.str());
        return -1; 
    }

    char writeBuffer[CONFIGPARSER_BUF_SIZE] = {};
    FileWriteStream configWriteStream(fpWrite, writeBuffer, sizeof(writeBuffer));
    PrettyWriter<FileWriteStream> writer(configWriteStream);
    d.Accept(writer);

    fclose(fpWrite);

    return 0;
}
开发者ID:muzzley,项目名称:alljoyn-muzzley-gateway-connector,代码行数:49,代码来源:ConfigParser.cpp

示例11: writeObject

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);
		}
	}

}
开发者ID:alexeyche,项目名称:alexeyche-junk,代码行数:36,代码来源:stream.cpp

示例12: encode

string XJson::encode(const ::urbi::UValue& data) {
    if (data.type != ::urbi::DATA_DICTIONARY && data.type != ::urbi::DATA_LIST) {
        send("throw \"Only UList or UDictionary are supported by UJson.\";");
        return "";
    }
    Document doc;
    StringBuffer stream;

    Writer<StringBuffer> writer(stream);

    unique_ptr<Value> valPtr(fromUValue(data, doc.GetAllocator()));
    (*valPtr).Accept(writer);

    string result(stream.GetString());
    stream.Clear();
    return result;
}
开发者ID:XCopterStudio,项目名称:xcs,代码行数:17,代码来源:x_json.cpp

示例13: addControl

Value addControl(Document& root, const char* type, int x, int y, int w, int h, int id){
    Document::AllocatorType& a = root.GetAllocator();
    
    Value ctl;
    ctl.SetObject();
    ctl.AddMember("type", StringRef(type), a);
    ctl.AddMember("id", id, a);
    
    Value frame;
    frame.SetObject();
    frame.AddMember("x", x, a);
    frame.AddMember("y", y, a);
    frame.AddMember("w", w, a);
    frame.AddMember("h", h, a);
    ctl.AddMember("frame", frame, a);
    
    return ctl;
}
开发者ID:aa4145,项目名称:PlayPhone,代码行数:18,代码来源:main.cpp

示例14:

TEST(Document, UnchangedOnParseError) {
    Document doc;
    doc.SetArray().PushBack(0, doc.GetAllocator());

    ParseResult err = doc.Parse("{]");
    EXPECT_TRUE(doc.HasParseError());
    EXPECT_EQ(err.Code(), doc.GetParseError());
    EXPECT_EQ(err.Offset(), doc.GetErrorOffset());
    EXPECT_TRUE(doc.IsArray());
    EXPECT_EQ(doc.Size(), 1u);

    err = doc.Parse("{}");
    EXPECT_FALSE(doc.HasParseError());
    EXPECT_FALSE(err.IsError());
    EXPECT_EQ(err.Code(), doc.GetParseError());
    EXPECT_EQ(err.Offset(), doc.GetErrorOffset());
    EXPECT_TRUE(doc.IsObject());
    EXPECT_EQ(doc.MemberCount(), 0u);
}
开发者ID:amandatta16,项目名称:rapidjson,代码行数:19,代码来源:documenttest.cpp

示例15: WriteDataJson

bool ZatData::WriteDataJson()
{
  void* file;
  if (!(file = XBMC->OpenFileForWrite(data_file.c_str(), true)))
  {
    XBMC->Log(LOG_ERROR, "Save data.json failed.");
    return false;
  }

  Document d;
  d.SetObject();

  Value a(kArrayType);
  Document::AllocatorType& allocator = d.GetAllocator();
  for (auto const& item : recordingsData)
  {
    if (!item.second->stillValid)
    {
      continue;
    }

    Value r;
    r.SetObject();
    Value recordingId;
    recordingId.SetString(item.second->recordingId.c_str(),
        item.second->recordingId.length(), allocator);
    r.AddMember("recordingId", recordingId, allocator);
    r.AddMember("playCount", item.second->playCount, allocator);
    r.AddMember("lastPlayedPosition", item.second->lastPlayedPosition,
        allocator);
    a.PushBack(r, allocator);
  }
  d.AddMember("recordings", a, allocator);

  StringBuffer buffer;
  Writer<StringBuffer> writer(buffer);
  d.Accept(writer);
  const char* output = buffer.GetString();
  XBMC->WriteFile(file, output, strlen(output));
  XBMC->CloseFile(file);
  return true;
}
开发者ID:vdrtuxnet,项目名称:pvr.zattoo,代码行数:42,代码来源:ZatData.cpp


注:本文中的Document::GetAllocator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。