本文整理汇总了C++中STRING::find_last_of方法的典型用法代码示例。如果您正苦于以下问题:C++ STRING::find_last_of方法的具体用法?C++ STRING::find_last_of怎么用?C++ STRING::find_last_of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类STRING
的用法示例。
在下文中一共展示了STRING::find_last_of方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FileName
// Get file name from path
STRING Port::FileName(STRING file)
{
#ifdef WIN32
#ifdef UNICODE
int pos = file.find_last_of(L"\\") + 1;
#else
int pos = file.find_last_of("\\") + 1;
#endif
#elif defined(UNIX)
#ifdef UNICODE
int pos = file.find_last_of(L"/") + 1;
#else
int pos = file.find_last_of("/") + 1;
#endif
#endif
return file.substr(pos);
}
示例2: GenerateDefinitions
void MgWmsLayerDefinitions::GenerateDefinitions(MgUtilDictionary& Dictionary)
{
MgXmlSynchronizeOnElement ResourceDocument(*m_xmlParser,_("ResourceDocument"));
if(!ResourceDocument.AtBegin())
return; // Something is wrong. We leave.
while(!ResourceDocument.AtEnd()) {
STRING sValue; // basic_string
if(GetElementContents(_("ResourceId"),sValue)) {
// Okay, the ResourceId is too decorated for our purposes;
// the outside world doesn't need to know (and clutter up
// URL command lines with) this syntactic "punctuation" so
// we just get rid of it.
// Remove the Library prefix, if present.
if(sValue.find(_("Library://")) == 0)
sValue = sValue.substr(10);
// Remove the LayerDefinition suffix, if present.
STRING::size_type iEnd = sValue.find(_(".LayerDefinition"));
if(iEnd != STRING::npos)
sValue.resize(iEnd);
// There, that's our Layer Name.
Dictionary.AddDefinition(_("Layer.Name"),sValue);
// Until we have "Friendly Name" support, the
// friendly name will simply be the layer name sans
// path.
iEnd = sValue.find_last_of('/');
if(iEnd != STRING::npos)
sValue = sValue.substr(iEnd+1); // one past the slash.
// That's our Layer Title,
// Note that subsequently-found metadata may override this
// definition with a real title... one that the user actually
// wants. This just provides a default in case no such
// friendly name exists.... that keeps the list of layer names
// from being a list of empty strings.
Dictionary.AddDefinition(_("Layer.Title"),sValue);
}
else if(!GetMetadataDefinitions(Dictionary)) {
SkipElement(NULL);
}
}
}
示例3: removePath
// Remove the path from a file name.
STRING removePath(const STRING str)
{
return str.substr(str.find_last_of(_T('\\')) + 1);
}