本文整理汇总了C++中KKStr::LocateLastOccurrence方法的典型用法代码示例。如果您正苦于以下问题:C++ KKStr::LocateLastOccurrence方法的具体用法?C++ KKStr::LocateLastOccurrence怎么用?C++ KKStr::LocateLastOccurrence使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KKStr
的用法示例。
在下文中一共展示了KKStr::LocateLastOccurrence方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DetermineClassFromFileName
/****************************************************************************************
* DetermineClassFromFileName
*
* Given an Image File Name(fileName) will return and mlClass. Will use the
* path name in fileName to determine class. If the class does not exist in
* mlClasses, will create a new instance and add it to mlClasses.
*
* After talking to the user it has come to light that the first sub-directory in
* a path will dictate what class he/she feels a image belongs to.
* Ex:
* .../Protista/
* .../Protista/SubDir1
* .../Trichodesmium
* .../Trichodesmium/SubDir1
* .../Trichodesmium/SubDir2
*
* The idea is that when trying to determine what class a image really is we look
* at the first sub-dir name in the path. We may also have to deal with seq-num's
* as part of the name, in that case we strip the _ and following numbers from the
* name to get the correct class name.
****************************************************************************************/
MLClassPtr OurNeighbors::DetermineClassFromFileName (const KKStr& fileName)
{
KKStr filename_copy = fileName;
// If there are no path separator characters('\' or '/') characters in name
// then we will not be able to determine the class.
auto x = osLocateFirstSlashChar (filename_copy);
if (!x || (x.value () < 1))
return mlClasses->GetUnKnownClass ();
KKStr className = filename_copy.SubStrSeg (0, x);
// now lets get rid of any possible trailing seq number.
// We are assuming that a underscore{"_") character separates the calcs name from the seq number.
// So if there is an underscore character, and all the characters to the right of it are
// underscore characters, then we will remove the underscore and the following numbers.
x = className.LocateLastOccurrence ('_');
if (x)
{
// Now lets eliminate any sequence number in name
// We are assuming that a underscore{"_") character separates the class name from the seq number.
// So if there is an underscore character, and all the characters to the right of it are
// numeric characters, then we will remove the underscore and the following numbers.
kkuint32 y = x.value () + 1;
bool allFollowingCharsAreNumeric = true;
while ((y < className.Len ()) && (allFollowingCharsAreNumeric))
{
char ch = className[y];
allFollowingCharsAreNumeric = ((ch >= '0') && (ch <= '9'));
y++;
}
if (allFollowingCharsAreNumeric)
{
className = className.SubStrSeg (0, x);
}
}
// Now that we have a string with the class name, lets get a pointer
// to a mlClass object from mlClasses , if none there then we get
// to create a new class.
MLClassPtr mlClass = mlClasses->GetMLClassPtr (className);
return mlClass;
} /* DetermineClassFromFileName */
示例2: w
ActiveLearningReport::ActiveLearningReport (RunLog& _log,
MLClassList& _mlClasses,
KKStr _subDirName
):
mlClasses (_mlClasses),
log (_log),
subDirName (_subDirName),
results (true, 10),
baseResultsFileName ("ActiveLearningResults")
{
if (!subDirName.Empty ())
{
KKStr w (subDirName);
osAddLastSlash (w);
w << baseResultsFileName;
baseResultsFileName = w;
}
// C:\users\kkramer\GradSchool\Plankton\ActiveLearning\Results\010-IPC\2003-12-03_AllOrders_010-IPC_50-IPR
int x = subDirName.LocateLastOccurrence ('_');
if (x > 5)
{
KKStr leftSide = subDirName.SubStrPart (0, x - 1);
KKStr rightSide = subDirName.SubStrPart (x + 1);
x = rightSide.LocateCharacter ('-');
KKStr IPR = rightSide.SubStrPart (0, x - 1);
imagesPerRetraining = atoi (IPR.Str ());
x = leftSide.LocateLastOccurrence ('_');
rightSide = subDirName.SubStrPart (x + 1);
x = rightSide.LocateCharacter ('-');
KKStr IPC = rightSide.SubStrPart (0, x - 1);
initialImagesPerClass = atoi (IPC.Str ());
}
}