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


C++ StringTokenizer::init方法代码示例

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


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

示例1: setArgument

int QueryQualifierBuilder::setArgument (QueryQualifierBuilder &qualifierBuilder, const char *pszPropertyAndValue)
{
    if (pszPropertyAndValue == NULL) {
        return -1;
    }
    static StringTokenizer tokenizer;
    tokenizer.init (pszPropertyAndValue, '=', '=');
    
    const char *pszProperty = tokenizer.getNextToken();
    if (pszProperty == NULL) {
        return -2;
    }

    String value = tokenizer.getNextToken();
    if (value.length() <= 0) {
        return -3;
    }

    value.trim();

    if (stricmp (GROUP_BY.c_str(), pszProperty) == 0) {
        qualifierBuilder._groupBy = value.c_str();
    }
    else if (stricmp (LIMIT.c_str(), pszProperty) == 0) {
        qualifierBuilder._limit = value.c_str();
    }
    else if (stricmp (ORDER.c_str(), pszProperty) == 0) {
        qualifierBuilder._order = value.c_str();
    }
    else {
        return -4;
    }

    return 0;
}
开发者ID:fpoltronieri,项目名称:nomads,代码行数:35,代码来源:QueryQualifierBuilder.cpp

示例2: outerTokenizer

StringStringHashtable * StringStringHashtable::parseStringStringHashtable (const char *pszString)
{
    if (pszString == NULL) {
        return NULL;
    }
    const bool bCaseSensitiveKeys = true;
    const bool bCloneKeys = true;
    const bool bDeleteKeys = true;
    const bool bCloneValues = false; // because I copy the token before setting it
    const bool bDeleteValues = true;
    StringStringHashtable *pMap = new StringStringHashtable (bCaseSensitiveKeys ,
                                                             bCloneKeys, bDeleteKeys,
                                                             bCloneValues, bDeleteValues);
    if (pMap == NULL) {
        return NULL;
    }
    StringTokenizer outerTokenizer (pszString, OUTER_SEPARATOR, OUTER_SEPARATOR);
    StringTokenizer innerTokenizer;
    for (const char *pszOuterToken; (pszOuterToken = outerTokenizer.getNextToken()) != NULL;) {
        innerTokenizer.init (pszOuterToken, INNER_SEPARATOR, INNER_SEPARATOR);
        const char *pszKey = innerTokenizer.getNextToken();
        String value (innerTokenizer.getNextToken());
        if ((pszKey != NULL) && (value.length() > 0)) {
            // bCloneValues set on false (because String makes a copy of the token,
            // that then I relinquish with r_str()),and bDeleteValues set on true
            pMap->put (pszKey, value.r_str());
        }
    }
    return pMap;
}
开发者ID:agilecomputing,项目名称:nomads,代码行数:30,代码来源:StringStringHashtable.cpp

示例3: br

QueryQualifierBuilder * QueryQualifierBuilder::parse (const char *pszQueryQualifiers)
{
    if (pszQueryQualifiers == NULL) {
        return NULL;
    }

    unsigned int uiLen = strlen (pszQueryQualifiers);
    if (uiLen == 0) {
        return NULL;
    }

    BufferReader br (pszQueryQualifiers, uiLen, false);
    LineOrientedReader lr (&br, false);
    char *pszLine = (char *) calloc (uiLen+1, sizeof (char));
    if (pszLine == NULL) {
        return NULL;
    }
    QueryQualifierBuilder *pQualifierBuilder = new QueryQualifierBuilder();
    if (pQualifierBuilder == NULL) {
        free (pszLine);
        return NULL;
    }

    for (int rc; (rc = lr.readLine (pszLine, uiLen)) >= 0;) {
        if (rc == 0) {
            continue;   // empty line
        }
        static StringTokenizer tokenizer;
        tokenizer.init (pszQueryQualifiers, ';', ';');
        for (const char *pszToken; (pszToken = tokenizer.getNextToken()) != NULL;) {
            if (pQualifierBuilder->setArgument (*pQualifierBuilder, pszToken) < 0) {
                free (pszLine);
                free (pQualifierBuilder);
                return NULL;
            }
        }
    }

    free (pszLine);
    
  /*  if (pszQueryQualifiers->_groupBy.) {
        
    }
            NOMADSUtil::String _limit;
            NOMADSUtil::String _order;*/

    return pQualifierBuilder;
}
开发者ID:fpoltronieri,项目名称:nomads,代码行数:48,代码来源:QueryQualifierBuilder.cpp

示例4: matchPropertyListToApplicationMetadata

int DSProQueryController::matchPropertyListToApplicationMetadata (char *pszBuffer, PropertiesConditionsList *pPropertiesConditionsList,
                                                                  MetadataInterface *pCurr, PtrLList<const char> *pResultsList)
{
    const char *pszMethodName = "DSProQueryController::matchPropertyListToApplicationMetadata";
    char *pszTemp;
    char *pszApplicationMetadataFields = nullptr;
    char *pszToken = strtok_mt (pszBuffer, "{", &pszTemp);
    if (pszToken != nullptr) {
        pszApplicationMetadataFields = strtok_mt (pszToken, "}", &pszTemp);
    }
    if (pszApplicationMetadataFields == nullptr) {
        checkAndLogMsg (pszMethodName, Logger::L_Warning, "The Application Metadata field is nullptr\n");
    }

    StringTokenizer tokenizer (pszApplicationMetadataFields, ' ', ',');
    StringTokenizer innerTokenizer;
    for (const char *pszAMField = tokenizer.getNextToken(); pszAMField != nullptr; pszAMField = tokenizer.getNextToken()) {
        innerTokenizer.init (pszAMField, '=', '=');
        const char *pszKey = innerTokenizer.getNextToken();
        const char *pszValue = innerTokenizer.getNextToken();
        if (pszKey == nullptr) {
            continue;
        }

        checkAndLogMsg (pszMethodName, Logger::L_Info, "Application Metadata field: <%s, %s>\n", pszKey, pszValue);

        PropertyCondition *pPropertyCondition = pPropertiesConditionsList->getPropertyCondition (pszKey);
        if (pPropertyCondition == nullptr) {
            continue;
        }

        checkAndLogMsg (pszMethodName, Logger::L_Info, "Found property key %s\n", pszKey);

        bool bAddMessageId = false;

        const char *pPropertyConditionOperator = pPropertyCondition->getPropertyConditionOperator();
        const char *pPropertyConditionValue = pPropertyCondition->getPropertyConditionValue();
        if (strcmp (pPropertyConditionOperator, "!=") == 0) {
            if (strcmp (pszValue, pPropertyConditionValue) != 0) {
                bAddMessageId = true;
            }
        }
        else if (strcmp (pPropertyConditionOperator, "=") == 0) {
            if (strcmp (pszValue, pPropertyConditionValue) == 0) {
                bAddMessageId = true;
            }
        }
        else {
            double dValue;
            if (!atod (pszValue, dValue)) {
                checkAndLogMsg (pszMethodName, Logger::L_Warning, "Expected a numeric value for property %s. Found %s\n",
                                pszKey, pszValue);
                continue;
            }
            if (!atod (pPropertyConditionValue, dValue)) {
                checkAndLogMsg (pszMethodName, Logger::L_Warning, "Expected a numeric value for property condition %s. Found %s\n",
                                pszKey, pPropertyConditionValue);
                continue;
            }

            float fValue = (float) dValue;
            float fConditionValue = (float) atof (pPropertyConditionValue);

            if (strcmp (pPropertyConditionOperator, ">=") == 0) {
                if (fValue >= fConditionValue) {
                    bAddMessageId = true;
                }
            }
            else if (strcmp (pPropertyConditionOperator, ">") == 0) {
                if (fValue > fConditionValue) {
                    bAddMessageId = true;
                }
            }
            else if (strcmp (pPropertyConditionOperator, "<=") == 0) {
                if (fValue <= fConditionValue) {
                    bAddMessageId = true;
                }
            }
            else {
                if (fValue < fConditionValue) {
                    bAddMessageId = true;
                }
            }
        }

        if (bAddMessageId) {
            char *pszMetadataId = nullptr;
            if (0 == pCurr->getFieldValue (MetadataInterface::MESSAGE_ID, &pszMetadataId) && pszMetadataId != nullptr) {
                pResultsList->append (pszMetadataId);
            }
        }

    }

    return 0;
}
开发者ID:ihmc,项目名称:nomads,代码行数:96,代码来源:DSProQueryController.cpp

示例5: init

int MetadataRankerLocalConfigurationImpl::init (NOMADSUtil::ConfigManager *pCfgMgr)
{
    const char *pszMethodName = "MetadataRankerLocalConfiguration::init";
    if (pCfgMgr == nullptr) {
        return -1;
    }

    const char *pszMatchamakingFiltersByNodeId = pCfgMgr->getValue (MD_RANKER_LOCAL_CONF_PROPERTY::FILTER_MATCHMAKING_BY_PEER);
    if (pszMatchamakingFiltersByNodeId != nullptr) {
        const char OUTER_SEPARATOR = ';';
        const char INNER_SEPARATOR = ',';
        StringTokenizer outerTokenizer (pszMatchamakingFiltersByNodeId, OUTER_SEPARATOR, OUTER_SEPARATOR);
        StringTokenizer innerTokenizer;
        for (const char *pszOuterToken; (pszOuterToken = outerTokenizer.getNextToken ()) != nullptr;) {
            innerTokenizer.init (pszOuterToken, INNER_SEPARATOR, INNER_SEPARATOR);
            const char *pszKey = innerTokenizer.getNextToken ();
            String value (innerTokenizer.getNextToken ());
            if ((pszKey != nullptr) && (value.length () > 0)) {
                addFilter (pszKey, value.c_str());
            }
        }
    }
    if (pszMatchamakingFiltersByNodeId != nullptr) {
        const char OUTER_SEPARATOR = ';';
        const char INNER_SEPARATOR = ',';
        StringTokenizer outerTokenizer (pszMatchamakingFiltersByNodeId, OUTER_SEPARATOR, OUTER_SEPARATOR);
        StringTokenizer innerTokenizer;
        for (const char *pszOuterToken; (pszOuterToken = outerTokenizer.getNextToken ()) != nullptr;) {
            innerTokenizer.init (pszOuterToken, INNER_SEPARATOR, INNER_SEPARATOR);
            const char *pszKey = innerTokenizer.getNextToken ();
            String value (innerTokenizer.getNextToken ());
            if ((pszKey != nullptr) && (value.length () > 0)) {
                String searchKey (pszKey);
                if (searchKey.endsWith ("*")) {
                    searchKey = searchKey.substring (0, searchKey.length () - 1);
                    searchKey += '-';
                }
                if (hasFilterForTypeAndPeer (searchKey, value)) {
                    checkAndLogMsg (pszMethodName, Logger::L_Info, "--- adding matchmaking filter for peer %s on %s.\n",
                                    pszKey, value.c_str());
                }
            }
        }
    }

    const char *pszNonMatchingTypes = pCfgMgr->getValue (MD_RANKER_LOCAL_CONF_PROPERTY::NON_MATCHING_DATA_TYPES);
    if (pszNonMatchingTypes != nullptr) {
        StringTokenizer tokenizer (pszNonMatchingTypes, ',', ',');
        for (const char *pszToken; (pszToken = tokenizer.getNextToken ()) != nullptr;) {
            if (strlen (pszToken) > 0) {
                addFilter (pszToken);
            }
        }
    }

    if (pCfgMgr->hasValue (MD_RANKER_LOCAL_CONF_PROPERTY::RANGE_OF_INFLUENCE_KEY_ATTRIBUTE)) {
        const String val (pCfgMgr->getValue (MD_RANKER_LOCAL_CONF_PROPERTY::RANGE_OF_INFLUENCE_KEY_ATTRIBUTE));
        setRangeOfInfluenceAttributeName (val);
    }

    if (pCfgMgr->hasValue (MD_RANKER_LOCAL_CONF_PROPERTY::TRACK_NOVELTY_INSIGN_DISTANCE_FACTOR)) {
        const String val (pCfgMgr->getValue (MD_RANKER_LOCAL_CONF_PROPERTY::TRACK_NOVELTY_INSIGN_DISTANCE_FACTOR));
        if (val.length() > 0) {
            _track.setInsignificantTrackMovementFactor ((float)atof (val));
        }
    }

    if (pCfgMgr->hasValue (MD_RANKER_LOCAL_CONF_PROPERTY::LOGSTAT_NOVELTY_INSIGN_CHANGE_FACTOR)) {
        const String val (pCfgMgr->getValue (MD_RANKER_LOCAL_CONF_PROPERTY::LOGSTAT_NOVELTY_INSIGN_CHANGE_FACTOR));
        if (val.length() > 0) {
            _logStat.setInsignificantUpdatePerc ((float)atof (val));
        }
    }

    return 0;
}
开发者ID:ihmc,项目名称:nomads,代码行数:76,代码来源:MetadataRankerLocalConfigurationImpl.cpp


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