本文整理汇总了C++中KKStr::ToFloat方法的典型用法代码示例。如果您正苦于以下问题:C++ KKStr::ToFloat方法的具体用法?C++ KKStr::ToFloat怎么用?C++ KKStr::ToFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KKStr
的用法示例。
在下文中一共展示了KKStr::ToFloat方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 */
示例2: ProcessData
void InstrumentDataPitchAndRoll::ProcessData (const KKStr& txt)
{
VectorKKStr fields = txt.Split (" \t\n\r");
if (fields.size () < 4)
return;
float pitch = -999.99f;
float roll = -999.99f;
KKStr fieldName = "";
KKStr fieldValue = "";
kkuint32 fieldNum = 0;
while (fieldNum < fields.size ())
{
fieldName = fields[fieldNum];
fieldName.Upper ();
fieldNum++;
if (fieldNum < fields.size ())
{
fieldValue = fields[fieldNum];
fieldNum++;
}
else
{
fieldValue = "";
}
if (fieldName == "R")
{
roll = fieldValue.ToFloat ();
}
else if (fieldName == "P")
{
pitch = fieldValue.ToFloat ();
}
}
manager->PitchAndRollData (curTextLineStartScanLine, pitch, roll);
} /* ProcessData */
示例3: 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 */
示例4: 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 */