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


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

本文整理汇总了C++中DynamicObject::hasMember方法的典型用法代码示例。如果您正苦于以下问题:C++ DynamicObject::hasMember方法的具体用法?C++ DynamicObject::hasMember怎么用?C++ DynamicObject::hasMember使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DynamicObject的用法示例。


在下文中一共展示了DynamicObject::hasMember方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _expandCurie

/**
 * Expands a possible CURIE string into a full IRI. If the string is not
 * recognized as a CURIE that can be expanded into an IRI, then false is
 * returned.
 *
 * @param ctx the context to use.
 * @param str the string to expand (no <>).
 * @param iri the string to store the IRI in.
 * @param usedCtx a context to update if a value was used from "ctx".
 *
 * @return true if the string was expanded, false if not.
 */
static bool _expandCurie(
   DynamicObject& ctx, const char* str, string& iri,
   DynamicObject* usedCtx = NULL)
{
   bool rval = false;

   if(!ctx.isNull())
   {
      // try to find a colon
      const char* ptr = strchr(str, ':');
      if(ptr != NULL)
      {
         // get the potential CURIE prefix
         size_t len = ptr - str + 1;
         char prefix[len];
         snprintf(prefix, len, "%s", str);

         // see if the prefix is in the context
         if(ctx->hasMember(prefix))
         {
            // prefix found, normalize string
            DynamicObject& uri = ctx[prefix];
            len = strlen(uri->getString()) + strlen(ptr + 1) + 3;
            iri = StringTools::format("%s%s", uri->getString(), ptr + 1);
            if(usedCtx != NULL)
            {
               (*usedCtx)[prefix] = uri.clone();
            }
            rval = true;
         }
      }
   }

   return rval;
}
开发者ID:zengyuxing007,项目名称:monarch,代码行数:47,代码来源:JsonLd.cpp

示例2: _isType

/* Check if a JSON-LD object is a specific type. */
static bool _isType(DynamicObject& in, const char* type)
{
   bool rval = false;

   if(in->hasMember("a"))
   {
      DynamicObject& a = in["a"];
      switch(a->getType())
      {
         case String:
         {
            rval = (a == type);
            break;
         }
         case Array:
         {
            DynamicObjectIterator i = a.getIterator();
            while(!rval && i->hasNext())
            {
               DynamicObject& next = i->next();
               rval = (next == type);
            }
            break;
         }
         default:
            break;
      }
   }

   return rval;
}
开发者ID:zengyuxing007,项目名称:monarch,代码行数:32,代码来源:JsonLd.cpp

示例3: filter

// FIXME: should this be using new JSON-LD frame stuff rather than this?
bool JsonLd::filter(
   DynamicObject& context, DynamicObject& filter,
   DynamicObject& in, DynamicObject& out, bool simplify)
{
   bool rval;
   DynamicObject normFilter;
   DynamicObject normIn;
   DynamicObject normOut;
   normOut->setType(Map);
   // remove contexts
   rval =
      removeContext(filter, normFilter) &&
      removeContext(in, normIn);
   // filter to the output
   if(rval)
   {
      _filter(normFilter, normIn, normOut);
      // FIXME: fixup graph
      // Search normOut for unknown references that are in normIn and add them.
      // Futher optimize by checking reference count and embedding data as
      // needed. This will result in a graph that is as complete as the input
      // with regard to references.

      // flatten in the case of one result
      if(simplify && normOut->hasMember("@") && normOut["@"]->length() == 1)
      {
         normOut = normOut["@"][0];
      }
   }
   // add context to output
   rval = rval && addContext(context, normOut, out);
   return rval;
}
开发者ID:zengyuxing007,项目名称:monarch,代码行数:34,代码来源:JsonLd.cpp

示例4: _setPredicate

/**
 * Sets a subject's predicate to the given object value. If a value already
 * exists, it will be appended to an array. If the object value is NULL, then
 * the subject's predicate will be converted to an array.
 *
 * @param s the subject.
 * @param p the predicate.
 * @param o the object, NULL to only convert s[p] to an array.
 */
static void _setPredicate(DynamicObject& s, const char* p, const char* o)
{
   // FIXME: must sort objects or keep array order?
   if(s->hasMember(p))
   {
      if(s[p]->getType() != Array)
      {
         DynamicObject tmp = s[p];
         s[p] = DynamicObject();
         s[p]->append(tmp);
      }
      if(o != NULL)
      {
         s[p]->append(o);
      }
   }
   else if(o == NULL)
   {
      s[p]->setType(Array);
   }
   else
   {
      s[p] = o;
   }
}
开发者ID:zengyuxing007,项目名称:monarch,代码行数:34,代码来源:JsonLd.cpp

示例5: getFileInfos

bool SampleService::getFileInfos(
   BtpAction* action, DynamicObject& in, DynamicObject& out,
   DynamicObject& fileInfos)
{
   bool rval;

   // do not send dyno as response
   out.setNull();

   // get catalog interface
   CatalogInterface* ci = dynamic_cast<CatalogInterface*>(
      mNode->getModuleApiByType("bitmunk.catalog"));

   // get targeted node user
   DynamicObject vars;
   action->getResourceQuery(vars);
   if(!vars->hasMember("nodeuser"))
   {
      BM_ID_SET(vars["nodeuser"], mNode->getDefaultUserId());
   }

   // get resource parameters
   DynamicObject params;
   action->getResourceParams(params);

   // populate ware bundle
   Ware ware;
   BM_ID_SET(ware["mediaId"], BM_MEDIA_ID(params[0]));
   MediaPreferenceList mpl;
   mpl[0]["preferences"][0]["contentType"] = vars["contentType"];
   mpl[0]["preferences"][0]["minBitrate"] = 1;
   // FIXME: Make sure the node user is checked against logged in user?
   if((rval = ci->populateWareBundle(
      BM_USER_ID(vars["nodeuser"]), ware, mpl)))
   {
      FileInfoIterator i = ware["fileInfos"].getIterator();
      while(i->hasNext())
      {
         FileInfo& fi = i->next();

         // FIXME: get content type for file info instead of "extension"
         const char* extension = fi["extension"]->getString();
         // FIXME: only support for mp3 audio at this time
         if(strcmp(extension, "mp3") == 0)
         {
            // get sample range for file info
            Media media;
            BM_ID_SET(media["id"], BM_MEDIA_ID(fi["mediaId"]));
            if(getSampleRange(media))
            {
               fi["media"] = media;
               fileInfos->append() = fi;
            }
         }
      }
   }

   return rval;
}
开发者ID:digitalbazaar,项目名称:bitmunk,代码行数:59,代码来源:SampleService.cpp

示例6: return

inline static bool _isBlankNode(DynamicObject& v)
{
   // look for no subject or "<_:" or "_:" at the beginning of the subject
   return (
      !v->hasMember("@") ||
      strstr(v["@"], "<_:") == v["@"]->getString() ||
      strstr(v["@"], "_:") == v["@"]->getString());
}
开发者ID:zengyuxing007,项目名称:monarch,代码行数:8,代码来源:JsonLd.cpp

示例7: convertToException

ExceptionRef Exception::convertToException(DynamicObject& dyno)
{
   ExceptionRef rval = new Exception(
      dyno["message"]->getString(),
      dyno["type"]->getString());

   if(dyno->hasMember("cause"))
   {
      ExceptionRef cause = convertToException(dyno["cause"]);
      rval->setCause(cause);
   }

   if(dyno->hasMember("details"))
   {
      *(*rval).mDetails = dyno["details"].clone();
   }

   return rval;
}
开发者ID:zengyuxing007,项目名称:monarch,代码行数:19,代码来源:Exception.cpp

示例8: _setPredicate

static void _setPredicate(
   DynamicObject& s, const char* predicate, DynamicObject& object)
{
   if(s->hasMember(predicate))
   {
      s[predicate].push(object);
   }
   else
   {
      s[predicate] = object;
   }
}
开发者ID:bsletten,项目名称:monarch,代码行数:12,代码来源:RdfaReader.cpp

示例9: isValid

bool Map::isValid(
   DynamicObject& obj,
   ValidatorContext* context)
{
   bool rval = true;

   if(!obj.isNull() && obj->getType() == monarch::rt::Map)
   {
      Validators::iterator i;
      for(i = mValidators.begin(); i != mValidators.end(); ++i)
      {
         // only add a "." if this is not a root map
         if(context->getDepth() != 0)
         {
            context->pushPath(".");
         }
         context->pushPath(i->first);
         if(obj->hasMember(i->first))
         {
            // do not short-circuit to ensure all keys tested
            if(!i->second.validator->isValid(obj[i->first], context))
            {
               rval = false;
            }
         }
         else if(!i->second.validator->isOptional(context))
         {
            rval = false;
            DynamicObject detail =
               context->addError("monarch.validation.MissingField", &obj);
            detail["validator"] = "monarch.validator.Map";
            detail["message"] = "A required field has not been specified.";
            detail["key"] = i->first;
         }
         context->popPath();
         if(context->getDepth() > 0)
         {
            context->popPath();
         }
      }
   }
   else
   {
      rval = false;
      DynamicObject detail =
         context->addError("monarch.validation.TypeError", &obj);
      detail["validator"] = "monarch.validator.Map";
      detail["message"] = "The given object type must a mapping (Map) type";
   }

   return rval;
}
开发者ID:bsletten,项目名称:monarch,代码行数:52,代码来源:Map.cpp

示例10: exchange

bool Messenger::exchange(
   UserId peerId,
   Url* url, BtpMessage* out, BtpMessage* in, UserId userId, UserId agentId,
   uint32_t timeout)
{
   bool rval = true;

   if(userId != 0)
   {
      // get user profile
      ProfileRef p;
      if(!mNode->getLoginData(agentId == 0 ? userId : agentId, NULL, &p))
      {
         ExceptionRef e = new Exception(
            "Could not do BTP exchange. Not logged in.",
            "bitmunk.node.Messenger.NotLoggedIn");
         BM_ID_SET(e->getDetails()["userId"], userId);
         BM_ID_SET(e->getDetails()["agentId"], agentId);
         Exception::set(e);
         rval = false;
      }
      else if(!p.isNull())
      {
         // set user ID and profile for outgoing secure message
         out->setUserId(userId);
         out->setAgentProfile(p);

         // set public key source for incoming secure message
         in->setPublicKeySource(mNode->getPublicKeyCache());
      }
   }

   // do btp exchange
   if(rval)
   {
      // if nodeuser is set, override peer ID with it
      DynamicObject vars;
      url->getQueryVariables(vars);
      if(vars->hasMember("nodeuser"))
      {
         peerId = BM_USER_ID(vars["nodeuser"]);
      }

      rval = mClient.exchange(peerId, url, out, in, timeout);
   }

   return rval;
}
开发者ID:digitalbazaar,项目名称:bitmunk,代码行数:48,代码来源:Messenger.cpp

示例11: _setDecodedParam

static bool _setDecodedParam(
   Statement* s, unsigned int index,
   DynamicObject& param, DynamicObject& value)
{
   bool rval = true;

   if(param->hasMember("encode"))
   {
      // FIXME: could use streams here and handle types other than string,
      // but the DatabaseClient API might be abandoned before this actually
      // ever really gets used to that extent

      // fill byte buffer with initial data
      ByteBuffer b;
      b.put(value->getString(), value->length(), true);

      // apply each decoding
      // FIXME: optimize this by doing it once and storing it when
      // defining the schema
      DynamicObject decode = param["encode"].clone();
      decode->reverse();
      DynamicObjectIterator i = decode.getIterator();
      while(rval && i->hasNext())
      {
         const char* type = i->next()->getString();

         // convert hex to binary
         if(strcmp(type, "hex") == 0)
         {
            const char* hex = b.bytes();
            unsigned int len = b.length();
            unsigned int binLen = (len >> 1) + 1;
            char bin[binLen];
            rval = Convert::hexToBytes(hex, len, bin, binLen);
            if(rval)
            {
               b.clear();
               b.put(bin, binLen, true);
            }
         }
      }

      // only blobs are supported at the moment
      rval = rval && s->setBlob(index, b.bytes(), b.length());
   }
开发者ID:bsletten,项目名称:monarch,代码行数:45,代码来源:DatabaseClient.cpp

示例12: _setEmbed

static void _setEmbed(DynamicObject& s, const char* p, DynamicObject& o)
{
   // FIXME: must sort objects or keep array order?
   if(s->hasMember(p))
   {
      if(s[p]->getType() != Array)
      {
         DynamicObject tmp = s[p];
         s[p] = DynamicObject();
         s[p]->append(tmp);
      }
      s[p]->append(o);
   }
   else
   {
      s[p] = o;
   }
}
开发者ID:zengyuxing007,项目名称:monarch,代码行数:18,代码来源:JsonLd.cpp

示例13: insertDirective

void DirectiveService::insertDirective(
   DynamicObject& cache, DynamicObject& directive)
{
   // Note: Assume cache lock is engaged.

   // get random number for ID
   char tmp[22];
   do
   {
      // get a random number between 1 and 1000000000
      uint64_t n = Random::next(1, 1000000000);
      snprintf(tmp, 22, "%" PRIu64, n);
   }
   while(cache->hasMember(tmp));

   // set directive ID and insert into cache
   directive["id"] = tmp;
   cache[tmp] = directive;
}
开发者ID:digitalbazaar,项目名称:bitmunk,代码行数:19,代码来源:DirectiveService.cpp

示例14: _findId

// Currently just handles top level and @:[...] constructs.
static bool _findId(DynamicObject& in, const char* id, DynamicObject& out)
{
   out.setNull();

   if(in->hasMember("@"))
   {
      DynamicObject& _id = in["@"];
      switch(_id->getType())
      {
         // top level object
         case String:
         {
            if(_id == id)
            {
               out = in;
            }
            break;
         }
         // top level is blank node
         case Array:
         {
            bool found = false;
            DynamicObjectIterator i = _id.getIterator();
            while(!found && i->hasNext())
            {
               DynamicObject& next = i->next();
               if(next["@"] == id)
               {
                  out = next;
                  found = true;
               }
            }
            break;
         }
         default:
            break;
      }
   }

   return true;
}
开发者ID:zengyuxing007,项目名称:monarch,代码行数:42,代码来源:JsonLd.cpp

示例15: _removeContext

/**
 * Recursively removes context from the given input object.
 *
 * @param ctx the context to use (changes during recursion as necessary).
 * @param in the input object.
 * @param out the normalized output object.
 * @param bnodeId the last blank node ID used.
 *
 * @return true on success, false on failure with exception set.
 */
static bool _removeContext(
   DynamicObject& ctx, DynamicObject& in, DynamicObject& out, int& bnodeId)
{
   bool rval = true;

   if(in.isNull())
   {
      out.setNull();
   }
   else
   {
      // initialize output
      DynamicObjectType inType = in->getType();
      out->setType(inType);

      // update context
      if(inType == Map && in->hasMember("#"))
      {
         ctx = in["#"];
      }

      if(inType == Map)
      {
         rval = _normalize(ctx, in, NULL, &out, bnodeId);
      }
      else if(inType == Array)
      {
         // strip context from each object in the array
         DynamicObjectIterator i = in.getIterator();
         while(i->hasNext())
         {
            DynamicObject& next = i->next();
            rval = _removeContext(ctx, next, out->append(), bnodeId);
         }
      }
   }

   return rval;
}
开发者ID:zengyuxing007,项目名称:monarch,代码行数:49,代码来源:JsonLd.cpp


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