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


C++ StringTokenizer类代码示例

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


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

示例1: ProcessError

std::string
NIImporter_DlrNavteq::EdgesHandler::getColumn(const StringTokenizer& st, ColumnName name, const std::string fallback) {
    assert(!myColumns.empty());
    if (myColumns[name] == MISSING_COLUMN) {
        if (fallback == "") {
            throw ProcessError("Missing column " + toString(name) + ".");
        } else {
            return fallback;
        }
    } else if (myColumns[name] >= 0) {
        return st.get((int)(myColumns[name]));
    } else {
        // negative column number implies an optional column
        if ((int) st.size() <= -myColumns[name]) {
            // the column is not present
            if (fallback == "") {
                throw ProcessError("Missing optional column " + toString(name) + " without default value.");
            } else {
                return fallback;
            }
        } else {
            return st.get((int)(-myColumns[name]));
        }
    }
}
开发者ID:behrisch,项目名称:sumo,代码行数:25,代码来源:NIImporter_DlrNavteq.cpp

示例2: result

/*!

\brief Creates a directory.
\details Defined in dmzSystemFile.h. Function will create a path as deep as is
requested in \a Path. Function returns dmz::True if path already exists.
\param[in] Path String containing directory to create.
\return Returns dmz::True if directory was successfully created.

*/
dmz::Boolean
dmz::create_directory (const String &Path) {

   Boolean result (False);

   if (Path) {

      result = True;
      const String FormattedPath (format_path (Path));
      StringTokenizer st (FormattedPath, '/');
      String dir;
      if (FormattedPath.get_char (0) == '/') { dir << "/"; }
      String part (st.get_next ());

      while (part) {

         if (dir) { dir << "/" << part; }
         else { dir = part; }

         if (!is_valid_path (dir)) {

            if (mkdir (dir.get_buffer (), S_IRUSR | S_IWUSR | S_IXUSR) != 0) {

               result = False;
            }
         }

         if (result) { part = st.get_next (); }
         else { part.flush (); }
      }
   }

   return result;
}
开发者ID:ben-sangster,项目名称:dmz,代码行数:43,代码来源:dmzSystemFileUnix.cpp

示例3: character

/*!

\brief Looks up states from names.
\param[in] Name String containing state names.
\param[out] state Mask object to store found states.
\return Returns dmz::True if all named states are found.
\note State names should be delineated by the "|" character (a.k.a. the bitwise or
operator).

*/
dmz::Boolean
dmz::Definitions::lookup_state (const String &Name, Mask &state) const {

   Boolean result (False);

   if (_state.defs) {

      StringTokenizer st (Name, '|');
      String value = st.get_next ();

      result = value;

      while (value) {

         trim_ascii_white_space (value);
         convert_ascii_white_space (value);

         Mask *ptr (_state.defs->maskTable.lookup (value));

         if (ptr) { state |= *ptr; }
         else if (_state.log) {

            _state.log->error << "Unable to find state: " << value
               << " in state name: " << Name << endl;

            result = False;
         }

         value = st.get_next ();
      }
   }

   return result;
}
开发者ID:ben-sangster,项目名称:dmz,代码行数:44,代码来源:dmzRuntimeInit.cpp

示例4: unoCommand

bool ChildSession::unoCommand(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens)
{
    if (tokens.count() == 1)
    {
        sendTextFrame("error: cmd=uno kind=syntax");
        return false;
    }

    std::unique_lock<std::recursive_mutex> lock(Mutex);

    if (_multiView)
        _loKitDocument->setView(_viewId);

    // we need to get LOK_CALLBACK_UNO_COMMAND_RESULT callback when saving
    const bool bNotify = (tokens[1] == ".uno:Save");

    if (tokens.count() == 2)
    {
        _loKitDocument->postUnoCommand(tokens[1].c_str(), nullptr, bNotify);
    }
    else
    {
        _loKitDocument->postUnoCommand(tokens[1].c_str(),
                                               Poco::cat(std::string(" "), tokens.begin() + 2, tokens.end()).c_str(),
                                               bNotify);
    }

    return true;
}
开发者ID:biostone,项目名称:online,代码行数:29,代码来源:ChildSession.cpp

示例5: 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

示例6: sendFontRendering

bool ClientSession::sendFontRendering(const char *buffer, int length, StringTokenizer& tokens)
{
    std::string font;
    if (tokens.count() < 2 ||
        !getTokenString(tokens[1], "font", font))
    {
        return sendTextFrame("error: cmd=renderfont kind=syntax");
    }

    const std::string response = "renderfont: " + Poco::cat(std::string(" "), tokens.begin() + 1, tokens.end()) + "\n";

    std::vector<char> output;
    output.resize(response.size());
    std::memcpy(output.data(), response.data(), response.size());

    std::unique_ptr<std::fstream> cachedRendering = _docBroker->tileCache().lookupRendering(font, "font");
    if (cachedRendering && cachedRendering->is_open())
    {
        cachedRendering->seekg(0, std::ios_base::end);
        size_t pos = output.size();
        std::streamsize size = cachedRendering->tellg();
        output.resize(pos + size);
        cachedRendering->seekg(0, std::ios_base::beg);
        cachedRendering->read(output.data() + pos, size);
        cachedRendering->close();

        return sendBinaryFrame(output.data(), output.size());
    }

    return forwardToPeer(_peer, buffer, length);
}
开发者ID:expansio,项目名称:online,代码行数:31,代码来源:ClientSession.cpp

示例7: unoCommand

bool ChildProcessSession::unoCommand(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens)
{
    Poco::Mutex::ScopedLock lock(_mutex);

    if (tokens.count() == 1)
    {
        sendTextFrame("error: cmd=uno kind=syntax");
        return false;
    }

    _loKitDocument->pClass->setView(_loKitDocument, _viewId);

    // we need to get LOK_CALLBACK_UNO_COMMAND_RESULT callback when saving
    bool bNotify = (tokens[1] == ".uno:Save");

    if (tokens.count() == 2)
    {
        _loKitDocument->pClass->postUnoCommand(_loKitDocument, tokens[1].c_str(), 0, bNotify);
    }
    else
    {
        _loKitDocument->pClass->postUnoCommand(_loKitDocument, tokens[1].c_str(), Poco::cat(std::string(" "), tokens.begin() + 2, tokens.end()).c_str(), bNotify);
    }

    return true;
}
开发者ID:maloherry,项目名称:online,代码行数:26,代码来源:ChildProcessSession.cpp

示例8: parsePeers

 void parsePeers (const char *pszPeerAddresses, StringHashset &addresses)
 {
     StringTokenizer tokenizer (pszPeerAddresses, ';', ';');
     const char *pszRemoteAddress;
     while ((pszRemoteAddress = tokenizer.getNextToken()) != NULL) {
         addresses.put (pszRemoteAddress);
     }
 }
开发者ID:fpoltronieri,项目名称:nomads,代码行数:8,代码来源:DSProUtils.cpp

示例9: loadGraph

void loadGraph(std::string edgeFile)
{
	// Open file for reading
	freopen(edgeFile.c_str(), "rt", stdin);

	edge_count = 0;
	vecEdges.clear();
	maxNode = -1;

	// Read line by line edge info
	while(gets(buff))
	{
		if(strlen(buff) == 0)
			break;
		edge_count++;

		StringTokenizer token;
		// tokenize using comma
		token.parse(buff, ",");
		std::vector<std::string> vecToken;
		vecToken.clear();
		token.getTokens(vecToken);

		// There should be exactly 9 values: edge_id, start_node_id, end_node_id, 
		// start_node_longitude, start_node_latitude, end_node_longitude, end_node_latitude, cost, reverse_cost
		if(vecToken.size() < 5)
			fprintf(stderr, "Error in %d edge\n", edge_count);

		// Populate Edge_t structure
		edge_astar_t tempEdge;
		tempEdge.id = atoi(vecToken[0].c_str());
		tempEdge.source = atoi(vecToken[1].c_str());
		tempEdge.target = atoi(vecToken[2].c_str());
		tempEdge.cost = atof(vecToken[3].c_str());
		tempEdge.reverse_cost = atof(vecToken[4].c_str());
		tempEdge.s_x = atof(vecToken[5].c_str());
		tempEdge.s_y = atof(vecToken[6].c_str());
		tempEdge.t_x = atof(vecToken[7].c_str());
		tempEdge.t_y = atof(vecToken[8].c_str());

		// Update max_node_id
		if(tempEdge.source > maxNode)
			maxNode = tempEdge.source;
		if(tempEdge.target > maxNode)
			maxNode = tempEdge.target;
		
		vecEdges.push_back(tempEdge);
	}

	edges = new edge_astar_t[edge_count];
	int i;

	for(i = 0; i < edge_count; i++)
	{
		edges[i] = vecEdges[i];
	}
	fclose(stdin);
}
开发者ID:DavidLiuGitHub,项目名称:pgrouting,代码行数:58,代码来源:BDATester.cpp

示例10: result

/*!

\brief Looks up all config contexts with the given name.
\details All config context found with a matching name are stored as children of \a data.
\param[in] Name String containing name of config contexts to lookup.
\param[out] data Config to store the found config contexts.
\return Returns dmz::True if any config contexts were found.

*/
dmz::Boolean
dmz::Config::lookup_all_config (const String &Name, Config &data) const {

   Boolean result (False);
   StringTokenizer it (Name, LocalScopeChar);
   String sub = it.get_next ();
   Boolean done (!sub ? True : False);

   Config prev ("prev");
   prev.add_config (*this);
   Config current (sub);

   while (!done) {

      ConfigIterator tableIt;
      Config next;

      ConfigContext *curContext = current.get_config_context ();

      while (prev.get_next_config (tableIt, next)) {

         ConfigContext *nextContext = next.get_config_context ();

         if (nextContext && curContext) {

            ConfigContext::DataList *dl (nextContext->configTable.lookup (sub));

            if (dl) {

               dl->lock.lock ();
                  ConfigContext::DataStruct *ds = dl->head;
                  while (ds) {

                     if (ds->handle) {

                        curContext->add_config (ds->context);
                     }

                     ds = ds->next;
                  }
               dl->lock.unlock ();
            }
         }
      }

      if (current.is_empty ()) { done = True; }
      else {

         sub = it.get_next ();
         if (!sub) { data = current; done = True; result = True; }
         else { prev = current; Config next (sub); current = next; }
      }
   }

   if (data.is_empty ()) { data.set_config_context (0); result = False; }

   return result;
}
开发者ID:ben-sangster,项目名称:dmz,代码行数:67,代码来源:dmzRuntimeConfig.cpp

示例11: inFailList

bool inFailList(int s){
    StringTokenizer strtok = StringTokenizer(src,",");
    while(strtok.hasMoreTokens()){
        string cur = strtok.nextToken();
        int c = atoi(cur.c_str());
        if(c==s) return true;
    }
    return false;
}
开发者ID:bsaunder,项目名称:aoPHP,代码行数:9,代码来源:testrdp.cpp

示例12: sendTile

void MasterProcessSession::sendTile(const char *buffer, int length, StringTokenizer& tokens)
{
    int part, width, height, tilePosX, tilePosY, tileWidth, tileHeight;

    if (tokens.count() < 8 ||
        !getTokenInteger(tokens[1], "part", part) ||
        !getTokenInteger(tokens[2], "width", width) ||
        !getTokenInteger(tokens[3], "height", height) ||
        !getTokenInteger(tokens[4], "tileposx", tilePosX) ||
        !getTokenInteger(tokens[5], "tileposy", tilePosY) ||
        !getTokenInteger(tokens[6], "tilewidth", tileWidth) ||
        !getTokenInteger(tokens[7], "tileheight", tileHeight))
    {
        sendTextFrame("error: cmd=tile kind=syntax");
        return;
    }

    if (part < 0 ||
        width <= 0 ||
        height <= 0 ||
        tilePosX < 0 ||
        tilePosY < 0 ||
        tileWidth <= 0 ||
        tileHeight <= 0)
    {
        sendTextFrame("error: cmd=tile kind=invalid");
        return;
    }

    std::string response = "tile: " + Poco::cat(std::string(" "), tokens.begin() + 1, tokens.end()) + "\n";

    std::vector<char> output;
    output.reserve(4 * width * height);
    output.resize(response.size());
    std::memcpy(output.data(), response.data(), response.size());

    std::unique_ptr<std::fstream> cachedTile = _tileCache->lookupTile(part, width, height, tilePosX, tilePosY, tileWidth, tileHeight);
    if (cachedTile && cachedTile->is_open())
    {
        cachedTile->seekg(0, std::ios_base::end);
        size_t pos = output.size();
        std::streamsize size = cachedTile->tellg();
        output.resize(pos + size);
        cachedTile->seekg(0, std::ios_base::beg);
        cachedTile->read(output.data() + pos, size);
        cachedTile->close();

        sendBinaryFrame(output.data(), output.size());

        return;
    }

    if (_peer.expired())
        dispatchChild();
    forwardToPeer(buffer, length);
}
开发者ID:wanweihua,项目名称:online,代码行数:56,代码来源:MasterProcessSession.cpp

示例13: StringTokenizer

void MPSReader::readNAME(){

  line = fileReader->readLine();
  StringTokenizer *lineTokens = new StringTokenizer(line);

  if (lineTokens->nextToken().compare("NAME") == 0)
  {
    funcao->NomeProblema = lineTokens->nextToken();
  }
}
开发者ID:vinishiru,项目名称:cuda-simplex,代码行数:10,代码来源:MPSReader.cpp

示例14: tokenizer

int TargetBasedReplicationController::configure (ConfigManager *pCfgMgr)
{
    const char *pszMethod = "TargetBasedReplicationController::configure";

    // Load the target specifications from config file
    const char *pszIncludedTargets = pCfgMgr->getValue ("aci.disService.replicationTarget.includeList");
    const char *pszExcludedTargets = pCfgMgr->getValue ("aci.disService.replicationTarget.excludeList");

    // Parse the targets into arrays
    if (pszIncludedTargets) {
        StringTokenizer tokenizer (pszIncludedTargets, ';');
        const char *pszToken;
        while ((pszToken = tokenizer.getNextToken()) != NULL) {
            String *pTargetId = new String (pszToken);
            _targetIncludeSpec.append (pTargetId);
            checkAndLogMsg (pszMethod, Logger::L_Info,
                            "added %s as an included target specification\n", pszToken);
        }
    }
    if (pszExcludedTargets) {
        StringTokenizer tokenizer (pszExcludedTargets, ';');
        const char *pszToken;
        while ((pszToken = tokenizer.getNextToken()) != NULL) {
            String *pTargetId = new String (pszToken);
            _targetExcludeSpec.append (pTargetId);
            checkAndLogMsg (pszMethod, Logger::L_Info,
                            "added %s as an excluded target specification\n", pszToken);
        }
    }

    // Determine whether the target's existing messages should be used as a filter
    _bCheckTargetForMsgs = pCfgMgr->getValueAsBool ("aci.disService.replication.checkTargetForMsgs", true);
    checkAndLogMsg (pszMethod, Logger::L_Info,
                    "check target's existing messages for filtration: %s\n",
                    _bCheckTargetForMsgs ? "true" : "false");

    // Check whether replicated messages should be acknowledged
    _bRequireAcks = pCfgMgr->getValueAsBool ("aci.disService.replication.requireAcks", true);
    checkAndLogMsg (pszMethod, Logger::L_Info,
                    "require acknowledgements: %s\n",
                    _bRequireAcks ? "true" : "false");

    // Check whether we should perform concurrent replication (to multiple target peers)
    _bAllowConcurrentReplication = pCfgMgr->getValueAsBool ("aci.disService.replication.concurrentReplication", false);
    checkAndLogMsg (pszMethod, Logger::L_Info,
                    "allow concurrent replication to multiple targets: %s\n",
                    _bAllowConcurrentReplication ? "true" : "false");

    // Check whether we should receive from multiple replications concurrently
    _bAllowConcurrentReception = pCfgMgr->getValueAsBool ("aci.disService.replication.concurrentReception", false);
    checkAndLogMsg (pszMethod, Logger::L_Info,
                    "allow concurrent reception from multiple replicators: %s\n",
                    _bAllowConcurrentReception ? "true" : "false");
    return 0;
}
开发者ID:agilecomputing,项目名称:nomads,代码行数:55,代码来源:TargetBasedReplicationController.cpp

示例15: StringTokenizer

expr_type Calculator::calc1(const char *expr){
   StringTokenizer *st = new StringTokenizer(expr, EDELIMITERS);

   MathTok m[len + 1];

   size_t co = 0;

   sign_type sign = E_PLUS;

   const char *x = st->nextToken();

   while (x && co < len){
      m[co].value = atoexpr(x);
      m[co].proc  = sign;

      //printf("%-3d %5.2f %d %s\n", e_matrix[ m[co].proc ]->sign, m[co].value, err, st->nextToEnd());

      co++;
      sign = chk_sign(st->lastdelimiter, st, &err);

      x = st->nextToken();
   }

   delete(st);

   while(co > 1){
      size_t i;

      unsigned short int pr  = e_matrix[ m[0 + 1].proc ]->priority;

      for (i = 0 + 1; i < co; i++){
         unsigned short int pr1 = e_matrix[ m[i].proc ]->priority;
         if (pr1 > pr)
            pr = pr1;
      }

      for (i = 0 + 1; i < co; i++)
         if (e_matrix[ m[i].proc ]->priority == pr){
            if (e_matrix[ m[i].proc ]->process == NULL)
               err = true;
            else
               m[i - 1].value = e_matrix[ m[i].proc ]->process(m[i - 1].value, m[i].value, &err);

            for (size_t j = i; j < co - 1; j++)
               m[j]=m[j + 1];

            co--;

            break;
         }
   }

   return m[0].value;
}
开发者ID:nmmmnu,项目名称:ccc,代码行数:54,代码来源:expr.cpp


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