本文整理汇总了C++中rapidjson::Document::Size方法的典型用法代码示例。如果您正苦于以下问题:C++ Document::Size方法的具体用法?C++ Document::Size怎么用?C++ Document::Size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rapidjson::Document
的用法示例。
在下文中一共展示了Document::Size方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: analyzeDataMission
void TopwoData::analyzeDataMission(rapidjson::Document& doc)
{
DataMission* mission_data = NULL;
for (int i = 0; i < (int)doc.Size(); i++)
{
mission_data = DataMission::create();
if (doc[i].HasMember("ID") && doc[i]["ID"].IsDouble())
mission_data->setId((int)doc[i]["ID"].GetDouble());
if (doc[i].HasMember("TY") && doc[i]["TY"].IsDouble())
mission_data->setType((int)doc[i]["TY"].GetDouble());
if (doc[i].HasMember("RE") && doc[i]["RE"].IsDouble())
mission_data->setReward((int)doc[i]["RE"].GetDouble());
if (doc[i].HasMember("TI") && doc[i]["TI"].IsString())
mission_data->setTitle(CCString::create(doc[i]["TI"].GetString()));
if (doc[i].HasMember("CO") && doc[i]["CO"].IsString())
mission_data->setContent(CCString::create(doc[i]["CO"].GetString()));
if (doc[i].HasMember("MI") && doc[i]["MI"].IsString())
mission_data->setMission(CCString::create(doc[i]["MI"].GetString()));
if (doc[i].HasMember("TA") && doc[i]["TA"].IsDouble())
mission_data->setTarget(doc[i]["TA"].GetDouble());
if (doc[i].HasMember("WO") && doc[i]["WO"].IsDouble())
mission_data->setWooer((int)doc[i]["WO"].GetDouble());
addDataMissionToArray(mission_data);
}
}
示例2: initIdTable
void BlackCity::initIdTable(rapidjson::Document &_doc){
if (_doc.IsArray()){
int size = _doc.Size();
int objId;
for (int i = 0; i<size; i++) {
objId =DICTOOL->getIntValue_json(_doc[i], "ID");
idTable.insert(std::make_pair(objId, i));
}
}
}
示例3: analyzeDataSection
void TopwoData::analyzeDataSection(rapidjson::Document& doc)
{
DataSection* chapter_data = NULL;
for (int i = 0; i < (int)doc.Size(); i++)
{
chapter_data = DataSection::create();
if (doc[i].HasMember("ID") && doc[i]["ID"].IsDouble())
chapter_data->setId((int)doc[i]["ID"].GetDouble());
if (doc[i].HasMember("BE") && doc[i]["BE"].IsDouble())
chapter_data->setBeginId((int)doc[i]["BE"].GetDouble());
if (doc[i].HasMember("EN") && doc[i]["EN"].IsDouble())
chapter_data->setEndId((int)doc[i]["EN"].GetDouble());
addDataSectionToArray(chapter_data);
}
}
示例4: parseJsonDoc
bool LevelConfig::parseJsonDoc(rapidjson::Document &doc) {
for (int i = 0; i < doc.Size(); ++i) {
rapidjson::Value &item = doc[(unsigned int) i];
if (!item.HasMember("ID") || !item.HasMember("Exp")
||!item.HasMember("ChipMax")||!item.HasMember("Reward"))
{
CLOG(ERROR) << "Lack required key.";
return false;
}
int32_t level = item["ID"].GetInt();
config[level].level = level;
config[level].expNeed = item["Exp"].GetInt64();
config[level].maxBet = item["ChipMax"].GetInt64();
config[level].fortuneReward = item["Reward"].GetInt();
}
return true;
}
示例5: analyzeDataNpc
void TopwoData::analyzeDataNpc(rapidjson::Document& doc)
{
DataNpc* npc_data = NULL;
for (int i = 0; i < (int)doc.Size(); i++)
{
npc_data = DataNpc::create();
if (doc[i].HasMember("ID") && doc[i]["ID"].IsDouble())
npc_data->setId((int)doc[i]["ID"].GetDouble());
if (doc[i].HasMember("NA") && doc[i]["NA"].IsString())
npc_data->setName(CCString::create(doc[i]["NA"].GetString()));
if (doc[i].HasMember("MF") && doc[i]["MF"].IsDouble())
npc_data->setFavorMax((int)doc[i]["MF"].GetDouble());
if (doc[i].HasMember("IN") && doc[i]["IN"].IsString())
npc_data->setDes(CCString::create(doc[i]["IN"].GetString()));
if (doc[i].HasMember("EM") && doc[i]["EM"].IsDouble())
npc_data->setExpressMissionId((int)doc[i]["EM"].GetDouble());
addDataNpcToArray(npc_data);
}
}
示例6: reinitialise
EReturn AICOProblem::reinitialise(rapidjson::Document& document,
boost::shared_ptr<PlanningProblem> problem)
{
clear();
if (document.IsArray())
{
for (rapidjson::SizeType i = 0; i < document.Size(); i++)
{
rapidjson::Value& obj = document[i];
if (obj.IsObject())
{
std::string constraintClass;
if (ok(getJSON(obj["class"], constraintClass)))
{
if (knownMaps_.find(constraintClass) != knownMaps_.end())
{
TaskMap_ptr taskmap;
if (ok(
TaskMap_fac::Instance().createObject(
knownMaps_[constraintClass], taskmap)))
{
EReturn ret = taskmap->initialise(obj, server_, scenes_,
problem);
if (ok(ret))
{
if (ret != CANCELLED)
{
std::string name = taskmap->getObjectName();
task_maps_[name] = taskmap;
TaskDefinition_ptr task;
if (ok(
TaskDefinition_fac::Instance().createObject(
"TaskSqrError", task)))
{
TaskSqrError_ptr sqr = boost::static_pointer_cast<
TaskSqrError>(task);
sqr->setTaskMap(taskmap);
int dim;
taskmap->taskSpaceDim(dim);
sqr->y_star0_.resize(dim);
sqr->rho0_(0) = 0.0;
sqr->rho1_(0) = 1e4;
sqr->object_name_ = name
+ std::to_string((unsigned long) sqr.get());
// TODO: Better implementation of stting goals from JSON
sqr->y_star0_.setZero();
sqr->setTimeSteps(T + 2);
Eigen::VectorXd tspan(2);
Eigen::VectorXi tspani(2);
if (obj["tspan"]["__ndarray__"].IsArray())
{
getJSON(obj["tspan"]["__ndarray__"], tspan);
}
else
{
getJSON(obj["tspan"], tspan);
}
if (tspan(0) <= 0.0) tspan(0) = 0.0;
if (tspan(1) >= 1.0) tspan(1) = 1.0;
tspani(0) = (int) (T * tspan(0));
tspani(1) = (int) (T * tspan(1));
for (int t = tspani(0); t <= tspani(1); t++)
{
sqr->registerRho(
Eigen::VectorXdRef_ptr(sqr->rho1_.segment(0, 1)),
t);
}
sqr->wasFullyInitialised_ = true;
task_defs_[name] = task;
}
else
{
INDICATE_FAILURE
;
return FAILURE;
}
}
else
{
ROS_WARN_STREAM(
"Creation of '"<<constraintClass<<"' cancelled!");
}
}
else
{
INDICATE_FAILURE
;
return FAILURE;
}
}
else
{
INDICATE_FAILURE
;
return FAILURE;
}
}
//.........这里部分代码省略.........
示例7: reinitialise
void IKProblem::reinitialise(rapidjson::Document& document,
boost::shared_ptr<PlanningProblem> problem)
{
clear();
if (document.IsArray())
{
for (rapidjson::SizeType i = 0; i < document.Size(); i++)
{
rapidjson::Value& obj = document[i];
if (obj.IsObject())
{
std::string constraintClass;
getJSON(obj["class"], constraintClass);
if (knownMaps_.find(constraintClass) != knownMaps_.end())
{
TaskMap_ptr taskmap = Initialiser::createMap(knownMaps_[constraintClass]);
taskmap->initialise(obj, server_, scene_,problem);
std::string name = taskmap->getObjectName();
task_maps_[name] = taskmap;
TaskDefinition_ptr task = Initialiser::createDefinition("TaskSqrError");
TaskSqrError_ptr sqr = boost::static_pointer_cast<TaskSqrError>(task);
sqr->setTaskMap(taskmap);
int dim;
taskmap->taskSpaceDim(dim);
sqr->y_star0_.resize(dim);
sqr->rho0_(0) = 0.0;
sqr->rho1_(0) = 1.0;
sqr->object_name_ = name+ std::to_string((unsigned long) sqr.get());
// TODO: Better implementation of stting goals from JSON
sqr->y_star0_.setZero();
sqr->setTimeSteps(T_);
Eigen::VectorXd tspan(2);
Eigen::VectorXi tspani(2);
// TODO fix ndarray problem
getJSON(obj["tspan"], tspan);
if (tspan(0) <= 0.0) tspan(0) = 0.0;
if (tspan(1) >= 1.0) tspan(1) = 1.0;
tspani(0) = (int) ((T_ - 1) * tspan(0));
tspani(1) = (int) ((T_ - 1) * tspan(1));
for (int t = tspani(0); t <= tspani(1); t++)
{
sqr->registerRho(Eigen::VectorXdRef_ptr(sqr->rho1_.segment(0, 1)),t);
}
sqr->wasFullyInitialised_ = true;
task_defs_[name] = task;
}
else
{
// WARNING("Ignoring unknown constraint '"<<constraintClass<<"'");
}
}
{
throw_named("Invalid JSON document object!");
}
}
}
else
{
throw_named("Invalid JSON array!");
}
}