本文整理汇总了C++中rapidjson::Document::HasMember方法的典型用法代码示例。如果您正苦于以下问题:C++ Document::HasMember方法的具体用法?C++ Document::HasMember怎么用?C++ Document::HasMember使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rapidjson::Document
的用法示例。
在下文中一共展示了Document::HasMember方法的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: Create
void TrackBrakeSimple::Create(const rapidjson::Document& d) {
// Read top-level data
assert(d.HasMember("Type"));
assert(d.HasMember("Template"));
assert(d.HasMember("Name"));
SetName(d["Name"].GetString());
// Read maximum braking torque
m_maxtorque = d["Maximum Torque"].GetDouble();
}
示例3: Create
void SprocketBand::Create(const rapidjson::Document& d) {
// Invoke base class method.
ChPart::Create(d);
// Read inertia properties
m_num_teeth = d["Number Teeth"].GetInt();
m_gear_mass = d["Gear Mass"].GetDouble();
m_gear_inertia = LoadVectorJSON(d["Gear Inertia"]);
m_axle_inertia = d["Axle Inertia"].GetDouble();
m_separation = d["Gear Separation"].GetDouble();
// Read profile information
assert(d.HasMember("Profile"));
m_gear_outer_radius = d["Profile"]["Outer Radius"].GetDouble();
m_gear_base_width = d["Profile"]["Base Width"].GetDouble();
m_gear_tip_width = d["Profile"]["Tip Width"].GetDouble();
m_gear_tooth_depth = d["Profile"]["Tooth Depth"].GetDouble();
m_gear_arc_radius = d["Profile"]["Arc Radius"].GetDouble();
m_gear_guide_wheel_width = d["Profile"]["Guide Wheel Width"].GetDouble();
m_gear_guide_wheel_gap = d["Profile"]["Guide Wheel Gap"].GetDouble();
m_gear_RA = d["Profile"]["Assembly Radius"].GetDouble();
// Read contact material data
assert(d.HasMember("Contact Material"));
float mu = d["Contact Material"]["Coefficient of Friction"].GetFloat();
float cr = d["Contact Material"]["Coefficient of Restitution"].GetFloat();
SetContactFrictionCoefficient(mu);
SetContactRestitutionCoefficient(cr);
if (d["Contact Material"].HasMember("Properties")) {
float ym = d["Contact Material"]["Properties"]["Young Modulus"].GetFloat();
float pr = d["Contact Material"]["Properties"]["Poisson Ratio"].GetFloat();
SetContactMaterialProperties(ym, pr);
}
if (d["Contact Material"].HasMember("Coefficients")) {
float kn = d["Contact Material"]["Coefficients"]["Normal Stiffness"].GetFloat();
float gn = d["Contact Material"]["Coefficients"]["Normal Damping"].GetFloat();
float kt = d["Contact Material"]["Coefficients"]["Tangential Stiffness"].GetFloat();
float gt = d["Contact Material"]["Coefficients"]["Tangential Damping"].GetFloat();
SetContactMaterialCoefficients(kn, gn, kt, gt);
}
// Read sprocket visualization
if (d.HasMember("Visualization")) {
assert(d["Visualization"].HasMember("Mesh Filename"));
assert(d["Visualization"].HasMember("Mesh Name"));
m_meshFile = d["Visualization"]["Mesh Filename"].GetString();
m_meshName = d["Visualization"]["Mesh Name"].GetString();
m_has_mesh = true;
}
}
示例4: ProcessJSON
// -----------------------------------------------------------------------------
// Process the specified JSON document and load tire specification
// -----------------------------------------------------------------------------
void FEATire::ProcessJSON(const rapidjson::Document& d) {
// Read top-level data
assert(d.HasMember("Type"));
assert(d.HasMember("Template"));
assert(d.HasMember("Name"));
SetName(d["Name"].GetString());
// Read geometric dimensions
m_tire_radius = d["Tire Radius"].GetDouble();
m_rim_radius = d["Rim Radius"].GetDouble();
m_rim_width = d["Rim Width"].GetDouble();
// Read contact material data
assert(d.HasMember("Contact Material"));
float mu = d["Contact Material"]["Coefficient of Friction"].GetFloat();
float cr = d["Contact Material"]["Coefficient of Restitution"].GetFloat();
SetContactFrictionCoefficient(mu);
SetContactRestitutionCoefficient(cr);
if (d["Contact Material"].HasMember("Properties")) {
float ym = d["Contact Material"]["Properties"]["Young Modulus"].GetFloat();
float pr = d["Contact Material"]["Properties"]["Poisson Ratio"].GetFloat();
SetContactMaterialProperties(ym, pr);
}
if (d["Contact Material"].HasMember("Coefficients")) {
float kn = d["Contact Material"]["Coefficients"]["Normal Stiffness"].GetFloat();
float gn = d["Contact Material"]["Coefficients"]["Normal Damping"].GetFloat();
float kt = d["Contact Material"]["Coefficients"]["Tangential Stiffness"].GetFloat();
float gt = d["Contact Material"]["Coefficients"]["Tangential Damping"].GetFloat();
SetContactMaterialCoefficients(kn, gn, kt, gt);
}
// Read continuum material data
double E = d["Continuum Material"]["Elasticity Modulus"].GetDouble();
double nu = d["Continuum Material"]["Poisson Ratio"].GetDouble();
double rd = d["Continuum Material"]["Rayleigh Damping"].GetDouble();
double density = d["Continuum Material"]["Density"].GetDouble();
m_material = std::make_shared<ChContinuumElastic>();
m_material->Set_E(E);
m_material->Set_v(nu);
m_material->Set_RayleighDampingK(rd);
m_material->Set_density(density);
// Default tire pressure
m_default_pressure = d["Default Pressure"].GetDouble();
// Name of Abaqus input file
m_input_file = d["Abaqus Mesh Filename"].GetString();
}
示例5: handle_method_token_auth
void handle_method_token_auth(per_session_data_eqemu *session, rapidjson::Document &document, std::string &method)
{
CheckParams(1, "[token]");
if(!document.HasMember("params") || document.HasMember("params") && document["params"].Empty() && !document["params"].IsString())
return;
session->auth = document["params"][(rapidjson::SizeType)0].GetString();
if (!CheckTokenAuthorization(session)) {
WriteWebCallResponseBoolean(session, document, false, false);
} else {
WriteWebCallResponseBoolean(session, document, true, false);
}
}
示例6: loadVersion
void Manifest::loadVersion(const rapidjson::Document &json)
{
// Retrieve remote manifest url
if ( json.HasMember(KEY_MANIFEST_URL) && json[KEY_MANIFEST_URL].IsString() )
{
_remoteManifestUrl = json[KEY_MANIFEST_URL].GetString();
}
// Retrieve remote version url
if ( json.HasMember(KEY_VERSION_URL) && json[KEY_VERSION_URL].IsString() )
{
_remoteVersionUrl = json[KEY_VERSION_URL].GetString();
}
// Retrieve local version
if ( json.HasMember(KEY_VERSION) && json[KEY_VERSION].IsString() )
{
_version = json[KEY_VERSION].GetString();
}
// Retrieve local group version
if ( json.HasMember(KEY_GROUP_VERSIONS) )
{
const rapidjson::Value& groupVers = json[KEY_GROUP_VERSIONS];
if (groupVers.IsObject())
{
for (rapidjson::Value::ConstMemberIterator itr = groupVers.MemberBegin(); itr != groupVers.MemberEnd(); ++itr)
{
std::string group = itr->name.GetString();
std::string version = "0";
if (itr->value.IsString())
{
version = itr->value.GetString();
}
_groups.push_back(group);
_groupVer.emplace(group, version);
}
}
}
// Retrieve local engine version
if ( json.HasMember(KEY_ENGINE_VERSION) && json[KEY_ENGINE_VERSION].IsString() )
{
_engineVer = json[KEY_ENGINE_VERSION].GetString();
}
_versionLoaded = true;
}
示例7: loadJSONsettingsFromDoc
int SettingRegistry::loadJSONsettingsFromDoc(rapidjson::Document& json_document, SettingsBase* settings_base, bool warn_duplicates)
{
if (!json_document.IsObject())
{
cura::logError("JSON file is not an object.\n");
return 3;
}
{ // handle machine name
std::string machine_name = "Unknown";
if (json_document.HasMember("name"))
{
const rapidjson::Value& machine_name_field = json_document["name"];
if (machine_name_field.IsString())
{
machine_name = machine_name_field.GetString();
}
}
SettingConfig& machine_name_setting = addSetting("machine_name", "Machine Name");
machine_name_setting.setDefault(machine_name);
machine_name_setting.setType("string");
}
if (json_document.HasMember("settings"))
{
std::list<std::string> path;
handleChildren(json_document["settings"], path, settings_base, warn_duplicates);
}
if (json_document.HasMember("overrides"))
{
const rapidjson::Value& json_object_container = json_document["overrides"];
for (rapidjson::Value::ConstMemberIterator override_iterator = json_object_container.MemberBegin(); override_iterator != json_object_container.MemberEnd(); ++override_iterator)
{
std::string setting = override_iterator->name.GetString();
SettingConfig* conf = getSettingConfig(setting);
if (!conf) //Setting could not be found.
{
logWarning("Trying to override unknown setting %s.\n", setting.c_str());
continue;
}
_loadSettingValues(conf, override_iterator, settings_base);
}
}
return 0;
}
示例8: read_to_map
ValueMap Json_Parser::read_to_map(rapidjson::Document &doc,const char*keyname){
rapidjson::Value va;
ValueMap jmap;
if (doc.HasMember(keyname)) {
va=doc[keyname];
if (va.IsBool()) {
const bool flag=va.GetBool();
jmap[keyname]=flag;
}
else if (va.IsDouble()) {
const double flag=va.GetDouble();
jmap[keyname]=flag;
}
else if (va.IsInt()) {
const int flag=va.GetInt();
jmap[keyname]=flag;
}
else if (va.IsString())
{
const std::string flag=va.GetString();
jmap[keyname]=Value(flag);
}
else if (va.IsNull()) {
jmap[keyname]=nullptr;
}
else if(va.IsObject())
{
cocos2d::ValueMap temp;
auto it=va.MemberBegin();
for (;it!=va.MemberEnd();it++) {
if (va.HasMember(it->name)) {
read_to_map(temp,va,it->name.GetString());
}
}
jmap[keyname]=Value(temp);
// CCLOG("map1层:%lu",temp.size());
}
else if(va.IsArray())
{
cocos2d::ValueVector temp;
for (int i=0; i<va.Size();i++) {
read_to_map_for_array(temp,va[i],i);
}
CCLOG("==%s,size:%lu",keyname,temp.size());
// CCLOG("ttt:%lu",ttt.size());
CCLOG("jma:%lu",jmap.size());
jmap[keyname]=Value(temp);
//ttt[keyname]=Value(temp);
CCLOG("==");
// CCLOG("vector1层:%lu",temp.size());
}
}
return jmap;
}
示例9: 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());
}
}
示例10: WriteWebCallResponseBoolean
void WriteWebCallResponseBoolean(per_session_data_eqemu *session, rapidjson::Document &doc, bool result, bool error, bool send_no_id) {
if (doc.HasMember("id") || send_no_id) {
rapidjson::StringBuffer s;
rapidjson::Writer<rapidjson::StringBuffer> writer(s);
writer.StartObject();
writer.String("id");
if (send_no_id) {
writer.Null();
}
else {
writer.String(doc["id"].GetString());
}
writer.String("result");
writer.StartObject();
writer.String("value");
writer.Bool(result);
writer.EndObject();
writer.String("error");
if (error) {
writer.Bool(true);
}
else {
writer.Null();
}
writer.EndObject();
session->send_queue->push_back(s.GetString());
}
}
示例11: Process_Status
void Robot::Process_Status(rapidjson::Document& jsRequest)
{
if (jsRequest.HasMember("robot_info") && jsRequest["robot_info"].IsObject())
{
m_sRobotStatus = JsonValueToString(jsRequest["robot_info"]);
}
}
示例12: Process_RequestCustomer
void Robot::Process_RequestCustomer(rapidjson::Document& jsRequest)
{
if (jsRequest.HasMember("body") && jsRequest["body"].IsObject())
{
rapidjson::Value& body = jsRequest["body"];
if (body.HasMember("question") && body["question"].IsObject())
{
rapidjson::Value& question = body["question"];
rapidjson::Document request2Session;
request2Session.SetObject();
rapidjson::Document::AllocatorType& allocator2A = request2Session.GetAllocator();
request2Session.AddMember("msgid", "request_customer", allocator2A);
rapidjson::Value jstmp;
jstmp.SetString(m_sID.c_str(), allocator2A);
request2Session.AddMember("robot_id", jstmp, allocator2A);
request2Session.AddMember("question", question, allocator2A);
string sNotify = JsonDocToString(request2Session);
vector<WebSocketSessionPtr> arrSession;
RobotService::instance().m_SessionManager.GetAllSession(arrSession);
for (vector<WebSocketSessionPtr>::iterator it = arrSession.begin(); it!=arrSession.end(); it++)
{
WebSocketSessionPtr spSession = *it;
spSession->SendNotify(sNotify);
}
}
else
{
log.debug("Process_RequestCustomer failed,no question node!");
}
}
}
示例13: _CheckError
// OPERATIONS
void _CheckError() {
if (document_.HasMember(kErrorCode)) {
throw etcd::ReplyException(document_[kErrorCode].GetInt(),
document_[kMessage].GetString(),
document_[kCause].GetString());
}
}
示例14: createColumnVectorFromJSON
ColumnVector createColumnVectorFromJSON(const rapidjson::Document &config_doc, std::string key, unsigned int size) {
ColumnVector col_vec(size);
if (config_doc.HasMember(key.c_str())) {
std::vector< std::vector<double> > vec;
createVectorFromJSON(config_doc, key, vec);
if (vec.size() != size) {
throw std::runtime_error(
(boost::format("Key specified by %s does not have the required %d values. %d entries were parsed.")
% key % size % vec.size()).str()
);
}
for (int i = 0; i < size; ++i) {
if (vec[i].size() != 1) {
throw std::runtime_error(
(boost::format("Row %d in the file specified by %s has %d values. There should only be one nodal value per line.")
% i % key % size % vec[i].size()).str()
);
}
col_vec[i] = vec[i][0];
}
}
else {
col_vec.setZero();
}
return col_vec;
}
示例15: runtime_error
JSON_API Vec3i read_Vec3i(rapidjson::Document const &d, char const *name, Vec3i const &def)
{
if(d.HasMember(name))
{
if(!d[name].IsArray())
{
std::stringstream str;
str << "ERROR [read_Vec3i]: \"" << name << "\" should be an array";
throw std::runtime_error(str.str());
}
if(d[name].Size()!=3)
{
std::stringstream str;
str << "ERROR [read_Vec3i]: wrong array size for \"" << name <<"\"!";
throw std::runtime_error(str.str());
}
for(rapidjson::SizeType i = 0; i < d[name].Size(); i++)
{
if(!d[name][i].IsInt())
{
std::stringstream str;
str << "ERROR [read_Vec3i]: array \"" << name <<"\" does not contain integers!";
throw std::runtime_error(str.str());
}
}
return Vec3i(d[name][0].GetInt(), d[name][1].GetInt(), d[name][2].GetInt());
}
return def;
}