• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ LM_E函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中LM_E函数的典型用法代码示例。如果您正苦于以下问题:C++ LM_E函数的具体用法?C++ LM_E怎么用?C++ LM_E使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: semInit

/* ****************************************************************************
*
* semInit -
*
*   parameter #2: 0 - the semaphore is to be shared between threads,
*   parameter #3: 1 - initially the semaphore is free
*
* RETURN VALUE (of sem_init)
*   0 on success,
*  -1 on failure
*
*/
int semInit(SemOpType _reqPolicy, bool semTimeStat, int shared, int takenInitially)
{
  if (sem_init(&reqSem, shared, takenInitially) == -1)
  {
    LM_E(("Runtime Error (error initializing 'req' semaphore: %s)", strerror(errno)));
    return -1;
  }

  if (sem_init(&transSem, shared, takenInitially) == -1)
  {
    LM_E(("Runtime Error (error initializing 'transactionId' semaphore: %s)", strerror(errno)));
    return -1;
  }

  if (sem_init(&cacheSem, shared, takenInitially) == -1)
  {
    LM_E(("Runtime Error (error initializing 'cache' semaphore: %s)", strerror(errno)));
    return -1;
  }

  if (sem_init(&timeStatSem, shared, takenInitially) == -1)
  {
    LM_E(("Runtime Error (error initializing 'timeStat' semaphore: %s)", strerror(errno)));
    return -1;
  }

  reqPolicy = _reqPolicy;

  // Measure accumulated semaphore waiting time?
  semWaitStatistics = semTimeStat;
  return 0;
}
开发者ID:Findeton,项目名称:fiware-orion,代码行数:44,代码来源:sem.cpp


示例2: attributeValue

/* ****************************************************************************
*
* attributeValue - return value of attribute as a string
*/
static void attributeValue(std::string* valueP, const std::vector<ContextAttribute*>& vec, char* attrName)
{
  for (unsigned int ix = 0; ix < vec.size(); ++ix)
  {
    if (vec[ix]->name != attrName)
    {
      continue;
    }

    if (vec[ix]->valueType == orion::ValueTypeString)
    {
      *valueP = vec[ix]->stringValue;
    }
    else if (vec[ix]->valueType == orion::ValueTypeNumber)
    {
      *valueP = toString(vec[ix]->numberValue);
    }
    else if (vec[ix]->valueType == orion::ValueTypeBoolean)
    {
      *valueP = (vec[ix]->boolValue == true)? "true" : "false";
    }
    else if (vec[ix]->valueType == orion::ValueTypeNone)
    {
      *valueP = "null";
    }
    else if ((vec[ix]->valueType == orion::ValueTypeObject) || (vec[ix]->valueType == orion::ValueTypeVector))
    {
      if (vec[ix]->compoundValueP)
      {
        if (vec[ix]->compoundValueP->valueType == orion::ValueTypeVector)
        {
          *valueP = "[" + vec[ix]->compoundValueP->toJson(true) + "]";
        }
        else if (vec[ix]->compoundValueP->valueType == orion::ValueTypeObject)
        {
          *valueP = "{" + vec[ix]->compoundValueP->toJson(true) + "}";
        }
        else
        {
          LM_E(("Runtime Error (attribute is of object type but its compound is of invalid type)"));
          *valueP = "";
        }
      }
      else
      {
        LM_E(("Runtime Error (attribute is of object type but has no compound)"));
        *valueP = "";
      }
    }
    else
    {
      LM_E(("Runtime Error (unknown value type for attribute)"));
      *valueP = "";
    }

    return;
  }

  *valueP = "";
}
开发者ID:Fiware,项目名称:context.Orion,代码行数:64,代码来源:macroSubstitute.cpp


示例3: response

/* ****************************************************************************
*
* RegisterContextRequest::check - 
*/
std::string RegisterContextRequest::check(RequestType requestType, Format format, std::string indent, std::string predetectedError, int counter)
{
  RegisterContextResponse  response(this);
  std::string              res;

  if (predetectedError != "")
  {
    LM_E(("predetectedError not empty"));
    response.errorCode.fill(SccBadRequest, predetectedError);
  }
  else if (contextRegistrationVector.size() == 0)
  {
    LM_E(("contextRegistrationVector.size() == 0"));
    response.errorCode.fill(SccBadRequest, "Empty Context Registration List");
  }
  else if (((res = contextRegistrationVector.check(RegisterContext, format, indent, predetectedError, counter)) != "OK") ||
           ((res = duration.check(RegisterContext, format, indent, predetectedError, counter))                  != "OK") ||
           ((res = registrationId.check(RegisterContext, format, indent, predetectedError, counter))            != "OK"))
  {
    LM_E(("Some check method failed: %s", res.c_str()));
    response.errorCode.fill(SccBadRequest, res);
  }
  else
    return "OK";

  LM_E(("Not OK - returning rendered error result"));     
  return response.render(RegisterContext, format, indent);
}
开发者ID:agallegoc,项目名称:fiware-orion,代码行数:32,代码来源:RegisterContextRequest.cpp


示例4: pthread_cancel

/* ****************************************************************************
*
* Notifier::destroyOntimeIntervalThreads -
*/
void Notifier::destroyOntimeIntervalThreads(const std::string& subId) {

    std::vector<pthread_t> canceled;

    /* Get all the ThreadParams associated to the given subId. Inspired in
     * http://advancedcppwithexamples.blogspot.com.es/2009/04/example-of-c-multimap.html
     */
    std::pair<std::multimap<std::string, ThreadData>::iterator, std::multimap<std::string, ThreadData>::iterator> ii;
    std::multimap<std::string, ThreadData>::iterator it;
    ii = this->threadsMap.equal_range(subId);
    for (it = ii.first; it != ii.second; ++it) {

        ThreadData td = it->second;

        /* Destroy thread */        
        int ret = pthread_cancel(td.tid);
        if (ret != 0)
        {
          LM_E(("Runtime Error (error canceling thread %lu: %d)", (unsigned long) td.tid, ret));
          return;
        }

        /* Note that we do the cancelation in parallel, storing the thread ID. This
         * vector is processed afterwards to wait for every thread to finish */
        canceled.push_back(td.tid);

        /* Release memory */
        delete td.params;

    }

    /* Remove key from the hashmap */
    threadsMap.erase(subId);

    /* Wait for all the cancelation to end */
    for (unsigned int ix = 0; ix < canceled.size(); ++ix) {
        void* res;

        /* pthread_join in blocking */
        int ret = pthread_join(canceled[ix], &res);
        if (ret != 0)
        {
          LM_E(("Runtime Error (error joining thread %lu: %d)", (unsigned long) canceled[ix], ret));
          return;
        }

        if (res == PTHREAD_CANCELED)
        {
            LM_T(LmtNotifier, ("canceled thread: %lu", (unsigned long) canceled[ix]));
        }
        else
        {
          LM_E(("Runtime Error (unexpected error: thread can not be canceled)"));
          return;
        }
    }

    canceled.clear();
}
开发者ID:d0ugal,项目名称:fiware-orion,代码行数:63,代码来源:Notifier.cpp


示例5: jsonTreat

/* ****************************************************************************
*
* jsonTreat - 
*/
std::string jsonTreat(const char* content, ConnectionInfo* ciP, ParseData* parseDataP, RequestType request, std::string payloadWord, JsonRequest** reqPP)
{
  std::string   res   = "OK";
  JsonRequest*  reqP  = jsonRequestGet(request, ciP->method);

  LM_T(LmtParse, ("Treating a JSON request: '%s'", content));

  ciP->parseDataP = parseDataP;

  if (reqP == NULL)
  {
    std::string errorReply = restErrorReplyGet(ciP, ciP->outFormat, "", requestType(request), SccBadRequest,
                                               std::string("Sorry, no request treating object found for RequestType '") + requestType(request) + "'");

    LM_RE(errorReply, ("Sorry, no request treating object found for RequestType %d (%s)", request, requestType(request)));
  }

  if (reqPP != NULL)
    *reqPP = reqP;

  LM_T(LmtParse, ("Treating '%s' request", reqP->keyword.c_str()));

  reqP->init(parseDataP);

  try
  {
    res = jsonParse(ciP, content, reqP->keyword, reqP->parseVector, parseDataP);
    if (ciP->inCompoundValue == true)
      orion::compoundValueEnd(ciP, parseDataP);
    if ((lmTraceIsSet(LmtCompoundValueShow)) && (ciP->compoundValueP != NULL))
      ciP->compoundValueP->shortShow("after parse: ");
  }
  catch (std::exception &e)
  {
    std::string errorReply  = restErrorReplyGet(ciP, ciP->outFormat, "", reqP->keyword, SccBadRequest, std::string("JSON Parse Error: ") + e.what());
    LM_E(("JSON Parse Error: '%s'", e.what()));
    LM_RE(errorReply, (res.c_str()));
  }

  if (res != "OK")
  {
    LM_E(("JSON parse error: %s", res.c_str()));
    ciP->httpStatusCode = SccBadRequest;

    std::string answer = restErrorReplyGet(ciP, ciP->outFormat, "", payloadWord, ciP->httpStatusCode, res);
    return answer; 
  }

  reqP->present(parseDataP);

  LM_T(LmtParseCheck, ("Calling check for JSON parsed tree (%s)", ciP->payloadWord));
  res = reqP->check(parseDataP, ciP);
  reqP->present(parseDataP);

  return res;
}
开发者ID:jesuspg,项目名称:fiware-orion,代码行数:60,代码来源:jsonRequest.cpp


示例6: treat

/* ****************************************************************************
*
* treat -
*
* This is the function that actually treats a node, bu calling its treat function
* provided by src/lib/xmlRequest - the entry point of XML parsing.
*
* It simple compares the current path with the paths in the incoming vector 'parseVector'
* and if a hit is found calls the 'treat' function of that hit (the instance of the vector).
*
* If no hit is found it means that the path of the current XML node is unknown.
* This will result in either a 'PARSE ERROR' or thatthe node is part of a Compound.
*/
static bool treat(ConnectionInfo* ciP, xml_node<>* node, const std::string& path, XmlNode* parseVector, ParseData* parseDataP)
{
  for (unsigned int ix = 0; parseVector[ix].path != "LAST"; ++ix)
  {
    if (path == parseVector[ix].path)
    {
      int r;

      //
      // Before treating a node, a check is made that the value of the node has no forbidden
      // characters.
      // However, if the the node has attributes, then the values of the attributes are checked instead
      //
      if (node->first_attribute() == NULL)
      {
        if (forbiddenChars(node->value()) == true)
        {
          LM_E(("Found a forbidden value in '%s'", node->value()));
          ciP->httpStatusCode = SccBadRequest;
          ciP->answer = std::string("Illegal value for XML attribute");
          return true;
        }
      }
      else
      {
        for (xml_attribute<> *attr = node->first_attribute(); attr; attr = attr->next_attribute())
        {
          if (forbiddenChars(attr->value()) == true)
          {
            LM_E(("Found a forbidden value in attribute: '%s'", node->value()));
            ciP->httpStatusCode = SccBadRequest;
            ciP->answer = std::string("Illegal value for XML attribute");
            return true;
          }
        }
      }

      if ((r = parseVector[ix].treat(node, parseDataP)) != 0)
      {
        LM_W(("Bad Input (xml parse error %d)", r));
      }

      return true;  // Node has been treated
    }
  }

  return false;  // Node was not found in the parse vector
}
开发者ID:AlvaroVega,项目名称:fiware-orion,代码行数:61,代码来源:xmlParse.cpp


示例7: strToLower

/* ****************************************************************************
*
* strToLower - 
*/
char* strToLower(char* to, const char* from, int toSize)
{
  int fromSize = strlen(from);

  if (toSize < fromSize + 1)
  {
    LM_E(("Runtime Error (cannot copy %d bytes into a buffer of %d bytes)", fromSize + 1, toSize));
    fromSize = toSize;
  }

  int ix;
  for (ix = 0; ix < fromSize; ix++)
  {
    if ((from[ix] >= 'A') && (from[ix] <= 'Z'))
    {
      to[ix] = from[ix] + ('a' - 'A');
    }
    else
    {
      to[ix] = from[ix];
    }
  }

  to[ix] = 0;

  return to;
}
开发者ID:fiwareulpgcmirror,项目名称:fiware-orion,代码行数:31,代码来源:string.cpp


示例8: forbiddenChars

/* ****************************************************************************
*
* forbiddenChars - 
*/
bool forbiddenChars(const char* s, const char* exceptions)
{
  if (s == (void*) 0)
  {
    return false;
  }

  while (*s != 0)
  {
    if ((exceptions != NULL) && (strchr(exceptions, *s) != NULL))
    {
      ++s;
      continue;
    }

    switch (*s)
    {
    case '<':
    case '>':
    case '"':
    case '\'':
    case '=':
    case ';':
    case '(':
    case ')':
      LM_E(("Bad Input (character '%c')", *s));
      return true;
    }

    ++s;
  }

  return false;
}
开发者ID:NozomiNetworks,项目名称:fiware-orion,代码行数:38,代码来源:forbiddenChars.cpp


示例9: restReply

/* ****************************************************************************
*
* restReply - 
*/
void restReply(ConnectionInfo* ciP, const std::string& answer)
{
  MHD_Response*  response;

  ++replyIx;
  LM_T(LmtServiceOutPayload, ("Response %d: responding with %d bytes, Status Code %d", replyIx, answer.length(), ciP->httpStatusCode));
  LM_T(LmtServiceOutPayload, ("Response payload: '%s'", answer.c_str()));

  if (answer == "")
    response = MHD_create_response_from_data(answer.length(), (void*) answer.c_str(), MHD_NO, MHD_NO);
  else
    response = MHD_create_response_from_data(answer.length(), (void*) answer.c_str(), MHD_YES, MHD_YES);

  if (!response)
  {
    LM_E(("Runtime Error (MHD_create_response_from_buffer FAILED)"));
    return;
  }

  for (unsigned int hIx = 0; hIx < ciP->httpHeader.size(); ++hIx)
    MHD_add_response_header(response, ciP->httpHeader[hIx].c_str(), ciP->httpHeaderValue[hIx].c_str());

  if (answer != "")
  {
    if (ciP->outFormat == XML)
      MHD_add_response_header(response, "Content-Type", "application/xml");
    else if (ciP->outFormat == JSON)
      MHD_add_response_header(response, "Content-Type", "application/json");
  }

  MHD_queue_response(ciP->connection, ciP->httpStatusCode, response);
  MHD_destroy_response(response);
}
开发者ID:jmmovilla,项目名称:fiware-orion,代码行数:37,代码来源:restReply.cpp


示例10: clock_gettime

/* ****************************************************************************
*
* QueueNotifier::sendNotifyContextRequest -
*/
void QueueNotifier::sendNotifyContextRequest
(
    NotifyContextRequest*            ncr,
    const ngsiv2::HttpInfo&          httpInfo,
    const std::string&               tenant,
    const std::string&               xauthToken,
    const std::string&               fiwareCorrelator,
    RenderFormat                     renderFormat,
    const std::vector<std::string>&  attrsOrder,
    const std::vector<std::string>&  metadataFilter,
    bool                             blacklist
    )
{
  std::vector<SenderThreadParams*> *paramsV = Notifier::buildSenderParams(ncr, httpInfo, tenant, xauthToken, fiwareCorrelator, renderFormat, attrsOrder, metadataFilter, blacklist);

  for (unsigned ix = 0; ix < paramsV->size(); ix++) {
    clock_gettime(CLOCK_REALTIME, &(((*paramsV)[ix])->timeStamp));
  }
  bool enqueued = queue.try_push(paramsV);
  if (!enqueued)
  {
    QueueStatistics::incReject(paramsV->size());

    LM_E(("Runtime Error (notification queue is full)"));
    for (unsigned ix = 0; ix < paramsV->size(); ix++) {
      delete (*paramsV)[ix];
    }
    delete paramsV;

    return;
  }

  QueueStatistics::incIn(paramsV->size());

}
开发者ID:Fiware,项目名称:context.Orion,代码行数:39,代码来源:QueueNotifier.cpp


示例11: get_curl_context

/* ****************************************************************************
*
* httpRequestSend - 
*
* RETURN VALUES
*   httpRequestSend returns 0 on success and a negative number on failure:
*     -1: Invalid port
*     -2: Invalid IP
*     -3: Invalid verb
*     -4: Invalid resource
*     -5: No Content-Type BUT content present
*     -6: Content-Type present but there is no content
*     -7: Total outgoing message size is too big
*     -8: Unable to initialize libcurl
*     -9: Error making HTTP request
*
*   [ error codes -1 to -7 comes from httpRequestSendWithCurl ]
*/
int httpRequestSend
(
   const std::string&     _ip,
   unsigned short         port,
   const std::string&     protocol,
   const std::string&     verb,
   const std::string&     tenant,
   const std::string&     servicePath,
   const std::string&     xauthToken,
   const std::string&     resource,
   const std::string&     orig_content_type,
   const std::string&     content,
   const std::string&     fiwareCorrelation,
   const std::string&     ngisv2AttrFormat,
   bool                   useRush,
   bool                   waitForResponse,
   std::string*           outP,
   const std::string&     acceptFormat,
   long                   timeoutInMilliseconds
)
{
  struct curl_context  cc;
  int                  response;

  get_curl_context(_ip, &cc);
  if (cc.curl == NULL)
  {
    release_curl_context(&cc);
    LM_E(("Runtime Error (could not init libcurl)"));
    lmTransactionEnd();

    *outP = "error";
    return -8;
  }

  response = httpRequestSendWithCurl(cc.curl,
                                     _ip,
                                     port,
                                     protocol,
                                     verb,
                                     tenant,
                                     servicePath,
                                     xauthToken,
                                     resource,
                                     orig_content_type,
                                     content,
                                     fiwareCorrelation,
                                     ngisv2AttrFormat,
                                     useRush,
                                     waitForResponse,
                                     outP,
                                     acceptFormat,
                                     timeoutInMilliseconds);
  release_curl_context(&cc);
  return response;
}
开发者ID:fiwareulpgcmirror-org,项目名称:context.Orion,代码行数:74,代码来源:httpRequestSend.cpp


示例12: LM_E

/* ****************************************************************************
*
* AlarmManager::semInit - 
*/
int AlarmManager::semInit(void)
{
  if (sem_init(&sem, 0, 1) == -1)
  {
    LM_E(("Runtime Error (error initializing 'alarm mgr' semaphore: %s)", strerror(errno)));
    return -1;
  }

  return 0;
}
开发者ID:PascaleBorscia,项目名称:fiware-orion,代码行数:14,代码来源:AlarmManager.cpp


示例13: SenderThreadParams

/* ****************************************************************************
*
* Notifier::sendNotifyContextAvailabilityRequest -
*
* FIXME: this method is very similar to sendNotifyContextRequest and probably
* they could be refactored in the future to have a common part using a parent
* class for both types of notifications and using it as first argument
*/
void Notifier::sendNotifyContextAvailabilityRequest
(
  NotifyContextAvailabilityRequest*  ncar,
  const std::string&                 url,
  const std::string&                 tenant,
  const std::string&                 fiwareCorrelator,
  RenderFormat                       renderFormat
)
{
    /* Render NotifyContextAvailabilityRequest */
    std::string payload = ncar->render(NotifyContextAvailability, "");

    /* Parse URL */
    std::string  host;
    int          port;
    std::string  uriPath;
    std::string  protocol;

    if (!parseUrl(url, host, port, uriPath, protocol))
    {
      std::string details = std::string("sending NotifyContextAvailabilityRequest: malformed URL: '") + url + "'";
      alarmMgr.badInput(clientIp, details);

      return;
    }

    /* Set Content-Type */
    std::string content_type = "application/json";

    /* Send the message (without awaiting response, in a separate thread to avoid blocking) */
    pthread_t            tid;
    SenderThreadParams*  params = new SenderThreadParams();

    params->ip               = host;
    params->port             = port;
    params->verb             = "POST";
    params->tenant           = tenant;
    params->resource         = uriPath;   
    params->content_type     = content_type;
    params->content          = payload;
    params->mimeType         = JSON;
    params->fiwareCorrelator = fiwareCorrelator;
    params->renderFormat     = renderFormatToString(renderFormat);

    strncpy(params->transactionId, transactionId, sizeof(params->transactionId));

    int ret = pthread_create(&tid, NULL, startSenderThread, params);
    if (ret != 0)
    {
      LM_E(("Runtime Error (error creating thread: %d)", ret));
      return;
    }
    pthread_detach(tid);
}
开发者ID:LeonanCarvalho,项目名称:fiware-orion,代码行数:62,代码来源:Notifier.cpp


示例14: LM_E

/* ****************************************************************************
*
* SubscriptionCache::insert - 
*/
void SubscriptionCache::insert(Subscription* subP)
{
  if (subP->entityIdInfos.size() == 0)
  {
    LM_E(("Runtime Error (no entity for subscription - not inserted in subscription cache)"));
    return;
  }

  subs.push_back(subP);

  ++noOfSubCacheEntries;
}
开发者ID:Findeton,项目名称:fiware-orion,代码行数:16,代码来源:SubscriptionCache.cpp


示例15: semInit

/* ****************************************************************************
*
* semInit -
*
*   parameter #1: 0 - the semaphore is to be shared between threads,
*   parameter #2: 1 - initially the semaphore is free
*
* RETURN VALUE (of sem_init)
*   0 on success,
*  -1 on failure
*
*/
int semInit(int shared, int takenInitially)
{
  if (sem_init(&reqSem, shared, takenInitially) == -1)
  {
    LM_E(("Runtime Error (error initializing 'req' semaphore: %s)", strerror(errno)));
    return 1;
  }

  if (sem_init(&mongoSem, shared, takenInitially) == -1)
  {
    LM_E(("Runtime Error (error initializing 'mongo' semaphore: %s)", strerror(errno)));
    return 2;
  }

  if (sem_init(&transSem, shared, takenInitially) == -1)
  {
    LM_E(("Runtime Error (error initializing 'transactionId' semaphore: %s)", strerror(errno)));
    return 3;
  }

  return 0;
}
开发者ID:jmmovilla,项目名称:fiware-orion,代码行数:34,代码来源:sem.cpp


示例16: restReply

/* ****************************************************************************
*
* restReply - 
*/
void restReply(ConnectionInfo* ciP, const std::string& answer)
{
  MHD_Response*  response;

  ++replyIx;
  LM_T(LmtServiceOutPayload, ("Response %d: responding with %d bytes, Status Code %d", replyIx, answer.length(), ciP->httpStatusCode));
  LM_T(LmtServiceOutPayload, ("Response payload: '%s'", answer.c_str()));

  response = MHD_create_response_from_buffer(answer.length(), (void*) answer.c_str(), MHD_RESPMEM_MUST_COPY);
  if (!response)
  {
    LM_E(("Runtime Error (MHD_create_response_from_buffer FAILED)"));
    return;
  }

  for (unsigned int hIx = 0; hIx < ciP->httpHeader.size(); ++hIx)
  {
    MHD_add_response_header(response, ciP->httpHeader[hIx].c_str(), ciP->httpHeaderValue[hIx].c_str());
  }

  if (answer != "")
  {
    if (ciP->outMimeType == JSON)
    {
      MHD_add_response_header(response, "Content-Type", "application/json");
    }
    else if (ciP->outMimeType == TEXT)
    {
      MHD_add_response_header(response, "Content-Type", "text/plain");
    }

    // At the present version, CORS is supported only for GET requests
    if ((strlen(restAllowedOrigin) > 0) && (ciP->verb == GET))
    {
      // If any origin is allowed, the header is sent always with "any" as value
      if (strcmp(restAllowedOrigin, "__ALL") == 0)
      {
        MHD_add_response_header(response, "Access-Control-Allow-Origin", "*");
      }
      // If a specific origin is allowed, the header is only sent if the origins match
      else if (strcmp(ciP->httpHeaders.origin.c_str(), restAllowedOrigin) == 0)
      {
        MHD_add_response_header(response, "Access-Control-Allow-Origin", restAllowedOrigin);
      }
    }
  }

  MHD_queue_response(ciP->connection, ciP->httpStatusCode, response);
  MHD_destroy_response(response);
}
开发者ID:LeonanCarvalho,项目名称:fiware-orion,代码行数:54,代码来源:restReply.cpp


示例17: BSON

/* ****************************************************************************
*
* attributeType -
*
*/
static std::string attributeType
(
  const std::string&                    tenant,
  const std::vector<std::string>&       servicePathV,
  const std::string                     entityType,
  const std::string                     attrName
)
{
  std::string  idType         = std::string("_id.")    + ENT_ENTITY_TYPE;
  std::string  idServicePath  = std::string("_id.")    + ENT_SERVICE_PATH;
  std::string  attributeName  = std::string(ENT_ATTRS) + "." + attrName;

  BSONObj query = BSON(idType        << entityType <<
                       idServicePath << fillQueryServicePath(servicePathV) <<
                       attributeName << BSON("$exists" << true));

  std::auto_ptr<DBClientCursor> cursor;
  std::string                   err;

  if (!collectionQuery(getEntitiesCollectionName(tenant), query, &cursor, &err))
  {
    return "";
  }

  while (cursor->more())
  {
    BSONObj r;
    try
    {
      r = cursor->nextSafe();
    }
    catch (const AssertionException &e)
    {
      // $err raised
      LM_E(("Runtime Error (assertion exception in nextSafe(): %s", e.what()));
      continue;
    }

    LM_T(LmtMongo, ("retrieved document: '%s'", r.toString().c_str()));

    /* It could happen that different entities within the same entity type may have attributes with the same name
     * but different types. In that case, one type (at random) is returned. A list could be returned but the
     * NGSIv2 operations only allow to set one type */
    BSONObj attrs = getField(r, ENT_ATTRS).embeddedObject();
    BSONObj attr = getField(attrs, attrName).embeddedObject();
    return getStringField(attr, ENT_ATTRS_TYPE);
  }

  return "";
}
开发者ID:NozomiNetworks,项目名称:fiware-orion,代码行数:55,代码来源:mongoQueryTypes.cpp


示例18: socketHttpConnect

/* ****************************************************************************
*
* socketHttpConnect -
*/
int socketHttpConnect(const std::string& host, unsigned short port)
{
  int                 fd;
  struct addrinfo     hints;
  struct addrinfo*    peer;
  char                port_str[10];


  LM_VVV(("Generic Connect to: '%s'  port: '%d'", host.c_str(), port));

  memset(&hints, 0, sizeof(struct addrinfo));
  hints.ai_socktype = SOCK_STREAM;
  hints.ai_protocol = 0;

  if (ipVersionUsed == IPV4) 
  {
    hints.ai_family = AF_INET;
    LM_VVV(("Allow IPv4 only"));
  }
  else if (ipVersionUsed == IPV6)
  {
    hints.ai_family = AF_INET6;
    LM_VVV(("Allow  IPv6 only"));
  }
  else 
  {
    hints.ai_family = AF_UNSPEC;
    LM_VVV(("Allow IPv4 or IPv6"));
  }

  snprintf(port_str, sizeof(port_str), "%d" , (int) port);

  if (getaddrinfo(host.c_str(), port_str, &hints, &peer) != 0) {
    LM_RE(-1, ("getaddrinfo('%s'): %s", host.c_str(), strerror(errno)));
  }

  if ((fd = socket(peer->ai_family, peer->ai_socktype, peer->ai_protocol)) == -1) {
    LM_RE(-1, ("socket: %s", strerror(errno)));
  }

  if (connect(fd, peer->ai_addr, peer->ai_addrlen) == -1)
  {
    freeaddrinfo(peer);
    close(fd);
    LM_E(("connect(%s, %d): %s", host.c_str(), port, strerror(errno)));
    return -1;
  }
  freeaddrinfo(peer);
  return fd;
}
开发者ID:B-Rich,项目名称:fiware-orion,代码行数:54,代码来源:clientSocketHttp.cpp


示例19: get_curl_context_new

/* ****************************************************************************
*
* get_curl_context_new -
*/
static int get_curl_context_new(const std::string& key, struct curl_context* pcc)
{
  pcc->curl   = NULL;
  pcc->pmutex = NULL;

  pcc->curl = curl_easy_init();

  if (pcc->curl == NULL)
  {
    LM_E(("Runtime Error (curl_easy_init)"));
    return -1;
  }

  return 0;
}
开发者ID:Findeton,项目名称:fiware-orion,代码行数:19,代码来源:sem.cpp


示例20: jsonRequestGet

/* ****************************************************************************
*
* jsonRequestGet - 
*/
static JsonRequest* jsonRequestGet(RequestType request, std::string method)
{
  for (unsigned int ix = 0; ix < sizeof(jsonRequest) / sizeof(jsonRequest[0]); ++ix)
  {
    if ((request == jsonRequest[ix].type) && (jsonRequest[ix].method == method))
    {
      if (jsonRequest[ix].parseVector != NULL)
        LM_V2(("Found jsonRequest of type %d, method '%s' - index %d (%s)", request, method.c_str(), ix, jsonRequest[ix].parseVector[0].path.c_str()));
      return &jsonRequest[ix];
    }
  }

  LM_E(("No request found for RequestType '%s', method '%s'", requestType(request), method.c_str()));
  return NULL;
}
开发者ID:B-Rich,项目名称:fiware-orion,代码行数:19,代码来源:jsonRequest.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ LM_ERR函数代码示例发布时间:2022-05-30
下一篇:
C++ LM_CRIT函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap