本文整理汇总了C++中DynamicObject::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ DynamicObject::clear方法的具体用法?C++ DynamicObject::clear怎么用?C++ DynamicObject::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DynamicObject
的用法示例。
在下文中一共展示了DynamicObject::clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _findType
// Currently just handles top level and @:[...] constructs.
static bool _findType(DynamicObject& in, const char* type, DynamicObject& out)
{
out->clear();
if(in->hasMember("@"))
{
DynamicObject& id = in["@"];
switch(id->getType())
{
// top level object
case String:
{
if(_isType(in, type))
{
out->append(in);
}
break;
}
// top level is blank node
case Array:
{
DynamicObjectIterator i = id.getIterator();
while(i->hasNext())
{
DynamicObject& next = i->next();
if(_isType(next, type))
{
out->append(next);
}
}
break;
}
default:
break;
}
}
return true;
}
示例2: normalize
bool JsonLd::normalize(DynamicObject& in, DynamicObject& out)
{
bool rval = true;
// initialize output
out->setType(Map);
out->clear();
// create map to store subjects
DynamicObject subjects;
subjects->setType(Map);
// initialize context
DynamicObject ctx(NULL);
if(in->hasMember("#"))
{
ctx = in["#"];
}
// put all subjects in an array for single code path
DynamicObject input;
input->setType(Array);
if(in->hasMember("@") && in["@"]->getType() == Array)
{
input.merge(in["@"], true);
}
else
{
input->append(in);
}
// do normalization
int bnodeId = 0;
DynamicObjectIterator i = input.getIterator();
while(rval && i->hasNext())
{
rval = _normalize(ctx, i->next(), &subjects, NULL, bnodeId);
}
// build output
if(rval)
{
// single subject
if(subjects->length() == 1)
{
DynamicObject subject = subjects.first();
out.merge(subject, false);
// FIXME: will need to check predicates for blank nodes as well...
// and fail if they aren't embeds?
// strip blank node '@'
if(_isBlankNode(out))
{
out->removeMember("@");
}
}
// multiple subjects
else
{
DynamicObject& array = out["@"];
array->setType(Array);
i = subjects.getIterator();
while(i->hasNext())
{
DynamicObject& next = i->next();
// FIXME: will need to check predicates for blank nodes as well...
// and fail if they aren't embeds?
// strip blank node '@'
if(_isBlankNode(next))
{
next->removeMember("@");
}
array->append(next);
}
}
}
return rval;
}