本文整理汇总了C++中rapidjson::Document::IsArray方法的典型用法代码示例。如果您正苦于以下问题:C++ Document::IsArray方法的具体用法?C++ Document::IsArray怎么用?C++ Document::IsArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rapidjson::Document
的用法示例。
在下文中一共展示了Document::IsArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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));
}
}
}
示例2: 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;
}
}
//.........这里部分代码省略.........
示例3: 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!");
}
}