本文整理汇总了C++中std::wstring::find_last_of方法的典型用法代码示例。如果您正苦于以下问题:C++ wstring::find_last_of方法的具体用法?C++ wstring::find_last_of怎么用?C++ wstring::find_last_of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::wstring
的用法示例。
在下文中一共展示了wstring::find_last_of方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getVideoFileBasename
std::wstring CSVPToolBox::getVideoFileBasename(std::wstring szVidPath, std::vector<std::wstring>* szaPathInfo = NULL)
{
//CPath szTPath(szVidPath.c_str());
int posDot = szVidPath.find_last_of(L'.');
int posSlash = szVidPath.find_last_of(L'\\');
int posSlash2 = szVidPath.find_last_of(L'/');
if (posSlash2 > posSlash)
posSlash = posSlash2;
if(posDot > posSlash)
{
if (szaPathInfo != NULL)
{
std::wstring szBaseName = szVidPath.substr(0, posDot);
std::wstring szExtName = szVidPath.substr(posDot, szVidPath.size() - posDot);
std::transform(szExtName.begin(), szExtName.end(), szExtName.begin(),::tolower);
std::wstring szFileName = szVidPath.substr(posSlash+1, (posDot - posSlash - 1));
std::wstring szDirName = szVidPath.substr(0, posSlash + 1);
szaPathInfo -> clear();
szaPathInfo -> push_back(szBaseName); // Base Name
szaPathInfo -> push_back(szExtName ); //ExtName
szaPathInfo -> push_back(szDirName); //Dir Name ()
szaPathInfo -> push_back(szFileName); // file name only
}
return szVidPath.substr(posDot);
}
return szVidPath;
}
示例2: parseNamedEmail
bool ClientRecipient::parseNamedEmail(const std::wstring & namedEmail) {
bool success = false;
size_t npos = std::wstring::npos;
size_t leftParen = namedEmail.find_last_of(L'(');
size_t rightParen = namedEmail.find_last_of(L')');
// If its not formatted in the way we expect, we cant handle it
if (leftParen != npos && rightParen != npos && rightParen == namedEmail.size()-1) {
name = namedEmail.substr(0, leftParen);
email = namedEmail.substr(leftParen+1,rightParen-leftParen-1);
success = true;
} else {
size_t leftParen = namedEmail.find_last_of(L'<');
size_t rightParen = namedEmail.find_last_of(L'>');
// If its not formatted in the way we expect, we cant handle it
if (leftParen != npos && rightParen != npos && rightParen == namedEmail.size()-1) {
name = namedEmail.substr(0, leftParen);
email = namedEmail.substr(leftParen+1,rightParen-leftParen-1);
success = true;
}
}
return success;
}
示例3: makeSyncLeaderHandler
Syncer::Syncer(FileEventLoop* files,
std::wstring leader,
std::wstring follower) : m_files(files), m_leader(leader)
{
m_leaderSyncer = makeSyncLeaderHandler(leader, follower);
m_leaderDir = leader.substr(0, leader.find_last_of('\\') + 1);
files->watch(m_leaderDir, m_leaderSyncer);
// Eventually, the leader and the follower syncers will use custom logic.
m_followerSyncer = makeSyncFollowerHandler(leader, follower);
m_followerDir = follower.substr(0, follower.find_last_of('\\') + 1);
files->watch(m_followerDir, m_followerSyncer);
}
示例4: Import
bool ObjectImporter::Import(std::wstring file, ImportedObjectData* rawData)
{
size_t first = file.find_last_of('\\') + 1;
size_t last = file.find_last_of('.');
rawData->name = file.substr(first, last-first);
std::wifstream in (file);
if(!in.is_open())
{
std::wstring msg = L"Failed to open file: \n";
msg.append(file);
MessageBox(0, msg.c_str(), L"Import error", 0);
return false;
}
else
{
std::wstring buff;
while (!in.eof())
{
in >> buff;
if(buff.size())
{
if(buff == ObjImpFormat::animationCount)
{
int count = 0;
if(!ParseInteger(in, count))
return false;
if(count)
{
rawData->animations.resize(count);
if(!ParseAnimationFile(in, rawData))
return false;
}
else
if(!ParseStandardFile(in, rawData))
return false;
}
else { ParseLine(in, true); }
}
}
in.close();
}
return true;
}
示例5: GetFilePath
std::wstring GetFilePath( const std::wstring& wsFullName )
{
std::wstring::size_type nIndex1 = wsFullName.find_last_of(L"\\");
std::wstring::size_type nIndex2 = wsFullName.find_last_of(L"/");
if (std::wstring::npos == nIndex1)
{
nIndex1 = 0;
}
if (std::wstring::npos == nIndex2)
{
nIndex2 = 0;
}
std::wstring::size_type nIndex = max(nIndex1, nIndex2);
return wsFullName.substr(0, nIndex);
}
示例6: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
dir = argv[0];
dir.resize(dir.find_last_of(_T("\\")) + 1);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
示例7: UrlHighlightHtml
std::wstring UrlHighlightHtml(const std::wstring& message, bool& isUrl)
{
std::wstring ret;
std::wstring htmlStop = L"\'\" []<>\r\n";
std::wstring search = L"://";
size_t start = 0;
size_t find;
while ((find = message.find(search, start)) < message.length()) {
size_t urlStart = message.find_last_of(htmlStop, find);
size_t urlEnd = message.find_first_of(htmlStop, find + 3);
if (urlStart >= message.length())
urlStart = -1;
if (urlEnd >= message.length())
urlEnd = message.length();
if (((int)urlEnd - 3 - (int)find > 0) && ((int)find - (int)urlStart - 1 > 0)) {
ret += message.substr(start, (urlStart + 1) - start);
std::wstring url = message.substr(urlStart + 1, urlEnd - urlStart - 1);
start = urlEnd;
ret += L"<a class=url target=_blank href=\"";
ret += url + L"\">" + url + L"</a>";
isUrl = true;
}
else {
ret += message.substr(start, (find + 3) - start);
start = find + 3;
}
}
ret += message.substr(start, message.length() - start);
return ret;
}
示例8: PictureTypeParser
GUID Picture::PictureTypeParser(const std::wstring & path)
{
auto pos = path.find_last_of(L'.');
auto posfix = std::wstring(path.begin() + pos + 1,
path.begin()+path.find_first_of(L'\0'));
for (auto& c : posfix)
c = std::tolower(c);
if (posfix == L"png")
{
return GUID_ContainerFormatPng;
}
else if (posfix == L"gif")
{
return GUID_ContainerFormatGif;
}
if (posfix == L"jpeg")
{
return GUID_ContainerFormatJpeg;
}
if (posfix == L"BMP")
{
return GUID_ContainerFormatBmp;
}
else assert(0);
//return GUID_ContainerFormatPng;
}
示例9: archive_dump
int archive_dump(std::wstring file, std::wstring application, std::wstring version, std::wstring date, std::wstring target) {
try {
if (!file_helpers::checks::exists(target)) {
if (!boost::filesystem::create_directories(target)) {
std::wcout << _T("Failed to create directory: ") << target << std::endl;
return -1;
}
std::wcout << _T("Created folder: ") << target << std::endl;
}
if (!file_helpers::checks::is_directory(target)) {
std::wcout << _T("Target is not a folder: ") << target << std::endl;
return -1;
}
std::wstring fname = file.substr(file.find_last_of(_T("/\\")));
boost::filesystem::copy_file(file, target + fname);
std::wstring descfile = target + fname + _T(".txt");
if (!write_desc(utf8::cvt<std::string>(descfile), utf8::cvt<std::string>(application), utf8::cvt<std::string>(version), utf8::cvt<std::string>(date))) {
std::wcout << _T("Failed to write description: ") << target << fname << _T(".txt") << std::endl;
return -1;
}
return 0;
} catch (const std::exception &e) {
std::cout << e.what() << std::endl;
return -1;
}
}
示例10: verifyValidExtension
bool sspAudioFile::verifyValidExtension(const std::wstring& strFilename)
{
if (s_extensions.empty()) {
int nMajorCount;
sf_command (NULL, SFC_GET_FORMAT_MAJOR_COUNT, &nMajorCount, sizeof (int));
SF_FORMAT_INFO info ;
for (int i=0; i<nMajorCount; ++i) {
info.format = i;
sf_command (NULL, SFC_GET_FORMAT_MAJOR, &info, sizeof (info));
// Concert to Unibyte string
size_t converted;
wchar_t str[10];
mbstowcs_s(&converted, str, 10, info.extension, _TRUNCATE);
s_extensions.push_back(str);
if (strcmp(info.extension, "aiff") == 0) s_extensions.push_back(_T("aif")); // Hack to support Windows short form
}
}
size_t nPos = strFilename.find_last_of(L".");
std::wstring ext = strFilename.substr(nPos+1, strFilename.length() - nPos);
std::vector<std::wstring>::iterator finder = find(s_extensions.begin(), s_extensions.end(), ext);
return finder != s_extensions.end();
}
示例11: file_ext
std::wstring file_ext(const std::wstring& aPath)
{
std::wstring::size_type pos = aPath.find_last_of(L'.');
if (pos != std::wstring::npos && pos != aPath.size() - 1)
return aPath.substr(pos + 1);
return L"";
}
示例12: GetFileNameExt
std::wstring GetFileNameExt(const std::wstring& fileName)
{
auto it = fileName.find_last_of('.');
if (it == fileName.npos)
return std::wstring();
return fileName.substr(it + 1);
}
示例13: getFileExt
std::wstring getFileExt(const std::wstring & fname)
{
size_t pos = fname.find_last_of(L'.');
if(pos != fname.npos) return fname.substr(pos + 1);
return L"";
}
示例14: extractName
std::wstring extractName(const std::wstring & pathname)
{
size_t pos = pathname.find_last_of(L'\\');
if (pos == std::wstring::npos) { return pathname; }
if (pos == pathname.length() - 1) { return L""; }
return(pathname.substr(pos + 1, std::wstring::npos));
}
示例15: GetPathFromPath
BOOL CCommonInterface::GetPathFromPath(std::wstring strAllPath, std::wstring & strPath)
{
int nPos = strAllPath.find_last_of('\\');
if (nPos > 0)
{
strPath = strAllPath.substr(0, nPos);
}
else
{
nPos = strAllPath.find_last_of('/');
if (nPos > 0)
{
strPath = strAllPath.substr(0, nPos);
}
}
return TRUE;
}