本文整理汇总了C++中DynamicObject::removeMember方法的典型用法代码示例。如果您正苦于以下问题:C++ DynamicObject::removeMember方法的具体用法?C++ DynamicObject::removeMember怎么用?C++ DynamicObject::removeMember使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DynamicObject
的用法示例。
在下文中一共展示了DynamicObject::removeMember方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addContext
bool JsonLd::addContext(
DynamicObject& context, DynamicObject& in, DynamicObject& out)
{
bool rval = true;
// "a" is automatically shorthand for rdf type
DynamicObject ctx = (context.isNull() ? DynamicObject() : context.clone());
ctx["a"] = RDF_TYPE;
// TODO: should context simplification be an option? (ie: remove context
// entries that are not used in the output)
// setup output context
DynamicObject& contextOut = out["#"];
contextOut->setType(Map);
// apply context
_applyContext(ctx, contextOut, NULL, in, out);
// clean up
if(contextOut->length() == 0)
{
out->removeMember("#");
}
return rval;
}
示例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;
}
示例3: _normalize
//.........这里部分代码省略.........
// get normalized key
nKey = _normalizeValue(ctx, key, RDF_TYPE_IRI, NULL, NULL);
// put values in an array for single code path
DynamicObject values;
values->setType(Array);
if(value->getType() == Array)
{
values.merge(value, true);
// preserve array structure when not using subjects map
if(out != NULL)
{
(*out)[nKey.c_str()]->setType(Array);
}
}
else
{
values->append(value);
}
// normalize all values
DynamicObjectIterator vi = values.getIterator();
while(rval && vi->hasNext())
{
DynamicObject v = vi->next();
if(v->getType() == Map)
{
if(subjects != NULL)
{
// get a normalized subject for the value
string vSubject;
if(v->hasMember("@"))
{
// normalize existing subject
vSubject = _normalizeValue(
ctx, v["@"], RDF_TYPE_IRI, NULL, NULL);
}
else
{
// generate the next blank node ID in order to preserve
// the blank node embed in the code below
vSubject = _createBlankNodeId(bnodeId + 1);
}
// determine if value is a blank node
bool isBNode = _isBlankNode(v);
// update non-blank node subject (use value's subject IRI)
if(!isBNode)
{
_setPredicate(subject, nKey.c_str(), vSubject.c_str());
}
// recurse
rval = _normalize(ctx, v, subjects, out, bnodeId);
// preserve embedded blank node
if(rval && isBNode)
{
// remove embed from top-level subjects
DynamicObject embed = (*subjects)[vSubject.c_str()];
(*subjects)->removeMember(vSubject.c_str());
embed->removeMember("@");
_setEmbed(subject, nKey.c_str(), embed);
}
}
else
{
// update out and recurse
DynamicObject next = (*out)[nKey.c_str()];
if(value->getType() == Array)
{
next = next->append();
}
else
{
next->setType(Map);
}
rval = _normalize(ctx, v, subjects, &next, bnodeId);
}
}
else
{
_setPredicate(
(subjects != NULL) ? subject : *out, nKey.c_str(),
_normalizeValue(ctx, v, RDF_TYPE_UNKNOWN, key, NULL).c_str());
}
}
}
// add subject to map
if(subjects != NULL)
{
(*subjects)[subject["@"]->getString()] = subject;
}
}
return rval;
}