当前位置: 首页>>代码示例>>C++>>正文


C++ DynamicObject::clear方法代码示例

本文整理汇总了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;
}
开发者ID:zengyuxing007,项目名称:monarch,代码行数:40,代码来源:JsonLd.cpp

示例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;
}
开发者ID:zengyuxing007,项目名称:monarch,代码行数:82,代码来源:JsonLd.cpp


注:本文中的DynamicObject::clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。