本文整理汇总了C++中wstring::swap方法的典型用法代码示例。如果您正苦于以下问题:C++ wstring::swap方法的具体用法?C++ wstring::swap怎么用?C++ wstring::swap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wstring
的用法示例。
在下文中一共展示了wstring::swap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DisplayDialog
int DisplayDialog ( WStringAutoPtr title, WStringAutoPtr message, WStringAutoPtr button1, WStringAutoPtr button2, WStringAutoPtr button3 )
{
// set the names to be used for each button
g_button1_name.swap ( *button1 );
g_button2_name.swap ( *button2 );
g_button3_name.swap ( *button3 );
// the type of dialog displayed varies depends on the nunmber of buttons required
UINT type = MB_OK;
if ( g_button2_name != L"" ) {
type = MB_OKCANCEL;
if ( g_button3_name != L"" ) {
type = MB_YESNOCANCEL;
}
}
// set the callback so that the custom button names are installed
g_window_hook = SetWindowsHookEx ( WH_CBT, &DialogCallback, 0, GetCurrentThreadId() );
/*
get the user's choice and translate that into a response that matches the equivalent
choice on OS X
*/
int button_clicked = MessageBox ( GetForegroundWindow(), message->c_str(), title->c_str(), type );
unsigned long response = 0;
switch ( button_clicked ) {
case IDOK:
case IDYES:
response = kBE_OKButton;
break;
case IDCANCEL:
response = kBE_CancelButton;
break;
case IDNO:
response = kBE_AlternateButton;
break;
}
return response;
} // DisplayDialog
示例2: ExpandDotDotDot
void ConfigHelper::ExpandDotDotDot(wstring& featPath, const wstring& scpPath, wstring& scpDirCached)
{
wstring delim = L"/\\";
if (scpDirCached.empty())
{
scpDirCached = scpPath;
wstring tail;
auto pos = scpDirCached.find_last_of(delim);
if (pos != wstring::npos)
{
tail = scpDirCached.substr(pos + 1);
scpDirCached.resize(pos);
}
if (tail.empty()) // nothing was split off: no dir given, 'dir' contains the filename
scpDirCached.swap(tail);
}
size_t pos = featPath.find(L"...");
if (pos != featPath.npos)
featPath = featPath.substr(0, pos) + scpDirCached + featPath.substr(pos + 3);
}