本文整理汇总了C++中json::Value::removeMember方法的典型用法代码示例。如果您正苦于以下问题:C++ Value::removeMember方法的具体用法?C++ Value::removeMember怎么用?C++ Value::removeMember使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类json::Value
的用法示例。
在下文中一共展示了Value::removeMember方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void my::GateServer::on_http_req(http::Connection* connPtr, Json::Value& reqJson)
{
//proto 和 player_id可夹带在header中带过来
//如何判断是gm后台的请求还是玩家请求!remote_ip?加密?session_id
int protoId = 0;
int playerId = 0;
try
{
protoId = boost::lexical_cast<int, std::string>(reqJson["proto"].asString());
playerId = boost::lexical_cast<int, std::string>(reqJson["playerId"].asString());
}
catch (std::exception& e)
{
LogE << "caught exception:" << e.what() << LogEnd;
}
LogW << "playerId:" << playerId << LogEnd;
NetMessage msg;
msg.setProto(protoId);
msg.setNetId(connPtr->get_connection_id());
msg.setPlayerId(playerId);
reqJson.removeMember("proto");
reqJson.removeMember("player_id");
std::string msgStr = reqJson.toStyledString();
LogW << msgStr << LogEnd;
msg.setMessage(msgStr);
m_pGameConn->sendMessage(msg);
}
示例2: sendLocalSDP
void SignalingWebSocketPeer::sendLocalSDP(std::string type, std::string sdp) {
Json::StyledWriter writer;
Json::Value message;
message["type"] = type;
if(sdp.length() > 800) {
for(int i=0; i<sdp.length(); i+=800) {
int n = MIN(sdp.length()-i+1,800);
message["sdpPartial"] = sdp.substr(i, n);
std::string msg = writer.write(message);
send(msg.c_str());
}
message.removeMember("sdpPartial");
message["endSdp"] = "yes";
std::string msg = writer.write(message);
send(msg.c_str());
}
else {
message["sdp"] = sdp;
std::string msg = writer.write(message);
send(msg.c_str());
}
}
示例3: if
std::vector<Stage *> PipelineReaderJSON::extractInputs(Json::Value& node,
TagMap& tags)
{
std::vector<Stage *> inputs;
std::string filename;
if (node.isMember("inputs"))
{
Json::Value& val = node["inputs"];
if (val.isString())
handleInputTag(val.asString(), tags, inputs);
else if (val.isArray())
{
for (const Json::Value& input : node["inputs"])
{
if (!input.isString())
throw pdal_error("JSON pipeline: 'inputs' tag must "
" be specified as a string or array of strings.");
handleInputTag(input.asString(), tags, inputs);
}
}
else
throw pdal_error("JSON pipeline: 'inputs' tag must "
" be specified as a string or array of strings.");
node.removeMember("inputs");
if (node.isMember("inputs"))
throw pdal_error("JSON pipeline: found duplicate 'inputs' "
"entry in stage definition.");
}
return inputs;
}
示例4: return
/***************************
* get stream by id
* on a specific port
*
**************************/
trex_rpc_cmd_rc_e
TrexRpcCmdGetStream::_run(const Json::Value ¶ms, Json::Value &result) {
uint8_t port_id = parse_port(params, result);
TrexStatelessPort *port = get_stateless_obj()->get_port_by_id(port_id);
bool get_pkt = parse_bool(params, "get_pkt", result);
uint32_t stream_id = parse_int(params, "stream_id", result);
TrexStream *stream = port->get_stream_by_id(stream_id);
if (!stream) {
std::stringstream ss;
ss << "stream id " << stream_id << " on port " << (int)port_id << " does not exists";
generate_execute_err(result, ss.str());
}
/* return the stored stream json (instead of decoding it all over again) */
Json::Value j = stream->get_stream_json();
if (!get_pkt) {
j.removeMember("packet");
}
result["result"]["stream"] = j;
return (TREX_RPC_CMD_OK);
}
示例5: outputFieldCounts
//Makes a JSON file that contains only the fieldnames and their corresponding bubble counts.
bool MarkupForm::outputFieldCounts(const char* bubbleVals, const char* outputPath){
return false; //I don't think this gets used.
Json::Value bvRoot;
if( !parseJsonFromFile(bubbleVals, bvRoot) ) return false;
Json::Value fields = bvRoot["fields"];
for ( size_t i = 0; i < fields.size(); i++ ) {
Json::Value field = fields[i];
Json::Value segments = field["segments"];
int counter = 0;
for ( size_t j = 0; j < segments.size(); j++ ) {
Json::Value segment = segments[j];
const Json::Value bubbles = segment["bubbles"];
for ( size_t k = 0; k < bubbles.size(); k++ ) {
const Json::Value bubble = bubbles[k];
if(bubble["value"].asBool()){
counter++;
}
}
}
field["count"] = counter;
field.removeMember("segments");
}
ofstream outfile(outputPath, ios::out | ios::binary);
outfile << bvRoot;
outfile.close();
return true;
}
示例6: GetSchemaCollection
Json::Value MongoDbAdapter::GetSchemaCollection()
{
mongocxx::instance inst{};
mongocxx::client conn{mongocxx::uri{}};
bsoncxx::stdx::string_view dbName("StorageTestDB");
mongocxx::database database = conn[dbName];
auto cursor = database["schemas"].find({});
Json::Value schemas;
Json::Value array;
for (auto&& doc : cursor) {
string json =bsoncxx::to_json(doc);
std::cout << json << std::endl;
Json::Value parsedFromString;
Json::Reader reader;
bool parsingSuccessful = reader.parse(json, parsedFromString);
if (parsingSuccessful)
{
parsedFromString.removeMember("_id"); // Hide the BSON id.
array.append(parsedFromString);
}
}
schemas["Schemas"] = array;
return schemas;
}
示例7: GetSchema
Json::Value MongoDbAdapter::GetSchema(string name)
{
mongocxx::instance inst{};
mongocxx::client conn{mongocxx::uri{}};
bsoncxx::stdx::string_view dbName("StorageTestDB");
mongocxx::database database = conn[dbName];
auto cursor = database["schemas"].find( bsoncxx::builder::stream::document{} << "SchemaName" << name<< bsoncxx::builder::stream::finalize);
for (auto&& doc : cursor) {
string json =bsoncxx::to_json(doc);
std::cout << json << std::endl;
Json::Value parsedFromString;
Json::Reader reader;
bool parsingSuccessful = reader.parse(json, parsedFromString);
if (parsingSuccessful)
{
parsedFromString.removeMember("_id"); // Hide the BSON id.
return parsedFromString;
}
}
return Json::nullValue;
}
示例8: pdal_error
std::vector<Stage *> PipelineReaderJSON::extractInputs(Json::Value& node,
TagMap& tags)
{
std::vector<Stage *> inputs;
std::string filename;
if (node.isMember("inputs"))
{
Json::Value& val = node["filename"];
if (!val.isNull())
{
for (const Json::Value& input : node["inputs"])
{
if (input.isString())
{
std::string tag = input.asString();
auto ii = tags.find(tag);
if (ii == tags.end())
throw pdal_error("JSON pipeline: Invalid pipeline: "
"undefined stage tag '" + tag + "'.");
else
inputs.push_back(ii->second);
}
else
throw pdal_error("JSON pipeline: 'inputs' tag must "
" be specified as a string.");
}
}
node.removeMember("inputs");
if (node.isMember("inputs"))
throw pdal_error("JSON pipeline: found duplicate 'inputs' "
"entry in stage definition.");
}
return inputs;
}
示例9: extractTag
std::string PipelineReaderJSON::extractTag(Json::Value& node, TagMap& tags)
{
std::string tag;
if (node.isMember("tag"))
{
Json::Value& val = node["tag"];
if (!val.isNull())
{
if (val.isString())
{
tag = val.asString();
if (tags.find(tag) != tags.end())
throw pdal_error("JSON pipeline: duplicate tag '" +
tag + "'.");
}
else
throw pdal_error("JSON pipeline: 'tag' must be "
"specified as a string.");
}
node.removeMember("tag");
if (node.isMember("tag"))
throw pdal_error("JSON pipeline: found duplicate 'tag' "
"entry in stage definition.");
}
return tag;
}
示例10: extractTag
std::string PipelineReaderJSON::extractTag(Json::Value& node, TagMap& tags)
{
std::string tag;
if (node.isMember("tag"))
{
Json::Value& val = node["tag"];
if (!val.isNull())
{
if (val.isString())
{
tag = val.asString();
if (tags.find(tag) != tags.end())
throw pdal_error("JSON pipeline: duplicate tag '" +
tag + "'.");
}
else
throw pdal_error("JSON pipeline: tag must be "
"specified as a string.");
}
node.removeMember("tag");
if (node.isMember("tag"))
throw pdal_error("JSON pipeline: found duplicate 'tag' "
"entry in stage definition.");
std::string::size_type pos = 0;
if (!Stage::parseTagName(tag, pos) || pos != tag.size())
throw pdal_error("JSON pipeline: Invalid tag name '" + tag + "'. "
"Must start with letter. Remainder can be letters, "
"digits or underscores.");
}
return tag;
}
示例11: CommandToMethod
Json::Value RPCHandler::CommandToMethod(Json::Value params) {
const std::string commandName = "command";
Json::Value newParams;
newParams["method"] = params[commandName];
params.removeMember(commandName);
newParams["params"] = Json::arrayValue;
newParams["params"].append(params);
return newParams;
}
示例12: loadObject
reObject* reAssetLoader::loadObject( std::string& fileName, bool asRef )
{
reObject* node = NULL;
ifstream fs(filePath(fileName).c_str(), ios::in);
if (!fs.fail())
{
Json::Reader reader;
Json::Value root;
reader.parse(fs, root);
if (!asRef)
{
root.removeMember("path");
root.removeMember("isReference");
}
node = loadObject(reVar(root));
fs.close();
}
return node;
}
示例13: extractFilename
std::string PipelineReaderJSON::extractFilename(Json::Value& node)
{
std::string filename;
if (node.isMember("filename"))
{
Json::Value& val = node["filename"];
if (!val.isNull())
{
if (val.isString())
filename = val.asString();
else
throw pdal_error("JSON pipeline: 'filename' must be "
"specified as a string.");
}
node.removeMember("filename");
if (node.isMember("filename"))
throw pdal_error("JSON pipeline: found duplicate 'filename' "
"entry in stage definition.");
}
return filename;
}
示例14: extractType
std::string PipelineReaderJSON::extractType(Json::Value& node)
{
std::string type;
if (node.isMember("type"))
{
Json::Value& val = node["type"];
if (!val.isNull())
{
if (val.isString())
type = val.asString();
else
throw pdal_error("JSON pipeline: 'type' must be specified as "
"a string.");
}
node.removeMember("type");
if (node.isMember("type"))
throw pdal_error("JSON pipeline: found duplicate 'type' "
"entry in stage definition.");
}
return type;
}
示例15: return
/***************************
* get all streams
*
**************************/
trex_rpc_cmd_rc_e
TrexRpcCmdGetAllStreams::_run(const Json::Value ¶ms, Json::Value &result) {
uint8_t port_id = parse_byte(params, "port_id", result);
bool get_pkt = parse_bool(params, "get_pkt", result);
if (port_id >= get_stateless_obj()->get_port_count()) {
std::stringstream ss;
ss << "invalid port id - should be between 0 and " << (int)get_stateless_obj()->get_port_count() - 1;
generate_execute_err(result, ss.str());
}
TrexStatelessPort *port = get_stateless_obj()->get_port_by_id(port_id);
std::vector <TrexStream *> streams;
port->get_stream_table()->get_object_list(streams);
Json::Value streams_json = Json::objectValue;
for (auto stream : streams) {
Json::Value j = stream->get_stream_json();
/* should we include the packet as well ? */
if (!get_pkt) {
j.removeMember("packet");
}
std::stringstream ss;
ss << stream->m_stream_id;
streams_json[ss.str()] = j;
}
result["result"]["streams"] = streams_json;
return (TREX_RPC_CMD_OK);
}