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


C++ KKStr::ExtractToken方法代码示例

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


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

示例1: minute

TimeType::TimeType (KKStr  s):
   hour   (0),
   minute (0),
   second (0)

{
  KKStr  field1, field2, field3;

  if  (s.Len () == 6)
  {
    field1 = s.SubStrPart (0, 1);
    field2 = s.SubStrPart (2, 3);
    field3 = s.SubStrPart (4, 5);
  }
  else
  {
    field1 = s.ExtractToken ("\n\r\t: ");
    field2 = s.ExtractToken ("\n\r\t: ");
    field3 = s.ExtractToken ("\n\r\t: ");
  }

  int32  f1 = atoi (field1.Str ());
  int32  f2 = atoi (field2.Str ());
  int32  f3 = atoi (field3.Str ());
 

  if  (((f1 >= 0)  &&  (f1 <= 24))  &&
       ((f2 >= 0)  &&  (f2 <= 59))  &&
       ((f3 >= 0)  &&  (f3 <= 59))
      )
  {
    hour    = (uchar)f1;
    minute  = (uchar)f2;
    second  = (uchar)f3;
  }
}
开发者ID:jizhihang,项目名称:Pices-XXX-,代码行数:36,代码来源:DateTime.cpp

示例2: Load

void  RandomSampleJobList::Load (TrainingConfigurationPtr  _config,
                                 OrderingsPtr              _orderings,
                                 int                       _numExamplesToKeep
                                )
{
  FILE*  in = fopen (jobFileName.Str (), "r");
  if  (!in)
  {
    log.Level (-1) << endl
                   << endl
                   << "RandomSampleJobList::Load    *** ERROR ***" << endl
                   << endl
                   << "     Error Opening Status File[" << jobFileName << "]" << endl
                   << endl;
    exit (-1);
  }

  char  buff[10240];

  while  (fgets (buff, sizeof (buff), in))
  {
    KKStr  statusStr (buff);
    if  (statusStr.SubStrPart (0, 1) == "//")
    {
      // We have a comment line,  we want to ignore.
    }
    else
    {
      KKStr  field = statusStr.ExtractToken (" \t\n\r");
      field.Upper ();
      if  (field == "JOB")
      {
        RandomSampleJobPtr j = new RandomSampleJob (_config, _orderings, _numExamplesToKeep, statusStr);
        PushOnBack (j);
      }
    }
  }

  fclose (in);
}  /* Load */
开发者ID:jizhihang,项目名称:Pices-XXX-,代码行数:40,代码来源:RandomSampleJob.cpp

示例3: PerformMorphOperations

void  LogicalFrame::PerformMorphOperations ()
{
  KKStr  ops = parms.MorphOperations ();

  memcpy (origFrameArea, frameArea, frameTotalPixels);
  
  while  (!ops.Empty ())
  {
    KKStr  nextOp = ops.ExtractToken (",\n\r\t");
    nextOp.Upper ();
    if  (nextOp == "O")
      PerformOpening ();

    else if  (nextOp == "C")
      PerformClosing ();

    else if  (nextOp == "D")
      PerformDialation ();

    else if  (nextOp == "E")
      PerformErosion ();
  }

}  /* PerformMorphOperations */
开发者ID:KurtKramer,项目名称:Pices,代码行数:24,代码来源:LogicalFrame.cpp

示例4: ForestCover_AddMnemonicClassName

void  ForestCover_AddMnemonicClassName ()
{
  const char*  classNames[] = {"Spruce_Fir",
                               "Lodgepole_Pine",
                               "Ponderosa_Pine",
                               "Cottonwood_Willow",
                               "Aspen",
                               "Douglas_fir",
                               "Krummholz",
                               NULL
                              };

  FILE* in = osFOPEN  ("K:\\Plankton\\Papers\\BitReduction\\DataSets\\ForestCover\\covtype.data", "r");
  ofstream o ("K:\\Plankton\\Papers\\BitReduction\\DataSets\\ForestCover\\covtype_alpha.data");

  char  buff[20480];

  int  lc = 0;

  while  (fgets (buff, sizeof (buff), in))
  {
    KKStr  ln (buff);

    vector<KKStr>  tokens;

    while  (!ln.Empty ())
    {
      KKStr  token = ln.ExtractToken (",\n\t\r");
      tokens.push_back (token);
    }

    int  lastFieldNum = (int)tokens.size () - 1;
    KKStr  lastToken = tokens[lastFieldNum];
    int  classNum = atoi (lastToken.Str ()) - 1;

    if  ((classNum < 0)  ||  (classNum > 6))
    {
      // Something has gone very wrong.
      cerr  << endl
            << "    *** ERROR ***" << endl
            << endl
            << buff << endl
            << endl
            << "ClassNum[" << classNum << "] Out of range." << endl
            << endl;
      osWaitForEnter ();
      exit (-1);
    }

    KKStr  className = classNames[classNum];
    tokens[lastFieldNum] = className;

    int  x = 0;
    vector<KKStr>::const_iterator idx;
    for (idx = tokens.begin ();  idx != tokens.end ();  idx++)
    {
      if  (x > 0)
        o << ",";
        o << *idx;
      x++;
    }
    o << endl;
    lc++;

    if ((lc % 100) == 0)
      cout << lc << endl;
  }

  fclose (in);
  o.close ();
}  /* ForestCover_AddMnemonicClassName */
开发者ID:jizhihang,项目名称:Pices-XXX-,代码行数:71,代码来源:FeatureFileConverter.cpp

示例5: Load

void  ActiveLearningReport::Load (KKStr   fileName,
                                  bool&    validFormat
                                 )
{
  validFormat = false;

  FILE*  f = osFOPEN (fileName.Str (), "r");

  if  (!f)
  {
    log.Level (-1) << endl
                   << "ActiveLearningReport::Load        *** ERROR ***" << endl
                   << endl
                   << "                      Could noty open File[" << fileName << "]" << endl
                   << endl;
    return;
  }

  char  buff[10240];

  bool  fileParmsLoaded = false;

 
  {
    // Get Frst Row wicj should be InitialTrainingImagesPerClass 
    if  (!fgets (buff, sizeof (buff), f))
    {
      log.Level (-1) << endl
                     << "ActiveLearningReport::Load        *** ERROR ***" << endl
                     << endl
                     << "                      *** No Data ***" << endl
                     << endl;
      fclose (f);
      return;
    }

    KKStr l (buff);
    l.Upper ();

    KKStr  field = l.ExtractToken ("\n\t\r ");
    if  (field != "\\INITIALTRAININGIMAGESPERCLASS")
    {
      log.Level (-1) << endl
                     << "ActiveLearningReport::Load        *** ERROR ***" << endl
                     << endl
                     << "  First Liine Not Valid[" << l << "]" << endl
                     << endl;
      fclose (f);
      return;
    }
    
    initialImagesPerClass = l.ExtractTokenInt ("\n\t\r ");
  }

  {
    // Get second Row wicj should be ImagesPerRetraining
    if  (!fgets (buff, sizeof (buff), f))
    {
      log.Level (-1) << endl
                     << "ActiveLearningReport::Load        *** ERROR ***" << endl
                     << endl
                     << "              *** Missing Second Line ***" << endl
                     << endl;
      fclose (f);
      return;
    }
    
    KKStr l (buff);
    l.Upper ();

    KKStr  field = l.ExtractToken ("\n\t\r ");
    if  (field != "\\IMAGESPERRETRAINING")
    {
      log.Level (-1) << endl
                     << "ActiveLearningReport::Load        *** ERROR ***" << endl
                     << endl
                     << "  Second Liine Not Valid[" << l << "]" << endl
                     << endl;
      fclose (f);
      return;
    }
    
    imagesPerRetraining = l.ExtractTokenInt ("\n\t\r ");
  }


  SortOrderResultsPtr  curSortOrderResults = NULL;

  while  (fgets (buff, sizeof (buff), f))
  {
    KKStr l (buff);

    if  (l.SubStrPart (0, 0) == "\\")
    {
      if  (curSortOrderResults)
      {
        results.PushOnBack (curSortOrderResults);
        curSortOrderResults = NULL;
      }

//.........这里部分代码省略.........
开发者ID:jizhihang,项目名称:Pices-XXX-,代码行数:101,代码来源:ActiveLearningReport.cpp

示例6: if

DateType::DateType (KKStr  s):
   year  (0),
   month (0),
   day   (0)
{
  KKStr  field1 = s.ExtractToken ("\n\r\t/ ");
  KKStr  field2 = s.ExtractToken ("\n\r\t/ ");
  KKStr  field3 = s.ExtractToken ("\n\r\t/ ");

  uchar  m;
  uchar  d;
  short  y;

  m = MonthFromStr (field1);
  if  ((m > 0)  && (m < 13))
  {
    // The first field is a month, assume  mmm/dd/yyyy
    d = (uchar)atoi (field2.Str ());
    y = (short)atoi (field3.Str ());

    if  ((d < 1)  ||  (d > DaysInTheMonth (y, m)))
      d = 1;

    year  = y;
    month = m;
    day   = d;

    return;
  }

  m = MonthFromStr (field2);
  if  ((m > 0)  && (m < 13))
  {
    // Second field is a month field, assuming  yyyy/mmm/dd
    int32 f3 = atoi (field3.Str ());
    int32 f1 = atoi (field1.Str ());
    
    if  (f3 > 1900)
    {
      y = (short)f3;
      d = (uchar)f1;
    }
    else
    {
      y = (short)f1;
      d = (uchar)f3;
    }

    if  (d < 1)
      d = 1;
    else if  (d > DaysInTheMonth (y, m))
      d = DaysInTheMonth (y, m);

    year  = y;
    month = m;
    day   = d;

    AdjustYear ();

    return;
  }

  int32 f1 = atoi (field1.Str ());
  int32 f2 = atoi (field2.Str ());
  int32 f3 = atoi (field3.Str ());

  if  (((f1 >= 1)  &&  (f1 <= 12))  &&
       ((f2 >= 1)  &&  (f2 <= 31))  &&
       ((f3 >= 0)  &&  (f3 <= 9999))
      )
  {
    // mm/dd/yyyy
    year  = short (f3);
    month = uchar (f1);
    day   = uchar (f2);

    AdjustYear ();
    return;
  }

  if  (((f1 >= 0)  &&  (f1 <= 9999))  &&
       ((f2 >= 1)  &&  (f2 <= 12))    &&
       ((f3 >= 1)  &&  (f3 <= 31))
      )
  {
    // yyyy/mm/dd
    year  = short (f1);
    month = uchar (f2);
    day   = uchar (f3);
    AdjustYear ();
    return;
  }

  if  (((f1 >= 0)  &&  (f1 <= 31))  &&
       ((f2 >= 1)  &&  (f2 <= 12))    &&
       ((f3 >= 1)  &&  (f3 <= 9999))
      )
  {
    // dd/mm/yyyy
    year  = short (f3);
//.........这里部分代码省略.........
开发者ID:jizhihang,项目名称:Pices-XXX-,代码行数:101,代码来源:DateTime.cpp

示例7: ProcessStatusStr

void  RandomSampleJob::ProcessStatusStr (KKStr  statusStr)
{
  log.Level (30) << "RandomSampleJob::ProcessStatusStr[" << statusStr << "]" << endl;
  KKStr  fieldName;
  KKStr  fieldValue;

  compMethod = BRNull;

  fieldName = statusStr.ExtractToken ("\t\n\r");

  while  (!fieldName.Empty ())
  {
    fieldName.Upper ();

    fieldValue = statusStr.ExtractToken ("\t\n\r");
    fieldValue.TrimLeft ("\n\r\t ");
    fieldValue.TrimRight ("\n\r\t ");

    if  (fieldName == "JOBID")
      jobId = atoi (fieldValue.Str ());

    else if  (fieldName == "STATUS")
      status = JobStatusFromStr (fieldValue);

    else if  (fieldName == "KERNEL")
      kernelType = KernalTypeFromStr (fieldValue);

    else if  (fieldName == "ENCODING")
      encodingMethod = EncodingMethodFromStr (fieldValue);

    else if  (fieldName == "COMPMETHOD")
      compMethod = CompressionMethodFromStr (fieldValue);

    else if  (fieldName == "C_PARAM")
      c = atoi (fieldValue.Str ());

    else if  (fieldName == "GAMMA")
      gamma = atof (fieldValue.Str ());

    else if  (fieldName == "ORDERINGNUM")
      orderingNum = atoi (fieldValue.Str ());

    else if  (fieldName == "EXAMPLESTOKEEP")
      numExamplesToKeep = atoi (fieldValue.Str ());

    else if  (fieldName == "ACCURACY")
      accuracy = (float)atof (fieldValue.Str ());

    else if  (fieldName == "TRAINTIME")
    {
      trainTime = atof (fieldValue.Str ());
    }

    else  if  (fieldName == "PREDTIME")
      testTime = (float)atof (fieldValue.Str ());

    else if  (fieldName == "SUPPORTVECTORS")
      supportVectors = (float)atof (fieldValue.Str ());

    else
    {
      log.Level (-1) << "RandomSampleJob::ProcessStatusStr  Invalid Field Name[" << fieldName << "]." << endl;
    }

    fieldName = statusStr.ExtractToken ("\t\n\r");
  }
}  /* ProcessStatusStr */
开发者ID:jizhihang,项目名称:Pices-XXX-,代码行数:67,代码来源:RandomSampleJob.cpp


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