本文整理汇总了C++中KKStr::ExtractToken2方法的典型用法代码示例。如果您正苦于以下问题:C++ KKStr::ExtractToken2方法的具体用法?C++ KKStr::ExtractToken2怎么用?C++ KKStr::ExtractToken2使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KKStr
的用法示例。
在下文中一共展示了KKStr::ExtractToken2方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StatusFileProcessLineJobStatusChange
void KKJobManager::StatusFileProcessLineJobStatusChange (KKStr& statusLineStr)
{
kkint32 expandedJobId = statusLineStr.ExtractTokenInt ("\t");
KKJobPtr j = jobs->LookUpByJobId (expandedJobId);
if (!j)
{
log.Level (-1) << endl << endl << endl
<< "ProcessStatusLineJobStatusChange ***Error*** Could not locate Expanded" << endl
<< endl
<< " JobId[" << expandedJobId << "]" << endl
<< endl;
EndBlock ();
osWaitForEnter ();
exit (-1);
}
KKStr statusStr = statusLineStr.ExtractToken2 ("\t");
statusStr.TrimLeft ();
statusStr.TrimRight ();
KKJob::JobStatus status = KKJob::JobStatusFromStr (statusStr);
if (status == jsNULL)
{
log.Level (-1) << endl << endl << endl
<< "ProcessStatusLineJobStatusChange ***Error*** Invalid Status Specified" << endl
<< endl
<< " JobId[" << expandedJobId << "]" << endl
<< " Status[" << statusStr << "]" << endl
<< endl;
EndBlock ();
osWaitForEnter ();
exit (-1);
}
j->Status (status);
} /* ProcessStatusLineJobStatusChange */
示例2: ProcessGPGLL
/**
* @brief Processes a GPGLL string that contains Latitude and Longitudinal info.
* @param[in] _str '$GPGLL' string with '$GPGLL' stripped off front.
*/
void InstrumentDataGPS::ProcessGPGLL (const KKStr& _str)
{
KKStr str (_str);
KKStr field = str.ExtractToken2 (",");
if (field == "$GPGLL")
field = str.ExtractToken2 (",");
double latitudeDegrees;
double latitudeMinutes;
ParseDegreeMinutesStr (field, latitudeDegrees, latitudeMinutes);
double latitude = latitudeDegrees + (latitudeMinutes / 60.0);
field = str.ExtractToken2 (",");
if (field == "S")
latitude = -latitude;
field = str.ExtractToken2 (",");
double longitudeDegrees;
double longitudeMinutes;
ParseDegreeMinutesStr (field, longitudeDegrees, longitudeMinutes);
double longitude = longitudeDegrees + (longitudeMinutes / 60.0);
field = str.ExtractToken2 (",");
if (field == "E")
longitude = -longitude;
field = str.ExtractToken2 (",");
TimeType gpsTime (field);
manager->Location (curTextLineStartScanLine, latitude, longitude, gpsTime);
} /* ProcessGPGLL */
示例3: GuessFormatOfFile
ScannerFile::Format ScannerFile::GuessFormatOfFile (const KKStr& _fileName,
RunLog& _log
)
{
// Will guess what file format by trying to open each one until one is considered valid.
FILE* f = osFOPEN (_fileName.Str (), "rb");
if (!f)
return Format::sfUnKnown;
bool endOfText = false;
KKStr ln (100);
ReadHeaderOneLine (f, endOfText, ln);
fclose (f);
KKStr fieldName = ln.ExtractToken2 ("\t");
if (!fieldName.EqualIgnoreCase ("ScannerFile"))
return Format::sfUnKnown;
KKStr scannerFileFormatStr = ln.ExtractToken2 ("\t");
return ScannerFileFormatFromStr (scannerFileFormatStr);
} /* GuessFormatOfFile */
示例4: tagStr
XmlTag::XmlTag (istream& i)
{
tagType = tagNULL;
if (i.peek () == '<')
i.get ();
KKStr tagStr (100);
ReadWholeTag (i, tagStr);
if (tagStr.FirstChar () == '/')
{
tagStr.ChopFirstChar ();
tagType = tagEnd;
}
if (tagStr.EndsWith ("/>"))
{
tagType = tagEmpty;
tagStr.ChopLastChar ();
tagStr.ChopLastChar ();
}
else if (tagStr.LastChar () != '>')
{
tagType = tagStart;
}
else
{
if (tagType == tagNULL)
tagType = tagStart;
tagStr.ChopLastChar ();
}
name.TrimLeft ();
name.TrimRight ();
name = tagStr.ExtractToken2 (" \n\r\t");
KKStr attributeName (20);
KKStr attributeValue (20);
while (!tagStr.Empty ())
{
ExtractAttribute (tagStr, attributeName, attributeValue);
if (!attributeName.Empty ())
attributes.push_back (XmlAttribute (attributeName, attributeValue));
}
}
示例5: 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 */
示例6: ReadHeader
void ScannerFile::ReadHeader ()
{
delete headerFields;
headerFields = new ScannerHeaderFields ();
bool endOfText = false;
KKStr ln (100);
ReadHeaderOneLine (file, endOfText, ln);
while (!endOfText)
{
KKStr fieldName = ln.ExtractToken2 ("\t");
KKStr fieldValue = ln.ExtractToken2 ("\t");
headerFields->Add (fieldName, fieldValue);
ExtractHeaderField (fieldName, fieldValue);
ReadHeaderOneLine (file, endOfText, ln);
}
} /* ReadHeader */
示例7: ReportTextMsg
void ScannerFile::ReportTextMsg (const char* textBuff,
kkint32 numTextBytes
)
{
KKStr s (textBuff, 0, numTextBytes - 1);
if (s.StartsWith ("InstrumentDataWord\t", true))
{
s.ExtractToken2 ("\t");
kkint32 idNum = s.ExtractTokenInt ("\t");
kkuint32 scanLineNum = s.ExtractTokenUint ("\t");
kkuint32 dataWord = s.ExtractTokenUint ("\t");
WordFormat32Bits w (dataWord);
ReportInstrumentDataWord (idNum, scanLineNum, w);
}
else
{
/**
*@todo Need to add code to do something with the textBuff message.
*/
}
} /* ReportTextMsg */
示例8: ProcessStatusStr
void BinaryClass::ProcessStatusStr (KKStr statusStr,
MLClassListPtr mlClasses
)
{
KKStr fieldName;
class1 = NULL;
class2 = NULL;
fieldName = statusStr.ExtractToken2 ("\t");
while (!fieldName.Empty ())
{
fieldName.TrimLeft ("\n\r\t ");
fieldName.TrimRight ("\n\r\t ");
fieldName.Upper ();
if (fieldName == "ALLCLASSES")
{
class1 = NULL;
class2 = NULL;
}
else if (fieldName == "BINARYCLASSES")
{
class1 = mlClasses->GetMLClassPtr (statusStr.ExtractToken2 ("\t"));
class2 = mlClasses->GetMLClassPtr (statusStr.ExtractToken2 ("\t"));
if ((class1 == NULL) || (class2== NULL))
{
cout << "Class1 or Class2 == NULL" << endl;
}
else
{
if ((class1->Name ().Empty ()) || (class1->Name ().Empty ()))
{
cout << "Class1Name or Class2Name are empty" << endl;
}
}
}
else if (fieldName == "STATUS")
status = BinaryClassStatusFromStr (statusStr.ExtractToken2 ("\t"));
else if (fieldName == "NUMPROCESSORS")
numProcessors = statusStr.ExtractTokenInt ("\t");
else if (fieldName.CompareIgnoreCase ("FinalResultType") == 0)
resultType = FinalResultTypeFromStr (statusStr.ExtractToken2 ("\t"));
else if (fieldName.CompareIgnoreCase ("ResultsFileName") == 0)
finalResultsFileName = statusStr.ExtractToken2 ("\t");
else if (fieldName.CompareIgnoreCase ("SelectionMethod") == 0)
selectionMethod = SelectionMethodFromStr (statusStr.ExtractToken2 ("\t"));
else if (fieldName.CompareIgnoreCase ("configFileName") == 0)
configFileName = statusStr.ExtractToken2 ("\t");
fieldName = statusStr.ExtractToken2 ("\t");
}
} /* ProcessStatusStr */
示例9: ReadConfigFile
void DataBaseServerList::ReadConfigFile ()
{
KKStr configFileName = osAddSlash (PicesVariables::ConfigurationDirectory ()) + "MySql.cfg";
log.Level (10) << "DataBaseServerList::ReadConfigFile ConfigFileName[" << configFileName << "]" << endl;
FILE* in = osFOPEN (configFileName.Str (), "r");
if (!in)
{
log.Level (-1) << "DataBaseServerList::ReadConfigFile Error loading ConfigFileName[" << configFileName << "]" << endl;
return;
}
defaultServerDescription = "";
bool defaultServerFound = false;
char buff[1024];
while (fgets (buff, sizeof (buff), in))
{
buff[sizeof(buff) - 1] = 0; // Just to make sure that buffer not completely full
KKStr ln (buff);
if (ln.Len () < 3)
continue;
if ((ln[0] == '/') && (ln[1] == '/'))
continue;
KKStr lineName = ln.ExtractToken2 ("\n\r\t");
if (lineName.EqualIgnoreCase ("Server"))
{
DataBaseServerPtr server = new DataBaseServer (ln);
PushOnBack (server);
}
else if (lineName.EqualIgnoreCase ("DefaultServer"))
{
defaultServerDescription = ln.ExtractToken2 ("\n\r\t");
defaultServerFound = true;
}
}
if (!defaultServerFound)
{
DataBaseServerPtr defaultServer = LookUpByDescription ("Local");
if (!defaultServer)
defaultServer = LookUpByDescription ("localhost");
if (!defaultServer)
{
defaultServer = new DataBaseServer ();
defaultServer->UserName ("Root");
defaultServer->Description ("localhost");
defaultServer->Embedded (false);
defaultServer->HostName ("localhost");
defaultServer->PortNum (3306),
defaultServer->MySqlDataDir ("");
defaultServer->UserName ("root");
defaultServer->PassWord ("dasani30");
defaultServer->DataBaseName ("pices_new");
defaultServerDescription = defaultServer->Description ();
PushOnBack (defaultServer);
}
defaultServerDescription = defaultServer->Description ();
}
fclose (in);
} /* ReadConfigFile */
示例10: ImpotrtGPSData
void ImpotrtGPSData (const KKStr& fileName)
{
RunLog log;
DataBasePtr dbConn = new DataBase (log);
ifstream i (fileName.Str ());
if (!i.is_open ())
{
log.Level (-1) << endl << endl
<< "ImpotrtGPSData Could not open file[" << fileName << "]" << endl
<< endl;
return;
}
log.Level (10) << endl << endl << endl << endl << endl
<< "ImpotrtGPSData FileName[" << fileName << "]" << endl << endl
<< endl;
char buff[20480];
bool firstPass = true;
int lastHour = 0;
DateTime lastDateTime;
while (i.getline (buff, sizeof (buff)))
{
KKStr ln = buff;
ln.TrimLeft ();
char ch = ln[0];
if ((ch < '0') || (ch > '9'))
continue;
KKStr dateStr = ln.ExtractToken2 (",");
KKStr timeStr = ln.ExtractToken2 (",");
KKStr WXTP_TaStr = ln.ExtractToken2 (",");
KKStr WXTS_TaStr = ln.ExtractToken2 (",");
KKStr WXTS_PaStr = ln.ExtractToken2 (",");
KKStr WXTP_PaStr = ln.ExtractToken2 (",");
KKStr dec_latStr = ln.ExtractToken2 (",");
KKStr dec_lonStr = ln.ExtractToken2 (",");
KKStr cogStr = ln.ExtractToken2 (",");
KKStr sogStr = ln.ExtractToken2 (",");
DateType gmtDate (dateStr);
TimeType gmtTime (timeStr);
DateTime gmtDateTime (gmtDate, gmtTime);
DateTime localTime = gmtDateTime;
localTime.HoursAdd (-4);
DateTime startDT = localTime;
DateTime endDT = localTime;
if (firstPass)
{
firstPass = false;
startDT.SecondsAdd (-180);
}
else
{
DateTime deltaDT = localTime - lastDateTime;
long deltaSecs = (long)deltaDT.Seconds ();
startDT.SecondsAdd (-(deltaSecs / 2));
}
endDT.SecondsAdd (120);
dbConn->InstrumentDataUpdateLatitudeAndLongitude (startDT, endDT, dec_latStr.ToDouble (), dec_lonStr.ToDouble ());
lastDateTime = localTime;
if (gmtTime.Minute () != lastHour)
{
lastHour = gmtTime.Hour ();
log.Level (10) << "File[" << osGetRootName (fileName) << "] GMT Time[" << gmtDate.MMM_DD_YYYY () << " - " << gmtTime.HH_MM_SS () << "]" << endl;
}
}
i.close ();
delete dbConn;
dbConn = NULL;
} /* ImpotrtGPSData */
示例11: 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 */
示例12: 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 */
示例13: StartStopTypeFromStr
void StartStopPoint::ParseTabDelStr (KKStr parser)
{
scanLineNum = parser.ExtractTokenInt ("\t");
KKStr typeStr = parser.ExtractToken2 ("\t");
type = StartStopTypeFromStr (typeStr);
}
示例14: ReadSimpleConfusionMatrix
void ClassificationBiasMatrix::ReadSimpleConfusionMatrix (istream& sr,
MLClassListPtr fileClasses
)
{
// 'classes' - The class order that the owner of this object is expecting.
// 'fileClasses' - The order that the classes are stored in the text file.
if ((classes == NULL) || (fileClasses == NULL))
{
KKStr errMsg = "ReadSimpleConfusionMatrix ***ERROR*** The 'Classes' line was never provided.";
runLog.Level (-1) << errMsg << endl;
valid = false;
throw KKException (errMsg);
}
kkint32 classesColIdx = 0;
char buff[10240];
KKStr l;
while (!sr.eof ())
{
sr.getline (buff, sizeof (buff));
l = buff;
l.TrimLeft ();
l.TrimRight ();
if (l.CompareIgnoreCase ("</SimpleConfusionMatrix>") == 0)
break;
KKStr lineName = l.ExtractToken2 ("\t");
if (lineName.CompareIgnoreCase ("DataRow") == 0)
{
if (fileClasses == NULL)
{
KKStr errMsg = "ReadSimpleConfusionMatrix ***ERROR*** 'Classes' was not provided before 'DataRow'.";
runLog.Level (-1) << errMsg << endl;
valid = false;
throw KKException (errMsg);
}
KKStr className = l.ExtractToken2 ("\t");
KKStr data = l.ExtractToken2 ("\t");
MLClassPtr pc = MLClass::CreateNewMLClass (className);
kkint32 classesIdx = classes->PtrToIdx (pc);
kkint32 fileClassesIdx = fileClasses->PtrToIdx (pc);
if (classesIdx < 0)
{
KKStr errMsg = "ReadSimpleConfusionMatrix ***ERROR*** DataRow specifies class[" + className + "] which is not defined by caller";
runLog.Level (-1) << errMsg << endl;
valid = false;
throw KKException (errMsg);
}
if (fileClassesIdx < 0)
{
KKStr errMsg = "ReadSimpleConfusionMatrix ***ERROR*** DataRow specifies class[" + className + "] was not defined in 'Classes' line.";
runLog.Level (-1) << errMsg << endl;
valid = false;
throw KKException (errMsg);
}
kkint32 classesRowIdx = classesIdx;
VectorKKStr dataFields = data.Split (',');
if (dataFields.size () != (kkuint32)numClasses)
{
KKStr errMsg = "ReadSimpleConfusionMatrix ***ERROR*** DataRow Class[" + className + "] number[" + StrFormatInt ((kkint32)dataFields.size (), "ZZZ0") + "] of values provided does not match number of Classes.";
runLog.Level (-1) << errMsg << endl;
valid = false;
throw KKException (errMsg);
}
for (kkint32 c = 0; c < numClasses; c++)
{
pc = fileClasses->IdxToPtr (c);
classesColIdx = classes->PtrToIdx (pc);
VectorKKStr parts = dataFields[c].Split (':');
if (parts.size () > 1)
{
(*counts) [classesRowIdx][classesColIdx] = parts[0].ToDouble ();
(*probabilities)[classesRowIdx][classesColIdx] = parts[1].ToDouble ();
}
}
}
}
} /* ReadSimpleConfusionMatrix */
示例15: 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 */