本文整理汇总了C++中std::wstring::pop_back方法的典型用法代码示例。如果您正苦于以下问题:C++ wstring::pop_back方法的具体用法?C++ wstring::pop_back怎么用?C++ wstring::pop_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::wstring
的用法示例。
在下文中一共展示了wstring::pop_back方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: As_Last_N_Chars_Removed
std::wstring As_Last_N_Chars_Removed(std::wstring str, unsigned int const& number_of_times){
for (unsigned int i = 0; i < number_of_times; ++i){
if (!str.empty()){
str.pop_back();
}else{
return str;
}
}
return str;
}
示例2: 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);
}
示例3: 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;
}