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


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

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


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

示例1: readNAME

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

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

示例3: StringTokenizer

 opennlp::model::Event *FileEventStream::next()
 {
   StringTokenizer *st = new StringTokenizer(line);
   std::string outcome = st->nextToken();
   int count = st->countTokens();
   std::string context[count];
   for (int ci = 0; ci < count; ci++)
   {
     context[ci] = st->nextToken();
   }
   return (new Event(outcome, context));
 }
开发者ID:benlm54,项目名称:myassist-repo,代码行数:12,代码来源:FileEventStream.cpp

示例4: calc

long int calc(const char *expr){
   StringTokenizer *st = new StringTokenizer(expr, EDELIMITERS);
   
   MathTok *m[100 + 1];
   unsigned int co = 0;
   char znak = CEPLUS;

   const char *x = st->nextToken();
   while (x){
      switch  (znak){
         case CEPLUS  : m[co] = new MathTok_PLUS (x); break;
         case CEMINUS : m[co] = new MathTok_MINUS(x); break;
         case CESTAR  : m[co] = new MathTok_STAR (x); break;
         case CESLASH : m[co] = new MathTok_SLASH(x); break;
         case CEGREAT : m[co] = new MathTok_GREAT(x); break;
         case CELESS  : m[co] = new MathTok_LESS (x); break;
         case CEEQUAL : m[co] = new MathTok_EQUAL(x); break;

         default      : m[co] = new MathTok_PLUS (x); break;
      }
      co++;
      znak = st->lastdelimiter;
      x = st->nextToken();
   }

   delete(st);

   while(co > 1){
      unsigned int i;

      unsigned short int pr = m[0 + 1]->getPriority();
      for (i = 0 + 1; i < co; i++)
         if (m[i]->getPriority() > pr)
            pr = m[i]->getPriority();

      for (i = 0 + 1; i < co; i++)
         if (m[i]->getPriority() == pr){
            m[i - 1]->value = m[i]->calc( m[i - 1]->value );

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

            co--;

            break;
         }
   }

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

示例5: readRHS

void MPSReader::readRHS(){

  StringTokenizer *lineTokens = new StringTokenizer(line);
  string nomeVetorRHS;
  string nomeFuncao;
  string valorTermoLivre;

  if (lineTokens->nextToken().compare("RHS") == 0){

    line = fileReader->readLine();

    while (line.compare("BOUNDS") != 0 && line.compare("") != 0 && line.compare("ENDATA") != 0){

      lineTokens->setLine(line);

      //Ler no minimo 3 tokens
      //Nome variavel / Nome Funcao|Restricao / Valor variavel

      if (this->VetorRHSPossuiNome){
        nomeVetorRHS = lineTokens->nextToken();
        nomeFuncao = lineTokens->nextToken();
        valorTermoLivre = lineTokens->nextToken();
      }
      else{
        nomeFuncao = lineTokens->nextToken();
        valorTermoLivre = lineTokens->nextToken();
      }

      //Se nomeFuncao for o nome da funcao objetivo, atribuir variaveis nela
      if (nomeFuncao.compare(funcao->Nome) == 0){
        funcao->TermoLivre = stof(valorTermoLivre.c_str());
      }
      //Se nao, atribuir variaveis a restricao
      else {
        funcao->setTermoLivreRestricao(nomeFuncao, stof(valorTermoLivre.c_str()));
      }

      //Se tiver mais tokens, ler mais duas colunas
      //Nome Variavel e Valor Variavel, obedecendo as mesmas regras anteriores
      if (lineTokens->hasToken()){

        nomeFuncao = lineTokens->nextToken();
        valorTermoLivre = lineTokens->nextToken();

        if (nomeFuncao.compare(funcao->Nome) == 0){
          funcao->TermoLivre = stof(valorTermoLivre.c_str());
        }
        //Se nao, atribuir variaveis a restricao
        else {
          funcao->setTermoLivreRestricao(nomeFuncao, stof(valorTermoLivre.c_str()));
        }
      }

      line = fileReader->readLine(); //ler nova linha ao final
    }

  }
}
开发者ID:vinishiru,项目名称:cuda-simplex,代码行数:58,代码来源:MPSReader.cpp

示例6: readROWS

void MPSReader::readROWS(){

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

  if (lineTokens->nextToken().compare("ROWS") == 0){

    line = fileReader->readLine();

    while (line.compare("COLUMNS") != 0){

      lineTokens->setLine(line);

      desigualdade = lineTokens->nextToken();
      nomeFuncao = lineTokens->nextToken();

      //Objetivo
      if (desigualdade.compare("N") == 0){
        funcao->Nome = nomeFuncao;
      }
      //Igualdade
      else if (desigualdade.compare("E") == 0){
        funcao->addRestricao(nomeFuncao);
        funcao->setDesigualdadeRestricao(nomeFuncao, Igual);
      }
      //Menor ou igual
      else if (desigualdade.compare("L") == 0){
        funcao->addRestricao(nomeFuncao);
        funcao->setDesigualdadeRestricao(nomeFuncao, MenorOuIgual);
      }
      //Maior ou igual
      else if (desigualdade.compare("G") == 0){
        funcao->addRestricao(nomeFuncao);
        funcao->setDesigualdadeRestricao(nomeFuncao, MaiorOuIgual);
      }
      else
        throw 10; //Erro de sintaxe

      line = fileReader->readLine();
    }
  }


}
开发者ID:vinishiru,项目名称:cuda-simplex,代码行数:46,代码来源:MPSReader.cpp

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

示例8: checkNumberTokens

void Tree::checkNumberTokens( StringTokenizer& str, const int& n,
			      const string& tag, const int& ln )
{
  if( n != str.countTokens() ) 
    {
      cerr << "The input-file seems corrupt for the " << Node::getAlphabetName() << " alphabet, line: " << ln << endl << tag << " ";
      cerr << "Line has " << str.countTokens()+1 << " space separated words, should have: " << n + 1 << endl;
      while( str.hasMoreTokens() )cout << str.nextToken() << " ";
      cout << endl;
      exit( 2 ); // THROW EXCEPTION!!
    }
}
开发者ID:ddalevi,项目名称:PSTk-Classifier,代码行数:12,代码来源:Tree.cpp

示例9: readCOLUMNS

void MPSReader::readCOLUMNS(){

  StringTokenizer *lineTokens = new StringTokenizer(line);
  string nomeFuncao;
  string nomeVariavel;
  string valorVariavel;

  if (lineTokens->nextToken().compare("COLUMNS") == 0){

    line = fileReader->readLine();

    while (line.compare("RHS") != 0){

      lineTokens->setLine(line);

      //Ler no minimo 3 tokens
      //Nome variavel / Nome Funcao|Restricao / Valor variavel

      nomeVariavel = lineTokens->nextToken();
      nomeFuncao = lineTokens->nextToken();
      valorVariavel = lineTokens->nextToken();

      //Se nomeFuncao for o nome da funcao objetivo, atribuir variaveis nela
      if (nomeFuncao.compare(funcao->Nome) == 0){
        funcao->addVariavel(nomeVariavel, stof(valorVariavel.c_str()));
      }
      //Se nao, atribuir variaveis a restricao
      else {
        funcao->addVariavelRestricao(nomeFuncao, nomeVariavel, stof(valorVariavel.c_str()));
      }

      //Se tiver mais tokens, ler mais duas colunas
      //Nome Variavel e Valor Variavel, obedecendo as mesmas regras anteriores
      if (lineTokens->hasToken()){
        nomeFuncao = lineTokens->nextToken();
        valorVariavel = lineTokens->nextToken();

        //Se nomeFuncao for o nome da funcao objetivo, atribuir variaveis nela
        if (nomeFuncao.compare(funcao->Nome) == 0){
          funcao->addVariavel(nomeVariavel, stof(valorVariavel.c_str()));
        }
        //Se nao, atribuir variaveis a restricao
        else {
          funcao->addVariavelRestricao(nomeFuncao, nomeVariavel, stof(valorVariavel.c_str()));
        }
      }


      line = fileReader->readLine(); //ler nova linha ao final
    }
  }

}
开发者ID:vinishiru,项目名称:cuda-simplex,代码行数:53,代码来源:MPSReader.cpp

示例10: putParsedStr

void Properties::putParsedStr(const char *s, char delim){
   if (isempty(s))
      return;

   StringTokenizer *st = new StringTokenizer(s, delim);

   char *tmp1 = strdupn(st->nextToken());
   char *tmp2 = strdupn(st->nextToEnd());

   const char *name = strcut(tmp1);
   const char *value = strcut(tmp2);

   put(name, value); 

   free(tmp1);
   free(tmp2);
   delete(st);
};
开发者ID:nmmmnu,项目名称:ccc,代码行数:18,代码来源:prop.cpp

示例11: StringTokenizer

vector<int> NumCalcApplicationTools::seqFromString(const string & s, const string & delim, const string & seqdelim)
{
  vector<int> seq;
  StringTokenizer * st = new StringTokenizer(s, delim, true);
  while (st->hasMoreToken())
  {
    StringTokenizer * st2 = new StringTokenizer(st->nextToken(), seqdelim, true);
    if (st2->numberOfRemainingTokens() > 1)
    {
      vector<int> tmp = VectorTools::seq(TextTools::toInt(st2->getToken(0)), TextTools::toInt(st2->getToken(1)), 1);
      VectorTools::append(seq, tmp);
    }
    else
    {
      seq.push_back(TextTools::toInt(st2->getToken(0)));
    }  
  }  
  return seq;
}
开发者ID:pjotrp,项目名称:bio---numcalc,代码行数:19,代码来源:NumCalcApplicationTools.cpp

示例12: StringTokenizer

gdx_cpp::files::FileHandle& TileAtlas::getRelativeFileHandle (const gdx_cpp::files::FileHandle& path,const std::string& relativePath) {
    if (relativePath.trim().length() == 0) {
        return path;
    }

    FileHandle child = path;

    StringTokenizer tokenizer = new StringTokenizer(relativePath, "\\/");
    while (tokenizer.hasMoreTokens()) {
        String token = tokenizer.nextToken();
        if (token.equals("..")) {
            child = child.parent();
        } else {
            child = child.child(token);
        }
    }

    return child;
}
开发者ID:NoiSek,项目名称:libgdx-cpp,代码行数:19,代码来源:TileAtlas.cpp

示例13: theGuard

void
AVT::nextToken(
            StylesheetConstructionContext&  constructionContext,
            const LocatorType*              locator,
            StringTokenizer&                tokenizer,
            XalanDOMString&                 token)
{
    if (tokenizer.hasMoreTokens() == false)
    {
        GetCachedString     theGuard(constructionContext);

        constructionContext.error(
            XalanMessageLoader::getMessage(
                theGuard.get(),
                XalanMessages::AttributeValueTemplateHasMissing),
            0,
            locator);
    }
    else
    {
        tokenizer.nextToken(token);
    }
}
开发者ID:rherardi,项目名称:xml-xalan-c-src_1_10_0,代码行数:23,代码来源:AVT.cpp

示例14: readCookies

void CookieJar::readCookies(HttpHeader* header, CookieOrigin origin)
{
    // parse cookies if appropriate cookie field exists
    const char* field = (origin == Server ? "Set-Cookie" : "Cookie");
    int count = header->getFieldCount(field);
    if(count > 0)
    {
        // Set-Cookie: cookie1_name=cookie1_value; max-age=0; path=/
        // Set-Cookie: c2=v2; expires=Thu, 21-Aug-2008 23:47:25 GMT; path=/
        // Cookie: cookie1_name=cookie1_value; cookie2_name=cookie2_value

        // parse cookies by semi-colons (cannot parse by commas because
        // the "expires" value may contain a comma and no one follows the
        // standard)
        string cookies;
        Cookie cookie(NULL);
        TimeZone gmt = TimeZone::getTimeZone("GMT");
        Date d;
        Date now;
        bool name;
        StringTokenizer pairs;
        for(int i = 0; i < count; ++i)
        {
            name = true;
            header->getField(field, cookies, i);
            pairs.tokenize(cookies.c_str(), ';');
            while(pairs.hasNextToken())
            {
                // get next token (name=value)
                const char* token = pairs.nextToken();

                // get name part of token
                size_t nameLength = strcspn(token, "=");
                char tmpName[nameLength + 1];
                strncpy(tmpName, token, nameLength);
                tmpName[nameLength] = 0;

                // trim whitespace from name
                char* namePtr = (tmpName + nameLength);
                for(; namePtr != tmpName && *namePtr == ' '; --namePtr)
                {
                    *namePtr = 0;
                }
                for(namePtr = tmpName; *namePtr != 0 && *namePtr == ' ';
                        ++namePtr);

                // get value part of token (ensure value length is at least 0 in
                // case bad parsing because of no equals sign after name)
                size_t valueLength = strlen(token);
                valueLength = (nameLength == valueLength ?
                               0 : valueLength - nameLength - 1);
                char tmpValue[valueLength + 1];
                if(valueLength > 0)
                {
                    strncpy(tmpValue, token + nameLength + 1, valueLength);
                }
                tmpValue[valueLength] = 0;

                if(origin == Client)
                {
                    // set cookie
                    setCookie(namePtr, tmpValue, 0, false, false);
                }
                else
                {
                    if(name)
                    {
                        // first token *must* be cookie name = cookie value
                        cookie = Cookie();
                        cookie["name"] = namePtr;
                        cookie["value"] = tmpValue;
                        name = false;
                    }
                    else
                    {
                        if(strcmp(namePtr, "expires") == 0)
                        {
                            // parse expiration time
                            if(d.parse(tmpValue, HttpHeader::sDateFormat, &gmt))
                            {
                                int64_t age = d.getSeconds() - now.getSeconds();
                                cookie["maxAge"] = (age <= 0 ? 0 : age);
                            }
                            else
                            {
                                // bad date format, use maxAge of 0
                                cookie["maxAge"] = 0;
                            }
                        }
                        else if(strcasecmp(namePtr, "secure") == 0)
                        {
                            // cookie is secure
                            cookie["secure"] = true;
                        }
                        else if(strcasecmp(namePtr, "HttpOnly") == 0)
                        {
                            // cookie is http-only (non-javascript)
                            cookie["httpOnly"] = true;
                        }
                        else
//.........这里部分代码省略.........
开发者ID:zengyuxing007,项目名称:monarch,代码行数:101,代码来源:CookieJar.cpp

示例15: readBOUNDS

void MPSReader::readBOUNDS(){

  /*				type            meaning
                  ---------------------------------------------------
                  LO    lower bound        b <= x (< +inf)
                  UP    upper bound        (0 <=) x <= b
                  FX    fixed variable     x = b
                  FR    free variable      -inf < x < +inf
                  MI    lower bound -inf   -inf < x (<= 0)
                  PL    upper bound +inf   (0 <=) x < +inf
                  BV    binary variable    x = 0 or 1
                  LI    integer variable   b <= x (< +inf)
                  UI    integer variable   (0 <=) x <= b
                  SC    semi-cont variable x = 0 or l <= x <= b
                  l is the lower bound on the variable
                  If none set then defaults to 1*/

  //Como se trata de um bloco opcional dos problemas,
  //Apenas tratarei os tipos LO e UP.

  StringTokenizer *lineTokens = new StringTokenizer(line);
  string boundType;
  string boundName;
  string nomeVariavel;
  string boundValue;
  string auxRestName; //sera criada uma nova restricao se a fronteira for valida
  Desigualdade tipoDesigualdade;

  if (lineTokens->nextToken().compare("BOUNDS") == 0){

    line = fileReader->readLine();

    while (line.compare("ENDATA") != 0){

      lineTokens->setLine(line);

      //Ler no minimo 3 tokens
      //Nome variavel / Nome Funcao|Restricao / Valor variavel

      boundType = lineTokens->nextToken();
      boundName = lineTokens->nextToken();
      nomeVariavel = lineTokens->nextToken();
      boundValue = lineTokens->nextToken();

      if (boundType.compare("LO") == 0){
        tipoDesigualdade = MaiorOuIgual;
      }
      else if (boundType.compare("UP") == 0){
        tipoDesigualdade = MenorOuIgual;
      }
      auxRestName = funcao->addRestricao();
      //Configurar nova restricao
      funcao->addVariavelRestricao(auxRestName, nomeVariavel, 1.0);
      funcao->setDesigualdadeRestricao(auxRestName, tipoDesigualdade);
      funcao->setTermoLivreRestricao(auxRestName, stof(boundValue.c_str()));

      line = fileReader->readLine(); //ler nova linha ao final
    }

  }

}
开发者ID:vinishiru,项目名称:cuda-simplex,代码行数:62,代码来源:MPSReader.cpp


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