本文整理汇总了C++中rapidjson::Document::AddMember方法的典型用法代码示例。如果您正苦于以下问题:C++ Document::AddMember方法的具体用法?C++ Document::AddMember怎么用?C++ Document::AddMember使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rapidjson::Document
的用法示例。
在下文中一共展示了Document::AddMember方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onReload
void RuntimeJsImpl::onReload(const rapidjson::Document &dArgParse, rapidjson::Document &dReplyParse)
{
if (dArgParse.HasMember("modulefiles")){
auto& allocator = dReplyParse.GetAllocator();
rapidjson::Value bodyvalue(rapidjson::kObjectType);
const rapidjson::Value& objectfiles = dArgParse["modulefiles"];
for (rapidjson::SizeType i = 0; i < objectfiles.Size(); i++){
if (!reloadScript(objectfiles[i].GetString())) {
bodyvalue.AddMember(rapidjson::Value(objectfiles[i].GetString(), allocator)
, rapidjson::Value(1)
, allocator);
}
}
if (0 == objectfiles.Size())
{
reloadScript("");
}
dReplyParse.AddMember("body", bodyvalue, dReplyParse.GetAllocator());
}else
{
reloadScript("");
}
dReplyParse.AddMember("code", 0, dReplyParse.GetAllocator());
}
示例2: Process_Heartbeat
void Robot::Process_Heartbeat(rapidjson::Document& jsRequest, rapidjson::Document& jsResponse, string& sResponse)
{
rapidjson::Document::AllocatorType& allocator = jsResponse.GetAllocator();
jsResponse.AddMember("errcode", 0, allocator);
jsResponse.AddMember("errmsg", "ok", allocator);
sResponse = JsonDocToString(jsResponse);
}
示例3: CreateError
bool JsonUtils::CreateError(rapidjson::Document& document, int err, const std::string& message)
{
rapidjson::Document::AllocatorType& allocator = document.GetAllocator();
document.SetObject();
document.AddMember("code", err, allocator);
document.AddMember("message", rapidjson::Value(message.c_str(), allocator), allocator);
}
示例4: jsonServerInfo
void FCServer::jsonServerInfo(rapidjson::Document &message)
{
// Server version
message.AddMember("version", kFCServerVersion, message.GetAllocator());
// Server configuration
message.AddMember("config", rapidjson::kObjectType, message.GetAllocator());
message.DeepCopy(message["config"], mConfig);
}
示例5: onStartDebuger
void RuntimeJsImpl::onStartDebuger(const rapidjson::Document& dArgParse, rapidjson::Document& dReplyParse)
{
if (loadScriptFile(ConfigParser::getInstance()->getEntryFile()))
{
dReplyParse.AddMember("code",0,dReplyParse.GetAllocator());
}
else
{
dReplyParse.AddMember("code",1,dReplyParse.GetAllocator());
}
}
示例6: fillJSON
void GraphIF::fillJSON(rapidjson::Document& jsonDoc,
rapidjson::Document::AllocatorType& allocator, unsigned short depth) {
jsonDoc.AddMember("Number of vertices", vertexSet->size(), allocator);
jsonDoc.AddMember("Number of edges", edgeSet->size(), allocator);
jsonDoc.AddMember("Vertex set",
JSONUtils::getDepthLimitedJSON(vertexSet, allocator, "VertexSetIF",
depth), allocator);
jsonDoc.AddMember("Edge set",
JSONUtils::getDepthLimitedJSON(edgeSet, allocator, "EdgeSetIF",
depth), allocator);
}
示例7: fillJSON
void EdgeSetIF::fillJSON(rapidjson::Document& jsonDoc,
rapidjson::Document::AllocatorType& allocator, unsigned short depth) {
rapidjson::Value edgeSet(rapidjson::kArrayType);
jsonDoc.AddMember("Number of edges", numberOfEdges, allocator);
begin();
while (hasNext()) {
edgeSet.PushBack(
JSONUtils::getDepthLimitedJSON(next(), allocator, "EdgeIF",
depth), allocator);
}
jsonDoc.AddMember("Edge set", edgeSet, allocator);
}
示例8: fillJSON
void VertexSetIF::fillJSON(rapidjson::Document& jsonDoc,
rapidjson::Document::AllocatorType& allocator, unsigned short depth) {
rapidjson::Value vertexSet(rapidjson::kArrayType);
jsonDoc.AddMember("Number of vertices", numberOfVertices, allocator);
begin();
while (hasNext()) {
vertexSet.PushBack(
JSONUtils::getDepthLimitedJSON(next(), allocator, "VertexIF",
depth), allocator);
}
jsonDoc.AddMember("Vertex set", vertexSet, allocator);
}
示例9: jresult
void
tws::wtss::prepare_timeseries_response(const timeseries_request_parameters& parameters,
const timeseries_validated_parameters& vparameters,
rapidjson::Document& doc,
rapidjson::Value& jattributes,
rapidjson::Document::AllocatorType& allocator)
{
// prepare result part in response
rapidjson::Value jresult(rapidjson::kObjectType);
jresult.AddMember("attributes", jattributes, allocator);
// add timeline in the response
rapidjson::Value jtimeline(rapidjson::kArrayType);
std::size_t init_pos = vparameters.timeline->pos(vparameters.start_time_idx);
std::size_t fin_pos = vparameters.timeline->pos(vparameters.end_time_idx);
tws::core::copy_string_array(std::begin(vparameters.timeline->time_points()) + init_pos,
std::begin(vparameters.timeline->time_points()) + (fin_pos + 1),
jtimeline, allocator);
jresult.AddMember("timeline", jtimeline, allocator);
// add the pixel center location in response
rapidjson::Value jcenter(rapidjson::kObjectType);
jcenter.AddMember("latitude", vparameters.pixel_center_latitude, allocator);
jcenter.AddMember("longitude", vparameters.pixel_center_longitude, allocator);
jresult.AddMember("center_coordinates", jcenter, allocator);
// prepare the query part in response
rapidjson::Value jquery(rapidjson::kObjectType);
jquery.AddMember("coverage", parameters.cv_name.c_str(), allocator);
rapidjson::Value jqattributes(rapidjson::kArrayType);
tws::core::copy_string_array(parameters.queried_attributes.begin(), parameters.queried_attributes.end(), jqattributes, allocator);
jquery.AddMember("attributes", jqattributes, allocator);
jquery.AddMember("latitude", parameters.latitude, allocator);
jquery.AddMember("longitude", parameters.longitude, allocator);
doc.AddMember("result", jresult, allocator);
doc.AddMember("query", jquery, allocator);
}
示例10: jsonDeviceMessage
void FCServer::jsonDeviceMessage(rapidjson::Document &message)
{
/*
* If this message has a "device" member and doesn't match any server-global
* message types, give each matching device a chance to handle it.
*/
const Value &device = message["device"];
bool matched = false;
if (device.IsObject()) {
for (unsigned i = 0; i != mUSBDevices.size(); i++) {
USBDevice *usbDev = mUSBDevices[i];
if (usbDev->matchConfiguration(device)) {
matched = true;
usbDev->writeMessage(message);
if (message.HasMember("error"))
break;
}
}
}
if (!matched) {
message.AddMember("error", "No matching device found", message.GetAllocator());
}
}
示例11: addOptionsToDoc
void MainWindow::addOptionsToDoc(rapidjson::Document &doc) {
rapidjson::Value options(rapidjson::kObjectType);
if (nodalDispCheckBox->isChecked()) {
options.AddMember("save_nodal_displacements", true, doc.GetAllocator());
rapidjson::Value rj_val;
std::string val = nodalDispLineEdit->displayText().toStdString();
rj_val.SetString(val.c_str(), val.length(), doc.GetAllocator());
options.AddMember("nodal_displacements_filename", rj_val, doc.GetAllocator());
}
if (nodalForcesCheckBox->isChecked()) {
options.AddMember("save_nodal_forces", true, doc.GetAllocator());
rapidjson::Value rj_val;
std::string val = nodalForcesLineEdit->displayText().toStdString();
rj_val.SetString(val.c_str(), val.length(), doc.GetAllocator());
options.AddMember("nodal_forces_filename", rj_val, doc.GetAllocator());
}
if (tieForcesCheckBox->isChecked()) {
options.AddMember("save_tie_forces", true, doc.GetAllocator());
rapidjson::Value rj_val;
std::string val = tieForcesLineEdit->displayText().toStdString();
rj_val.SetString(val.c_str(), val.length(), doc.GetAllocator());
options.AddMember("ties_forces_filename", rj_val, doc.GetAllocator());
}
if (reportCheckBox->isChecked()) {
options.AddMember("save_report", true, doc.GetAllocator());
rapidjson::Value rj_val;
std::string val = tieForcesLineEdit->displayText().toStdString();
rj_val.SetString(val.c_str(), val.length(), doc.GetAllocator());
options.AddMember("report_filename", rj_val, doc.GetAllocator());
}
options.AddMember("verbose", true, doc.GetAllocator());
doc.AddMember("options", options, doc.GetAllocator());
}
示例12: Serialize
void CPlayer::Serialize(string name, rapidjson::Document& root)
{
rapidjson::Value json;
json.SetObject();
_SerializeFieldI64(Role_Attrib_ID, root, root);
_SerializeFieldI64(Role_Attrib_UserID, root, root);
_SerializeFieldInt(Role_Attrib_TemplateID, root, root);
_SerializeFieldStr(Role_Attrib_Name, root, root);
_SerializeFieldI64(Role_Attrib_SceneID, json, root);
_SerializeFieldInt(Role_Attrib_Position, json, root);
_SerializeFieldInt(Role_Attrib_Vocation, json, root);
_SerializeFieldInt(Role_Attrib_Sex, json, root);
_SerializeFieldInt(Role_Attrib_Level, json, root);
_SerializeFieldI64(Role_Attrib_Exp, json, root);
_SerializeFieldInt(Role_Attrib_GoldCoin, json, root);
_SerializeFieldInt(Role_Attrib_SilverCoin, json, root);
_SerializeFieldInt(Role_Attrib_Fighting, json, root);
_SerializeFieldStr(Role_Attrib_CreateTime, json, root);
_SerializeFieldStr(Role_Attrib_LoginTime, json, root);
_SerializeFieldStr(Role_Attrib_LogoutTime, json, root);
root.AddMember(name.c_str(), root.GetAllocator(), json, root.GetAllocator());
}
示例13: threadsSummary
void Workers::threadsSummary(rapidjson::Document &doc)
{
uv_mutex_lock(&m_mutex);
const uint64_t pages[2] = { m_status.hugePages, m_status.pages };
const uint64_t memory = m_status.ways * xmrig::cn_select_memory(m_status.algo);
uv_mutex_unlock(&m_mutex);
auto &allocator = doc.GetAllocator();
rapidjson::Value hugepages(rapidjson::kArrayType);
hugepages.PushBack(pages[0], allocator);
hugepages.PushBack(pages[1], allocator);
doc.AddMember("hugepages", hugepages, allocator);
doc.AddMember("memory", memory, allocator);
}
示例14: onStartDebuger
void RuntimeLuaImpl::onStartDebuger(const rapidjson::Document& dArgParse, rapidjson::Document& dReplyParse)
{
// Lua
char szDebugArg[1024] = {0};
sprintf(szDebugArg, "require('debugger')(%s,'%s')",dArgParse["debugcfg"].GetString(), "");
startScript(szDebugArg);
dReplyParse.AddMember("code", 0, dReplyParse.GetAllocator());
}
示例15: fillJSON
void EdgeIF::fillJSON(rapidjson::Document& jsonDoc,
rapidjson::Document::AllocatorType& allocator, unsigned short depth) {
jsonDoc.AddMember("Edge cost", edgeCost, allocator);
jsonDoc.AddMember("Connection type",
rapidjson::StringRef(
EnumUtils::getEdgeConnectionTypeString(connectionType)),
allocator);
jsonDoc.AddMember("Is hidden?",
rapidjson::StringRef(EnumUtils::getVisibilityString(visibility)),
allocator);
jsonDoc.AddMember("u",
JSONUtils::getDepthLimitedJSON(edgeConnection.first, allocator,
"VertexIF", depth), allocator);
jsonDoc.AddMember("v",
JSONUtils::getDepthLimitedJSON(edgeConnection.second, allocator,
"VertexIF", depth), allocator);
}