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


C++ Split::setSeparator方法代码示例

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


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

示例1: ostr

void
Date::addTime(std::string time, std::string unit)
{
    Split splt;

    // default for units: inherent units
    if( unit.size() == 0 )
        unit = unitStr;

    // It is save to append units (even if empty) to time
    // Note: time-unit overrules parameter unit.
    time += unit;

    // Split string at positions where digits and characters alternate.
    splt.setSeparator(":alnum:");
    splt = time ;

    // If there is a mix of digits and non-digits, splt.size() >= 2:
    // isNonDigit && size == 1 is an error.
    // size == 0 is an error.
    // But, for !isNonDigit && size == 1 we got the default

    bool isNon = ! hdhC::isDigit(time);

    if( (splt.size() == 1 && isNon) || (splt.size() == 0) )
    {
        std::ostringstream ostr(std::ios::app);
        ostr << "Date::addTime()"
             << "\nerror in 2nd parameter (time=" << time << ")" ;
        exceptionError( ostr.str() );
    }

    // unitStr and int strings are empty.
    // Pure digits are always converted to days.
    if( splt.size() == 1 )
    {
        addDays( splt.toDouble(0) ) ;
        return;
    }

    std::string str(splt[1]);

    if( str[0] == 'y' )
        addYears( splt.toDouble(0) );
    else if( str.substr(0,2) == "mo" )
        addMonths( splt.toDouble(0) );
    else if( str[0] == 'd' )
        addDays( splt.toDouble(0) );
    else if( str[0] == 'h' )
        addHours( splt.toDouble(0) );
    else if( str.substr(0,2) == "mi" )
        addMinutes( splt.toDouble(0) );
    else if( str[0] == 's' )
        addSeconds( splt.toDouble(0) );

    return;
}
开发者ID:IS-ENES-Data,项目名称:QA-DKRZ,代码行数:57,代码来源:Date.cpp

示例2: split


//.........这里部分代码省略.........
  }

  for( size_t i=0 ; i < optStr.size() ; ++i)
  {
     Split split(optStr[i], "=");

     if( split[0] == "cM"
       || split[0] == "checkMode"
         || split[0] == "check_mode" )
     {
       if( split.size() == 2 )
         setCheckMode(split[1]);
        continue;
     }

     if( split[0] == "dIP"
          || split[0] == "dataInProduction"
              || split[0] == "data_in_production" )
     {
        // effects completeness test in testPeriod()
        isFileComplete=false;
        continue;
     }

     if( split[0] == "dP"
          || split[0] == "dataPath" || split[0] == "data_path" )
     {
        if( split.size() == 2 )
          // path to the directory where the execution takes place
          qaFile.setPath(split[1]);

        continue;
     }

     if( split[0] == "f" )
     {
       if( split.size() == 2 )
          qaFile.setFile(split[1]);
        continue;
     }

     if( split[0] == "fS" || split[0] == "FileSequence"
         || split[0] == "file_sequence" )
     {
        if( split.size() == 2 )
          fileSequenceState=split[1][0];

        continue;
     }

     if( split[0] == "oT"
           || split[0] == "outlierTest"
                || split[0] == "outlier_test" )
     {
        if( enablePostProc && split.size() == 2 )
          outlierOpts.push_back(split[1]);

        continue;
     }

     if( split[0] == "qNF" || split[0] == "qaNcfileFlags"
       || split[0] == "qa_ncfile_flags" )
     {
       if( split.size() == 2 )
          qaNcfileFlags=split[1];
        continue;
     }

     if( split[0] == "rR"
            || split[0] == "replicatedRecord"
                 || split[0] == "replicated_record" )
     {
       if( split.size() > 1 )
       {
          // input could be: ..., only_groups=num
          // then num would be in split[2]
          std::string tmp( split[1] );
          if( split.size() == 3 )
          {
            tmp += '=' ;
            tmp += split[2] ;
          }

          Split csv ;
          csv.setSeparator(",");
          BraceOP groups(tmp);
          while ( groups.next(tmp) )
          {
            csv = tmp;
            for( size_t i=0 ; i < csv.size() ; ++i )
              replicationOpts.push_back(csv[i]);
          }

          continue;
       }
     }
   }

   return;
}
开发者ID:bird-house,项目名称:QA-DKRZ,代码行数:101,代码来源:QA.cpp

示例3: list

void
Base::applyOptions()
{
   // options only applicable to Base properties

   Split split;
   split.setSeparator("=");

   // now we apply to the varNames found
   for( size_t j=0 ; j < optStr.size() ; ++j)
   {
     split = optStr[j];
     if( split.size() == 2 )
     {
       if( isVarname( split[0] ) )
       {
         if( getObjName() == "IN" )
           continue;
         else
         {
           Split list(split[1], ",");
           for( size_t i=0 ; i < list.size() ; i++)
             varName.push_back( list[i] );
         }
       }

       if( split[0][0] == 'f' )
       {
         setFilename( split[1] );

         continue;
       }

       if( split[0] == "filling_value" ||
              split[0] == "fillingValue" || split[0] == "fV"
                  || split[0] == "_FillValue" )
       {
         isMissValSet=true;
         Split spltFV(split[1],",");
         for( size_t i=0 ; i < spltFV.size() ; ++i)
           fillingValue.push_back( spltFV.toDouble(i) ) ;
         continue;
       }

     }

     // skip ident number
     if( split.isNumber(0) )
        continue;

     // these are applied to each GD obj
//     for( size_t i=0 ; i < pGM.size() ; ++i)
/*
     {
       if( split[0] == "back_rotation"
            || split[0] == "backRotation")
       {
         isBackRotation=true;
         pGM[i]->setBackRotation();
         continue;
       }
*/

/*
       if( split[0] == "gmt_multi_segment"
            || split[0] == "gmtMultiSegment" )
       {
         pGM[i]->setOutputGMT_MultiSegment();
         continue;
       }

       if( split[0] == "oF" )
       {
         pGM[i]->setPrintFilename(split[1]);
         continue;
       }

       if( split[0] == "print_cells" || split[0] == "printCells" )
       {
         pGM[i]->setPrintWithGeoCoord();
         continue;
       }

       if( split[0].substr(0,3) == "reg"
            || split[0].substr(0,3) == "Reg" )
       {
         regionFile = split[1];
         continue;
       }
*/
//     }
   }

   return;
}
开发者ID:h-dh,项目名称:QA-DKRZ,代码行数:95,代码来源:Base.cpp

示例4: enablePrintOnlyMarked

int
Ensemble::testAmbiguity( std::string &str,
   bool is_only_marked,
   bool isModificationTest,
   bool isMixingRefused )
{
  // this function operates on the time-sorted files

  //detect a renewed data set testing internal time values
  if( isWithTarget )
  {
    // Note that last points to the target
    if( member[last]->end  >  member[sz-1]->end )
    {
      startIndex = sz-1;
      sz = member.size();
      enablePrintOnlyMarked();

      str = getOutput();
      return 32;
    }
  }

  // may have added 10 eventually, depending on the type of error
  int returnVal=0;

  // test modification time against the target
  if( isModificationTest && isWithTarget )
  {
    int rV=0;
    for( size_t i=0 ; i < sz ; ++i)
    {
       // note: 'later than' is equivalent to 'greater than'
       if( member[last]->modTime  <  member[i]->modTime )
       {
         enablePrintEnsemble();
         member[i]->enableModTimeNote();

         member[i]->putState("modification time") ;
         if(!rV)
         {
           rV=2;
           returnVal += rV;
         }
       }
    }
  }

  // check the correct sequence of dates in the filename
  std::string t;
  std::string t0_b;
  std::string t0_e;
  std::string t1_b;
  std::string t1_e;
  Split splt;
  splt.setSeparator('-');

  bool isRange=false;
  bool isSingular=false;

  // check ascending begin and end dates from filenames, respectively.
  for( size_t i=0 ; i < sz ; ++i)
  {
     t1_b.clear();
     t1_e.clear();

     size_t pos=member[i]->filename.rfind('_') + 1  ;
     t=member[i]->filename.substr( pos ) ;

     if( (pos=t.rfind(".nc")) < std::string::npos )
       t=t.substr(0,pos);

     splt=t;  // separate the dates

     // ensures that filenames without dates work
     t1_b='X';
     t1_e='X';

     if( splt.size() > 0 )
     {
       if( hdhC::isDigit( splt[0] ) )
          t1_b = splt[0] ;

       if( splt.size() == 2 )
       {
         if( hdhC::isDigit( splt[1] ) )
            t1_e = splt[1] ;
         isRange=true;
       }
       else  // singular date
       {
          t1_e = t1_b;
          isSingular=true;
       }
     }

     if( i > 0 && t0_e > t1_b )
     {
       member[i-1]->putState("misaligned filename dates");
       member[i]->putState("misaligned filename dates");
//.........这里部分代码省略.........
开发者ID:bird-house,项目名称:QA-DKRZ,代码行数:101,代码来源:syncFiles.cpp


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