本文整理汇总了C++中KKStr::ToInt方法的典型用法代码示例。如果您正苦于以下问题:C++ KKStr::ToInt方法的具体用法?C++ KKStr::ToInt怎么用?C++ KKStr::ToInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KKStr
的用法示例。
在下文中一共展示了KKStr::ToInt方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseCmdLineParameter
void ModelParamUsfCasCor::ParseCmdLineParameter (const KKStr& parameter,
const KKStr& value,
bool& parameterUsed,
RunLog& log
)
{
parameterUsed = true;
if (parameter.EqualIgnoreCase ("-InLimit") ||
parameter.EqualIgnoreCase ("-IL") ||
parameter.EqualIgnoreCase ("-I")
)
in_limit = value.ToInt ();
else if (parameter.EqualIgnoreCase ("-OutLimit") ||
parameter.EqualIgnoreCase ("-OL") ||
parameter.EqualIgnoreCase ("-O")
)
out_limit = value.ToInt ();
else if (parameter.EqualIgnoreCase ("-NumberOfRounds") ||
parameter.EqualIgnoreCase ("-NOR") ||
parameter.EqualIgnoreCase ("-Rounds") ||
parameter.EqualIgnoreCase ("-R")
)
number_of_rounds = value.ToInt ();
else if (parameter.EqualIgnoreCase ("-NumberOfTrials") ||
parameter.EqualIgnoreCase ("-NOT") ||
parameter.EqualIgnoreCase ("-T")
)
number_of_trials = value.ToInt ();
else if (parameter.EqualIgnoreCase ("-RandomSeed") ||
parameter.EqualIgnoreCase ("-RS") ||
parameter.EqualIgnoreCase ("-S")
)
random_seed = value.ToInt ();
else if (parameter.EqualIgnoreCase ("-UseCache") ||
parameter.EqualIgnoreCase ("-UC") ||
parameter.EqualIgnoreCase ("-Cache")
)
{
if (value.Empty ())
useCache = true;
else
useCache = value.ToBool ();
}
else
parameterUsed = false;
} /* ParseCmdLineParameter */
示例2: ProcessStatusStr
void KKJob::ProcessStatusStr (const KKStr& statusStr)
{
log.Level (30) << "KKJob::ProcessStatusStr[" << statusStr << "]" << endl;
KKStr fieldName;
KKStr fieldValue;
VectorKKStr fields = statusStr.Split ('\t');
kkuint32 fieldNum = 0;
while (fieldNum < fields.size ())
{
fieldName = fields[fieldNum];
fieldNum++;
if (fieldNum < fields.size ())
{
fieldValue = fields[fieldNum];
fieldNum++;
}
else
{
fieldValue = "";
}
fieldName.Upper ();
fieldValue.TrimLeft ("\n\r\t ");
fieldValue.TrimRight ("\n\r\t ");
if (fieldName.CompareIgnoreCase ("JOBID") == 0)
jobId = atoi (fieldValue.Str ());
else if (fieldName.CompareIgnoreCase ("PARENTID") == 0)
parentId = atoi (fieldValue.Str ());
else if (fieldName.CompareIgnoreCase ("STATUS") == 0)
status = JobStatusFromStr (fieldValue);
else if (fieldName.CompareIgnoreCase ("NumProcessors") == 0)
numProcessors = fieldValue.ToInt ();
else if (fieldName.CompareIgnoreCase ("NumPorcessesAllowed") == 0)
numPorcessesAllowed = fieldValue.ToInt ();
else if (fieldName.CompareIgnoreCase ("Prerequisites") == 0)
PrerequisitesFromStr (fieldValue);
else
{
ProcessStatusField (fieldName, fieldValue);
}
}
} /* ProcessStatusStr */
示例3: ln
void RandomSplitJobManager::StatusFileProcessLine (const KKStr& _ln,
istream& statusFile
)
{
KKStr ln (_ln);
KKStr fieldName = ln.ExtractToken2 ("\t");
KKStr fieldValue = ln.ExtractToken2 ("\t");
if (fieldName.CompareIgnoreCase ("MLClasses") == 0)
mlClasses = MLClassList::BuildListFromDelimtedStr (fieldValue, ',');
else if (fieldName.CompareIgnoreCase ("ConfigFileName") == 0)
configFileName = fieldValue;
else if (fieldName.CompareIgnoreCase ("DataFileName") == 0)
dataFileName = fieldValue;
else if (fieldName.CompareIgnoreCase ("DataIndexFileName") == 0)
dataIndexFileName = fieldValue;
else if (fieldName.CompareIgnoreCase ("Format") == 0)
format = FeatureFileIO::FileFormatFromStr (fieldValue);
else if (fieldName.CompareIgnoreCase ("NumFolds") == 0)
numFolds = fieldValue.ToInt ();
else if (fieldName.CompareIgnoreCase ("NumSplits") == 0)
numSplits = fieldValue.ToInt ();
else if (fieldName.CompareIgnoreCase ("SplitFraction") == 0)
{
bool percentage = (fieldValue.LastChar () == '%');
if (percentage)
{
fieldValue.ChopLastChar ();
splitFraction = fieldValue.ToFloat () / 100.0f;
}
else
{
splitFraction = fieldValue.ToFloat ();
if (splitFraction > 1.0f)
splitFraction = splitFraction / 100.0f;
}
}
else
KKJobManager::StatusFileProcessLine (_ln, statusFile);
} /* StatusFileProcessLine */
示例4: ProcessCmdLineParameter
bool AbundanceCorrectionStatsBuilder::ProcessCmdLineParameter (char parmSwitchCode,
KKStr parmSwitch,
KKStr parmValue
)
{
KKStr parmValueUpper (parmValue);
parmValueUpper.Upper ();
if (parmSwitch.EqualIgnoreCase ("-c") || parmSwitch.EqualIgnoreCase ("-config"))
{
configFileName = parmValue;
configFileFullPath = TrainingConfiguration2::GetEffectiveConfigFileName (configFileName);
if (!osFileExists (configFileFullPath))
{
log.Level (-1) << "ProcessCmdLineParameter ***ERROR*** Invalid '-config' [" << configFileName << "] file." << endl;
Abort (true);
}
}
else if (parmSwitch.EqualIgnoreCase ("-folds") || parmSwitch.EqualIgnoreCase ("-numFolds") || parmSwitch.EqualIgnoreCase ("-numOfFolds"))
{
numOfFolds = parmValue.ToInt ();
if ((numOfFolds < 2) || (numOfFolds > 1000))
{
log.Level (-1) << "ProcessCmdLineParameter ***ERROR*** Invalid '-NumFolds' [" << numOfFolds << "] Invlaid; valid values (2 - 1000)." << endl;
Abort (true);
}
}
else if (parmSwitch.EqualIgnoreCase ("-r") || parmSwitch.EqualIgnoreCase ("-report") || parmSwitch.EqualIgnoreCase ("-ReportFileName"))
reportFileName = parmValue;
return !Abort ();
} /* ProcessCmdLineParameter */
示例5: ExtractHeaderField
void ScannerFile::ExtractHeaderField (const KKStr& fieldName,
const KKStr& fieldValue
)
{
if (fieldName.EqualIgnoreCase ("FrameHeight"))
{
kkuint32 fieldValueUint = fieldValue.ToInt32 ();
if ((fieldValueUint > 0) && (fieldValueUint < (1024 * 1024)))
frameHeight = fieldValue.ToInt32 ();
}
else if (fieldName.EqualIgnoreCase ("PixelsPerScanLine"))
pixelsPerScanLine = fieldValue.ToInt ();
else if (fieldName.EqualIgnoreCase ("ScanRate"))
scanRate = fieldValue.ToFloat ();
else if (fieldName.EqualIgnoreCase ("FlatFieldCorrectionEnabled"))
flatFieldEnabled = fieldValue.ToBool ();
} /* ExtractHeaderField */
示例6: ProcessCmdLineParameter
bool MergeFeatureFiles::ProcessCmdLineParameter (const KKStr& parmSwitch,
const KKStr& parmValue
)
{
bool validParm = true;
if (parmSwitch.EqualIgnoreCase ("-S") ||
parmSwitch.EqualIgnoreCase ("-SRC") ||
parmSwitch.EqualIgnoreCase ("-SOURCE")
)
{
KKStr srcFileName = parmValue;
if (!osFileExists (srcFileName))
{
log.Level (-1) << "ProcessCmdLineParameter ***ERROR*** Invalid '-src' [" << srcFileName << "] file." << endl;
Abort (true);
validParm = false;
}
srcFileNames.push_back (srcFileName);
srcFormats.push_back (currentDefaultFormat);
if (!currentDefaultFormat->CanRead ())
{
log.Level (-1) << "ProcessCmdLineParameter ***ERROR*** Format[" << currentDefaultFormat->DriverName () << "] does not support read." << endl;
Abort (true);
validParm = false;
}
}
else if
(parmSwitch.EqualIgnoreCase ("-DEST") ||
parmSwitch.EqualIgnoreCase ("-D") ||
parmSwitch.EqualIgnoreCase ("-DESTINATION")
)
{
if (!destFileName.Empty ())
{
log.Level (-1) << "ProcessCmdLineParameter ***ERROR*** More than one destination file was specified." << endl;
Abort (true);
validParm= false;
}
destFileName = parmValue;
if (osFileExists (destFileName))
{
log.Level (-1) << "ProcessCmdLineParameter ***ERROR*** Destination File[" << destFileName << "] already exists." << endl;
Abort (true);
validParm = false;
}
if (!currentDefaultFormat->CanWrite ())
{
log.Level (-1) << "ProcessCmdLineParameter ***ERROR*** Format[" << currentDefaultFormat->DriverName () << "] does not support write." << endl;
Abort (true);
validParm = false;
}
destFormat = currentDefaultFormat;
}
else if
(parmSwitch.EqualIgnoreCase ("-F") ||
parmSwitch.EqualIgnoreCase ("-FORMAT")
)
{
FeatureFileIOPtr newFormat = FeatureFileIO::FileFormatFromStr (parmValue);
if (!newFormat)
{
log.Level (-1) << "ProcessCmdLineParameter ***ERROR*** No such format as[" << parmValue<< "]." << endl;
Abort (true);
validParm = false;
}
else
{
currentDefaultFormat = newFormat;
}
}
else if
(parmSwitch.EqualIgnoreCase ("-STRAT") ||
parmSwitch.EqualIgnoreCase ("-STRATIFY")
)
{
stratify = true;
if (!parmValue.Empty ())
{
numOfFolds = parmValue.ToInt ();
if ((numOfFolds < 1) || (numOfFolds > 1000))
{
log.Level (-1) << "ProcessCmdLineParameter ***ERROR*** -Folds[" << numOfFolds << "] must be 1 or greater and less than 10000." << endl;
Abort (true);
validParm = false;
}
}
}
else if
(parmSwitch.EqualIgnoreCase ("-RAND") ||
parmSwitch.EqualIgnoreCase ("-RANDOM") ||
//.........这里部分代码省略.........
示例7: if
void KKJobManager::ProcessJobXmlBlockOfText (const KKStr& startStr,
istream& i
)
{
if ((startStr.SubStrPart (0, 4) != "<KKJob ") || (startStr.LastChar () != '>'))
{
log.Level (-1) << endl
<< "KKJobManager::ProcessJobXmlBlockOfText ***ERROR*** StartStr[" << startStr << "] is not a KKJob String." << endl
<< endl;
return;
}
KKStr s = startStr.SubStrPart (5);
s.TrimLeft ();
s.ChopLastChar ();
KKStr jobTypeStr = "";
kkint32 jobId = -1;
VectorKKStr parameters = s.Split (',');
for (kkuint32 x = 0; x < parameters.size (); ++x)
{
KKStr parameterStr = parameters[x];
parameterStr.TrimLeft ();
parameterStr.TrimRight ();
KKStr fieldName = parameterStr.ExtractToken2 ("=");
fieldName.TrimLeft (); fieldName.TrimRight ();
KKStr fieldValue = parameterStr.ExtractToken2 ("=");
fieldValue.TrimLeft (); fieldValue.TrimRight ();
if (fieldName.CompareIgnoreCase ("JobType") == 0)
jobTypeStr = fieldValue;
else if (fieldName.CompareIgnoreCase ("JobId") == 0)
jobId = fieldValue.ToInt ();
}
if (jobTypeStr.Empty () || (jobId < 0))
{
log.Level (-1) << endl
<< "KKJobManager::ProcessJobXmlBlockOfText ***ERROR*** StartStr[" << startStr << "]." << endl
<< " JobType and/or JobId were not provided." << endl
<< endl;
return;
}
KKJobPtr j = jobs->LookUpByJobId (jobId);
if (j == NULL)
{
// We do not have this job in memory yet. We will have to create it now.
KKStr emptyStatusStr = "JobId\t" + StrFormatInt (jobId, "ZZZZ0");
j = KKJob::CallAppropriateConstructor (this, jobTypeStr, emptyStatusStr);
}
j->CompletedJobDataRead (i);
} /* ProcessJobXmlBlockOfText */
示例8: StatusFileProcessLine
void KKJobManager::StatusFileProcessLine (const KKStr& ln,
istream& statusFile
)
{
if (ln.SubStrPart (0, 1) == "//")
{
// A coment line; we can ignore it.
return;
}
KKStr statusStr (ln);
KKStr fieldName = statusStr.ExtractToken2 ("\t");
if (fieldName.Empty ())
{
// A empty line we will ignore it.
return;
}
statusStr.TrimLeft ("\n\r\t ");
statusStr.TrimRight ("\n\r\t ");
if (fieldName.CompareIgnoreCase ("JOB") == 0)
{
// We have a KKJob entr line; the next field determines JobType fllowed by parameters for that JobType constructor.
KKStr jobTypeName = fieldName = statusStr.ExtractToken2 ("\t");
KKJobPtr j = KKJob::CallAppropriateConstructor (this, jobTypeName, statusStr);
KKJobPtr existingJob = jobs->LookUpByJobId (j->JobId ());
if (existingJob)
{
existingJob->ReFresh (*j);
delete j; j = NULL;
}
else
{
jobs->PushOnBack (j);
}
}
else if (fieldName.EqualIgnoreCase ("CPUTIMEUSED"))
{
double cpuTimeUsed = statusStr.ExtractTokenDouble ("\t");
cpuTimeTotalUsed += cpuTimeUsed;
}
else if (fieldName.EqualIgnoreCase ("CURRENTDATETIME"))
{
KKB::DateTime dateTime = KKB::DateTime (statusStr);
if (!dateTimeFirstOneFound)
{
dateTimeFirstOneFound = true;
dateTimeStarted = dateTime;
}
dateTimeEnded = dateTime;
}
else if (fieldName.EqualIgnoreCase ("ExpansionCount"))
expansionCount = statusStr.ToInt ();
else if (fieldName.EqualIgnoreCase ("ExpansionFirstJobId"))
expansionFirstJobId = statusStr.ToInt ();
else if (fieldName.EqualIgnoreCase ("JobStatusChange"))
StatusFileProcessLineJobStatusChange (statusStr);
else if (fieldName.EqualIgnoreCase ("NextJobId"))
nextJobId = statusStr.ExtractTokenInt ("\t");
else if (fieldName.EqualIgnoreCase ("QuitRunning"))
quitRunning = true;
else if (fieldName.EqualIgnoreCase ("Restart"))
restart = false;
else if (fieldName.EqualIgnoreCase ("Status"))
status = KKJob::JobStatusFromStr (statusStr);
else
{
log.Level (-1) << "KKJobManager::StatusFileProcessLine Invalid Field Name[" << fieldName << "]." << endl;
}
} /* StatusFileProcessLine */
示例9: ReadXML
void ClassificationBiasMatrix::ReadXML (istream& sr)
{
char buff[10240];
KKStr l (512);
if (sr.eof ())
return;
MLClassListPtr fileClasses = NULL;
sr.getline (buff, sizeof (buff));
while (!sr.eof ())
{
l = buff;
l.TrimRight ();
if (l.CompareIgnoreCase ("</ClassificationBiasMatrix>") == 0)
break;
KKStr lineName = l.ExtractToken2 ("\t");
if (!lineName.Empty ())
{
KKStr fieldValue = l.ExtractToken2 ("\t");
if (lineName.CompareIgnoreCase ("Classes") == 0)
{
delete fileClasses; fileClasses = NULL;
fileClasses = MLClassList::BuildListFromDelimtedStr (fieldValue, ',');
if (classes == NULL)
classes = new MLClassList (*fileClasses);
}
else if (lineName.CompareIgnoreCase ("ConfigDateTime") == 0)
{
configDateTime = fieldValue;
}
else if (lineName.CompareIgnoreCase ("ConfigFileName") == 0)
{
configFileNameFromMatrixBiasFile = fieldValue;
}
else if (lineName.CompareIgnoreCase ("ConfigFileDateTime") == 0)
{
configDateTime = fieldValue;
}
else if (lineName.CompareIgnoreCase ("DateTime") == 0)
{
dateTimeFileWritten = fieldValue;
}
else if (lineName.CompareIgnoreCase ("DateTimeFileWritten") == 0)
{
dateTimeFileWritten = fieldValue;
}
else if (lineName.CompareIgnoreCase ("FileName") == 0)
{
}
else if (lineName.CompareIgnoreCase ("NumClasses") == 0)
{
numClasses = fieldValue.ToInt ();
}
else if (lineName.CompareIgnoreCase ("<SimpleConfusionMatrix>") == 0)
{
ReadSimpleConfusionMatrix (sr, fileClasses);
}
}
if (!sr.eof ())
sr.getline (buff, sizeof (buff));
}
} /* ReadXML */
示例10: ProcessCmdLineParameter
bool RandomSplits::ProcessCmdLineParameter (char parmSwitchCode,
KKStr parmSwitch,
KKStr parmValue
)
{
KKStr parmValueUpper (parmValue);
parmValueUpper.Upper ();
parmSwitch.Upper ();
if ((parmSwitch == "-CONFIGFILENAME") || (parmSwitch == "-C") || (parmSwitch == "-CONFIG"))
{
configFileName = parmValue;
}
else if ((parmSwitch == "-DATAFILE") || (parmSwitch == "-DF"))
{
dataFileName = parmValue;
}
else if ((parmSwitch == "-F") || (parmSwitch == "-FORMAT"))
{
format = FeatureFileIO::FileFormatFromStr (parmValue);
if (!format)
{
log.Level (-1) << endl << endl
<< "ProcessCmdLineParameter ***ERROR*** No such format as[" << parmValue<< "]." << endl
<< endl;
Abort (true);
}
}
else if (parmSwitch.EqualIgnoreCase ("-NumFolds") ||
parmSwitch.EqualIgnoreCase ("-NF") ||
parmSwitch.EqualIgnoreCase ("-NumOfFolds") ||
parmSwitch.EqualIgnoreCase ("-NOF")
)
{
numFolds = parmValue.ToInt ();
if ((numFolds != 0) && (numFolds < 2))
{
log.Level (-1) << endl
<< "ProcessCmdLineParameter ***ERROR*** Invalid NumFolds[" << parmValue<< "]." << endl
<< " Must be '0' or greter than '1'." << endl
<< endl;
Abort (true);
}
}
else if ((parmSwitch == "-NUMSPLITS") || (parmSwitch == "-NS") || (parmSwitch == "-SPLITS"))
{
numSplits = parmValue.ToInt ();
}
else if ((parmSwitch == "-SPLITPERCENTAGE") || (parmSwitch == "-SP"))
{
bool percentage = false;
if (parmValue.LastChar () == '%')
{
percentage = true;
parmValue.ChopLastChar ();
}
splitFraction = parmValue.ToFloat ();
if (percentage)
splitFraction = splitFraction / 100.0f;
else
{
if (splitFraction >= 1.0f)
{
log.Level (-1) << endl << endl
<< "ProcessCmdLineParameter ***ERROR*** Invalid Split Percentage[" << splitFraction << "]" << endl
<< endl
<< " If you want to enter as percentage include a '%' sign otherwise it is assumed to be a fraction." << endl
<< endl;
}
}
}
else if (parmSwitch.EqualIgnoreCase ("Restart"))
{
restart = true;
}
else
{
log.Level (-1) << endl << endl
<< "ProcessCmdLineParameter ***ERROR***" << endl
<< endl
<< " Invalid Parameter[" << parmSwitch << "]" << endl
<< endl;
Abort (true);
}
return !Abort ();
} /* ProcessCmdLineParameter */