本文整理汇总了C++中rapidjson::Value::AddMember方法的典型用法代码示例。如果您正苦于以下问题:C++ Value::AddMember方法的具体用法?C++ Value::AddMember怎么用?C++ Value::AddMember使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rapidjson::Value
的用法示例。
在下文中一共展示了Value::AddMember方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SerializeStaticMeshNode
void JSONSerializer::SerializeStaticMeshNode(rapidjson::Value& nodeValue,
const shared_ptr<StaticMeshNode>& node)
{
const shared_ptr<Mesh>& mesh = node->GetMesh();
ASSERT(mesh->mRawVertexData != nullptr);
nodeValue.AddMember("format", mesh->mFormat->mBinaryFormat, *mAllocator);
nodeValue.AddMember("vertexcount", mesh->mVertexCount, *mAllocator);
nodeValue.AddMember("indexcount", mesh->mIndexCount, *mAllocator);
UINT floatCount = mesh->mVertexCount * mesh->mFormat->mStride / sizeof(float);
float* attribs = reinterpret_cast<float*>(mesh->mRawVertexData);
rapidjson::Value attribArray(rapidjson::kArrayType);
for (UINT i = 0; i < floatCount; i++) {
attribArray.PushBack(double(attribs[i]), *mAllocator);
}
nodeValue.AddMember("vertices", attribArray, *mAllocator);
if (mesh->mIndexCount > 0) {
rapidjson::Value indexArray(rapidjson::kArrayType);
for (UINT i = 0; i < mesh->mIndexCount; i++) {
indexArray.PushBack(UINT(mesh->mIndexData[i]), *mAllocator);
}
nodeValue.AddMember("indices", indexArray, *mAllocator);
}
}
示例2: pack
void etcd_packer::pack(const etcd_key_value &etcd_val, rapidjson::Value &json_val, rapidjson::Document &doc) {
if (0 != etcd_val.create_revision) {
json_val.AddMember("create_revision", etcd_val.create_revision, doc.GetAllocator());
}
if (0 != etcd_val.mod_revision) {
json_val.AddMember("mod_revision", etcd_val.mod_revision, doc.GetAllocator());
}
if (0 != etcd_val.version) {
json_val.AddMember("version", etcd_val.version, doc.GetAllocator());
}
if (0 != etcd_val.lease) {
json_val.AddMember("lease", etcd_val.lease, doc.GetAllocator());
}
if (!etcd_val.key.empty()) {
pack_base64(json_val, "key", etcd_val.key, doc);
}
if (!etcd_val.value.empty()) {
pack_base64(json_val, "value", etcd_val.value, doc);
}
}
示例3:
void
SkillInfo::to_json_value(rapidjson::Document& d, rapidjson::Value& v) const
{
rapidjson::Document::AllocatorType& allocator = d.GetAllocator();
v.SetObject();
// Avoid unused variable warnings
(void)allocator;
if (kind_) {
rapidjson::Value v_kind;
v_kind.SetString(*kind_, allocator);
v.AddMember("kind", v_kind, allocator);
}
if (apiVersion_) {
rapidjson::Value v_apiVersion;
v_apiVersion.SetString(*apiVersion_, allocator);
v.AddMember("apiVersion", v_apiVersion, allocator);
}
if (name_) {
rapidjson::Value v_name;
v_name.SetString(*name_, allocator);
v.AddMember("name", v_name, allocator);
}
}
示例4: jsonifyModule
void jsonifyModule(const Module& module, rapidjson::Value& moduleValue, rapidjson::Document& document){
moduleValue.SetObject();
moduleValue.AddMember("name", module.getName().c_str(), document.GetAllocator());
moduleValue.AddMember("description", module.getDescription().c_str(), document.GetAllocator());
moduleValue.AddMember("type", module.getType().getName().c_str(), document.GetAllocator());
//add inputs
rapidjson::Value inputsValue;
inputsValue.SetObject();
for(unsigned int i=0; i<module.getInputSize(); ++i){
auto inputLink = module.getInput(i);
auto outputLink = inputLink->getOutputLink();
//only add connected links
if(outputLink){
std::string sourceString = outputLink->getOwner().getName() + "." + outputLink->getModuleOutput().getName();
rapidjson::Value source(sourceString.c_str(), document.GetAllocator());
rapidjson::Value inputName(inputLink->getModuleInput().getName().c_str(), document.GetAllocator());
inputsValue.AddMember(inputName, source, document.GetAllocator());
} else {
//add custom unlinked values
rapidjson::Value vectorValue;
vectorValue.SetArray();
auto unlinkedValue = inputLink->getUnlinkedValue();
for(int j=0; j<unlinkedValue.getSignalType().dimensionality; ++j){
vectorValue.PushBack(unlinkedValue[j], document.GetAllocator());
}
rapidjson::Value inputName(inputLink->getModuleInput().getName().c_str(), document.GetAllocator());
inputsValue.AddMember(inputName, vectorValue, document.GetAllocator());
}
}
moduleValue.AddMember("inputs", inputsValue, document.GetAllocator());
}
示例5:
void
BlackboardGraph::to_json_value(rapidjson::Document& d, rapidjson::Value& v) const
{
rapidjson::Document::AllocatorType& allocator = d.GetAllocator();
v.SetObject();
// Avoid unused variable warnings
(void)allocator;
if (kind_) {
rapidjson::Value v_kind;
v_kind.SetString(*kind_, allocator);
v.AddMember("kind", v_kind, allocator);
}
if (apiVersion_) {
rapidjson::Value v_apiVersion;
v_apiVersion.SetString(*apiVersion_, allocator);
v.AddMember("apiVersion", v_apiVersion, allocator);
}
if (dotgraph_) {
rapidjson::Value v_dotgraph;
v_dotgraph.SetString(*dotgraph_, allocator);
v.AddMember("dotgraph", v_dotgraph, allocator);
}
}
示例6: addObjectMember
void addObjectMember(rapidjson::Value &v, const char *name, const JsonSerializable &o,
rapidjson::Document::AllocatorType &allocator)
{
if (o.unnamed())
v.AddMember(name, o.toJson(allocator), allocator);
else
v.AddMember(name, o.name().c_str(), allocator);
}
示例7: SerializeTextureNode
void JSONSerializer::SerializeTextureNode(rapidjson::Value& nodeValue,
const shared_ptr<TextureNode>& node)
{
shared_ptr<Texture> texture = node->Get();
ASSERT(texture->mTexelData);
string b64 = base64_encode((UCHAR*)&(*texture->mTexelData)[0],
UINT((*texture->mTexelData).size()));
nodeValue.AddMember("width", texture->mWidth, *mAllocator);
nodeValue.AddMember("height", texture->mHeight, *mAllocator);
nodeValue.AddMember("type", rapidjson::Value(
EnumMapperA::GetStringFromEnum(TexelTypeMapper, int(texture->mType)), *mAllocator),
*mAllocator);
nodeValue.AddMember("base64", b64, *mAllocator);
}
示例8: SerializeStubNode
void JSONSerializer::SerializeStubNode(
rapidjson::Value& nodeValue, const shared_ptr<StubNode>& node)
{
const string& f = node->mSource.Get();
rapidjson::Value slotValue(rapidjson::kObjectType);
nodeValue.AddMember("source", f, *mAllocator);
}
示例9: pack_string
void etcd_packer::pack_string(rapidjson::Value &json_val, const char *key, const char *val, rapidjson::Document &doc) {
rapidjson::Value k;
rapidjson::Value v;
k.SetString(key, doc.GetAllocator());
v.SetString(val, doc.GetAllocator());
json_val.AddMember(k, v, doc.GetAllocator());
}
示例10: SaveToJSON
void Map::SaveToJSON( rapidjson::Document& document, rapidjson::Value& object )
{
DebugPrintf( "Saving game state..." );
// TODO: Add the ID.
//rapidjson::Value gameIDValue;
//gameIDValue.SetString( mGameID.c_str(), result.GetAllocator() );
//result.AddMember( "id", gameIDValue, result.GetAllocator() );
// Start an array for Units.
rapidjson::Value unitsArray;
unitsArray.SetArray();
DebugPrintf( "Created array!" );
ForEachUnit( [ &document, &object, &unitsArray ]( Unit* unit )
{
// Serialize each Unit.
rapidjson::Value unitJSON;
unitJSON.SetObject();
// Have the Unit serialize its values to JSON.
unit->SaveToJSON( document, unitJSON );
// Add each Unit's JSON to the array.
unitsArray.PushBack( unitJSON, document.GetAllocator() );
});
// Add it to the result.
object.AddMember( "units", unitsArray, document.GetAllocator() );
DebugPrintf( "Added array!" );
}
示例11: fill_backend_backend
/*
* Gets statistics from lowlevel backend and writes it to "backend" section
*/
static void fill_backend_backend(rapidjson::Value &stat_value,
rapidjson::Document::AllocatorType &allocator,
const struct dnet_backend_io *backend,
const dnet_backend_info *config_backend) {
char *json_stat = NULL;
size_t size = 0;
struct dnet_backend_callbacks *cb = backend->cb;
if (cb->storage_stat_json) {
cb->storage_stat_json(cb->command_private, &json_stat, &size);
if (json_stat && size) {
rapidjson::Document backend_value(&allocator);
backend_value.Parse<0>(json_stat);
auto &config_value = backend_value["config"];
config_value.AddMember("group", config_backend->group, allocator);
config_value.AddMember("queue_timeout", config_backend->queue_timeout, allocator);
rapidjson::Document initial_config(&allocator);
initial_config.Parse<0>(config_backend->initial_config.c_str());
backend_value.AddMember("initial_config",
static_cast<rapidjson::Value&>(initial_config),
allocator);
stat_value.AddMember("backend",
static_cast<rapidjson::Value&>(backend_value),
allocator);
}
}
free(json_stat);
}
示例12: fill_backend_status
/*
* Fills status section of one backend
*/
static void fill_backend_status(rapidjson::Value &stat_value,
rapidjson::Document::AllocatorType &allocator,
struct dnet_node *node,
dnet_backend_status &status,
const dnet_backend_info *config_backend) {
backend_fill_status_nolock(node, &status, config_backend);
rapidjson::Value status_value(rapidjson::kObjectType);
status_value.AddMember("state", status.state, allocator);
status_value.AddMember("string_state", dnet_backend_state_string(status.state), allocator);
status_value.AddMember("defrag_state", status.defrag_state, allocator);
status_value.AddMember("string_defrag_state", dnet_backend_defrag_state_string(status.defrag_state), allocator);
rapidjson::Value last_start(rapidjson::kObjectType);
last_start.AddMember("tv_sec", status.last_start.tsec, allocator);
last_start.AddMember("tv_usec", status.last_start.tnsec / 1000, allocator);
status_value.AddMember("last_start", last_start, allocator);
status_value.AddMember("string_last_time", dnet_print_time(&status.last_start), allocator);
status_value.AddMember("last_start_err", status.last_start_err, allocator);
status_value.AddMember("read_only", status.read_only == 1, allocator);
status_value.AddMember("delay", status.delay, allocator);
stat_value.AddMember("status", status_value, allocator);
}
示例13:
void core::wim::auth_parameters::serialize(rapidjson::Value& _node, rapidjson_allocator& _a) const
{
_node.AddMember("login", login_, _a);
_node.AddMember("aimid", aimid_, _a);
_node.AddMember("atoken", a_token_, _a);
_node.AddMember("sessionkey", session_key_, _a);
_node.AddMember("devid", dev_id_, _a);
_node.AddMember("expiredin", (int64_t)exipired_in_, _a);
_node.AddMember("timeoffset", (int64_t)time_offset_, _a);
_node.AddMember("aimsid", aimsid_, _a);
_node.AddMember("fetchurl", fetch_url_, _a);
_node.AddMember(settings_need_show_promo, need_promo_, _a);
}
示例14: ensure_has_object_mem
void ensure_has_object_mem(rapidjson::Value & _val, rapidjson::Value::StringRefType _name, rapidjson::Document & _doc)
{
if (!_val.HasMember(_name)) {
rapidjson::Value v(rapidjson::kObjectType);
_val.AddMember(_name, v, _doc.GetAllocator());
}
RAPIDJSON_ASSERT(_val.FindMember(_name)->value.IsObject());
}
示例15: conversion_error
void
tws::geoarray::write(const dimension_t& dim,
rapidjson::Value& jdim,
rapidjson::Document::AllocatorType& allocator)
{
if(!jdim.IsObject())
throw tws::conversion_error() << tws::error_description("dimension metadata must be a JSON object!");
rapidjson::Value jdim_name(dim.name.c_str(), dim.name.length(), allocator);
jdim.AddMember("name", jdim_name, allocator);
rapidjson::Value jdim_dsc(dim.description.c_str(), dim.description.length(), allocator);
jdim.AddMember("description", jdim_dsc, allocator);
jdim.AddMember("min_idx", dim.min_idx, allocator);
jdim.AddMember("max_idx", dim.max_idx, allocator);
}