本文整理汇总了C++中std::wstring::back方法的典型用法代码示例。如果您正苦于以下问题:C++ wstring::back方法的具体用法?C++ wstring::back怎么用?C++ wstring::back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::wstring
的用法示例。
在下文中一共展示了wstring::back方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetTextExtent
void D3DFontObject9::DrawText(const boost::shared_ptr<const ID3DSprite> &pSprite,
std::wstring textString, RECT &screenRect, uint32 flags, const D3DXCOLOR &color) const {
if (m_d3dxFont != nullptr) {
CComPtr<ID3DXSprite> pD3DXSprite = nullptr;
const auto pSprite9 = boost::dynamic_pointer_cast<const D3DSprite9>(pSprite);
if (pSprite9 != nullptr)
pD3DXSprite = pSprite9->GetD3DXSprite();
// has trailing whitespace?
// todo: proper fix for multiline + hcentered
uint32 length = textString.length();
if (length != 0 && textString.back() == L' ')
{
// this hack only works for single line align
if ((flags & DT_SINGLELINE) == DT_SINGLELINE) {
flags &= ~(DT_CENTER | DT_VCENTER | DT_RIGHT | DT_BOTTOM);
screenRect = GetTextExtent(textString, screenRect, flags);
}
else
textString.back() = 0xA0; // "non breaking space"
}
m_d3dxFont->DrawTextW(pD3DXSprite, textString.data(), length, &screenRect, flags, color);
}
}
示例2: SegmentizeAddSegment
bool CServerPath::SegmentizeAddSegment(std::wstring & segment, tSegmentList& segments, bool& append)
{
if (traits[m_type].has_dots) {
if (segment == L".") {
return true;
}
else if (segment == L"..") {
if (segments.empty()) {
return false;
}
else {
segments.pop_back();
return true;
}
}
}
bool append_next = false;
if (!segment.empty() && traits[m_type].separatorEscape && segment.back() == traits[m_type].separatorEscape) {
append_next = true;
segment[segment.size() - 1] = traits[m_type].separators[0];
}
if (append) {
segments.back() += segment;
}
else {
segments.push_back(std::move(segment));
}
append = append_next;
return true;
}
示例3: formatPath
void formatPath(std::wstring & fname)
{
if(fname.empty()) return;
std::replace(fname.begin(), fname.end(), L'\\', L'/');
if(fname.back() != L'/') fname += L'/';
}
示例4: GetFileList
std::vector<std::wstring> GetFileList(const std::wstring& pattern, const bool fullPaths)
{
const std::wstring directory = (fullPaths ? GetDirPart(pattern) : L"");
// may not pass an empty string to FindFirstFileEx
UIETWASSERT(pattern.length() > 0);
// string passed to FindFirstFileEx must not end in a backslash
UIETWASSERT(pattern.back() != L'\\');
WIN32_FIND_DATA findData;
HANDLE hFindFile = ::FindFirstFileExW(pattern.c_str(), FindExInfoBasic,
&findData, FindExSearchNameMatch, NULL, 0);
std::vector<std::wstring> result;
if (hFindFile == INVALID_HANDLE_VALUE)
{
// If there are NO matching files, then FindFirstFileExW returns
// INVALID_HANDLE_VALUE and the last error is ERROR_FILE_NOT_FOUND.
UIETWASSERT(::GetLastError() == ERROR_FILE_NOT_FOUND);
return result;
}
do
{
result.emplace_back(directory + findData.cFileName);
} while (::FindNextFileW(hFindFile, &findData));
UIETWASSERT(::GetLastError() == ERROR_NO_MORE_FILES);
ATLVERIFY(::FindClose(hFindFile));
return result;
}
示例5: EnumerateFiles
std::list<std::wstring> EnumerateFiles(std::wstring path)
{
std::list<std::wstring> result;
if (path.empty())
return result;
#if defined(_WIN32)
HANDLE dir;
WIN32_FIND_DATAW data;
// Rewrite slashes for better compatibility.
for (auto& c: path)
{
if (c == L'/')
c = L'\\';
}
// Appending '\*' handles the case of querying a disk root.
if (path.back() != L'\\')
path += L'\\';
path += L'*';
if ((dir = ::FindFirstFileW(path.c_str(), &data)) != INVALID_HANDLE_VALUE)
{
BOOL rc = TRUE;
do
{
if (!(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
result.push_back(data.cFileName);
rc = ::FindNextFileW(dir, &data);
}
while (rc);
::FindClose(dir);
}
#else
DIR* dir;
std::string u8path = UTF8Encoding().Convert(path);
if (u8path.empty() || u8path.back() != '/')
u8path += '/';
if ((dir = ::opendir(u8path.c_str())) != nullptr)
{
struct dirent ent, *pent = &ent;
while (::readdir_r(dir, pent, &pent) == 0 && pent != nullptr)
{
struct stat st;
if (::stat((u8path + pent->d_name).c_str(), &st) == 0 && (st.st_mode & S_IFREG))
{
result.push_back(UTF8Encoding().Convert(pent->d_name));
}
}
::closedir(dir);
}
#endif
return result;
}
示例6:
RECT D3DFontObject9::GetTextExtent(std::wstring textString, RECT rect, uint32 flags) const {
if (m_d3dxFont != nullptr) {
uint32 length = textString.length();
bool trailingSpace = (length != 0 && textString.back() == L' ');
if (trailingSpace)
textString.back() = L'.';
m_d3dxFont->DrawTextW(nullptr, textString.data(), length, &rect, flags | DT_CALCRECT, 0);
// adjust the rectangle...
if (trailingSpace) {
rect.right += m_spaceExtent.x;
rect.right -= m_pointExtent.x;
}
}
return rect;
}
示例7: DeleteFolder
int DeleteFolder(std::wstring path) {
if (path.back() == '\\')
path.pop_back();
path.push_back('\0');
SHFILEOPSTRUCT fos = {0};
fos.wFunc = FO_DELETE;
fos.pFrom = path.c_str();
fos.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT;
return SHFileOperation(&fos);
}
示例8: ExecFunc
int CPython::ExecFunc(const std::vector<std::wstring> &argv, std::wstring &err, HANDLE hfile)
{
std::vector<std::wstring>::const_iterator itr, eitr;
itr = argv.cbegin(); eitr = argv.cend(); err = *itr;
if (argv.size() <= 0) {
err = text("No python command function found"); return 1;
}
err.push_back(text('('));
for (++itr; itr != eitr; ++itr) {
err.append(*itr); err.push_back(text(','));
}
if (err.back() == text(',')) err.pop_back();
err.push_back(text(')'));
Addtolist(1,1,text("Execute Function: %s"),err.c_str());
int id = 0; FILE *pfile = nullptr; DWORD count = 0;
PyObject *poldout, *polderr, *pnewout, *pnewerr;
if (DuplicateHandle (
GetCurrentProcess(), hfile, GetCurrentProcess(), &hfile,
0, false, DUPLICATE_SAME_ACCESS
)) {
id = open_osfhandle((intptr_t)hfile, _O_WRONLY);
pfile = fdopen(id,"w"); setvbuf(pfile,nullptr,_IONBF,1024);
poldout = PySys_GetObject("stdout");
polderr = PySys_GetObject("stderr");
pnewout = PyFile_FromFile(pfile, "logger", "w", nullptr);
pnewerr = PyFile_FromFile(pfile, "logger", "w", nullptr);
PySys_SetObject("stdout", pnewout);
PySys_SetObject("stderr", pnewerr);
} else poldout = polderr = pnewout = pnewerr = nullptr;
std::wstring_convert<std::codecvt_utf8_utf16<wchar>> cvt;
std::string str = cvt.to_bytes(err);
std::size_t pos = str.find(text('.'));
if (pos != std::string::npos) {
std::string mod = str.substr(0, pos);
PyObject* dest = PyImport_ImportModule(mod.c_str());
PyObject* main = PyImport_AddModule("__main__");
PyObject_SetAttrString(main, mod.c_str(), dest);
}
str.insert(0, "print ");
int irslt = PyRun_SimpleString(str.c_str());
if (irslt != 0) err = text("Internal error that PyRun_SimpleString fail");
else err = text("Execute python function successfully ..");
if (pnewout != nullptr) PySys_SetObject("stdout", poldout);
if (pnewerr != nullptr) PySys_SetObject("stderr", polderr);
if (pfile != nullptr) fclose(pfile); return irslt;
}
示例9: ExtractCurrentFile
bool DialogInstall::ExtractCurrentFile(const std::wstring& fileName)
{
// Some archives don't explicity list directories, so create them recursively
if (!CreateDirectoryRecursive(fileName))
{
return false;
}
if (fileName.back() == L'\\')
{
// Nothing left to do
return true;
}
if (unzOpenCurrentFile(m_PackageUnzFile) != UNZ_OK)
{
return false;
}
HANDLE hFile = CreateFile(fileName.c_str(), GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
if (hFile == INVALID_HANDLE_VALUE)
{
return false;
}
int read;
do
{
BYTE buffer[16384];
DWORD written;
read = unzReadCurrentFile(m_PackageUnzFile, buffer, 16384);
if (read < 0 || !WriteFile(hFile, (LPCVOID)buffer, read, &written, nullptr) || read != written)
{
read = UNZ_ERRNO;
break;
}
}
while (read != UNZ_EOF);
CloseHandle(hFile);
return unzCloseCurrentFile(m_PackageUnzFile) == UNZ_OK && read == UNZ_EOF;
}
示例10: Ends_With
bool Ends_With(std::wstring const& str, wchar_t const& end_part){
if (!str.empty()){
return str.back() == end_part;
}
return false;
}