本文整理汇总了C++中std::tstring::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ tstring::empty方法的具体用法?C++ tstring::empty怎么用?C++ tstring::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::tstring
的用法示例。
在下文中一共展示了tstring::empty方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConcatPaths
/**
@param sFolder Folder to combine
@param sPathname Path to combine (probably relative to sFolder)
@param bAllowAbsoluteOverride true to allow sPathname to have an absolute path, false to make sure it's relative
@return The combined path
*/
std::tstring ConcatPaths(const std::tstring& sFolder, const std::tstring& sPathname, bool bAllowAbsoluteOverride /* = true */)
{
// Do we have a folder?
if (sFolder.empty())
// No, return the second part alone
return sPathname;
// Do we have a path?
if (sPathname.empty())
// No, return the first part alone
return sFolder;
// Allow overriding paths by using a drive letter and colon (c:) or a UNC path (\\)
if (bAllowAbsoluteOverride)
if ((sPathname.size() > 2) && (sPathname[1] == ':') || ((sPathname[0] == '\\') && (sPathname[1] == '\\')))
return sPathname;
std::tstring sRet = sFolder;
// Make sure we have a slash at the end of the folder part
CHAR c = sFolder[sFolder.size()-1];
if ((c != '\\') && (c != '/'))
sRet += _T("\\");
// Make sure we don't have a slash at the beginning of the path part:
c = sPathname[0];
if ((c == '\\') || (c == '/'))
// We do, jump over it
sRet += sPathname.substr(1);
else
// Just add them
sRet += sPathname;
return sRet;
}
示例2: ExtractEmail
void ExtractEmail(IDispatchPtr spDispOutlook, IDispatchPtr spDispNameSpace, const std::tstring& subject, const std::tstring& folder)
{
if(subject.empty())
throw Workshare::ArgumentException(_T("subject"), _T("Blank subject specified for the search"));
if(folder.empty())
throw Workshare::ArgumentException(_T("folder"), _T("Invalid destination folder specified for saving of attachments"));
if(-1 == _taccess(folder.c_str(), 0))
throw Workshare::ArgumentException(_T("folder"), _T("Destination folder does not exist"));
Outlook::_MailItemPtr spEmailItem = FindEmail(spDispOutlook, spDispNameSpace, subject);
Outlook::AttachmentsPtr spAttachments = spEmailItem->Attachments;
if(spAttachments == 0)
throw Workshare::NullReferenceException(_T("Failed to get the attachments collection for the mail item"));
long attachmentCount = spAttachments->Count;
if(0 == attachmentCount)
return;
for(long index = 1; index <= attachmentCount; index++)
{
Outlook::AttachmentPtr spAttachment = spAttachments->Item(index);
//we don't handle embedded documents
Outlook::OlAttachmentType attachmentType = spAttachment->Type;
if(Outlook::olOLE == attachmentType || Outlook::olEmbeddeditem == attachmentType)
continue;
std::tstring filename(folder);
filename.append(_T("\\")).append((LPTSTR)spAttachment->FileName);
std::tstring baseFilename = GetFilenameWithoutExtension(filename);
std::tstring fileExtension = GetFileExtension(filename);
int duplicate = 1;
while(-1 != _taccess(filename.c_str(), 0))
{
duplicate++;
std::tostringstream dupFilename;
dupFilename << baseFilename << _T("(") << duplicate << _T(").") << fileExtension << std::ends;
filename = dupFilename.str().c_str();
}
HRESULT hr = spAttachment->SaveAsFile(filename.c_str());
if(FAILED(hr))
{
std::tostringstream errMsg;
errMsg << _T("Failed to save attachment ") << (LPCTSTR)spAttachment->FileName << _T(" to ") << filename << std::ends;
throw Workshare::Com::ComException(errMsg.str().c_str(), hr, spAttachment);
}
}
}
示例3: init
bool DBManager::init(std::tstring dbfile)
{
std::tstring aofolder = AOManager::instance().getAOFolder();
if (aofolder.empty())
{
LOG("DBManager::init: Not a valid AO folder.");
return false;
}
if (dbfile.empty())
{
dbfile = _T("ItemAssistant.db");
}
bool dbfileExists = bfs::exists(bfs::tpath(dbfile));
if (!m_db->Init(dbfile))
{
LOG("DBManager::init: Unable to " << (dbfileExists ? "open" : "create") << " database. [" << dbfile << "]");
return false;
}
if (!dbfileExists)
{
createDBScheme();
}
unsigned int dbVersion = getDBVersion();
if (dbVersion < CURRENT_DB_VERSION)
{
if (IDOK != MessageBox(NULL, _T("AO Item Assistant needs to update its database file to a newer version."),
_T("Question - AO Item Assistant++"), MB_OKCANCEL | MB_ICONQUESTION))
{
return false;
}
updateDBVersion(dbVersion);
}
else if (dbVersion > CURRENT_DB_VERSION)
{
MessageBox(NULL,
_T("AO Item Assistant has detected a too new version of its database file. You should upgrade the software to continue."),
_T("Error - AO Item Assistant++"), MB_OK | MB_ICONERROR);
return false;
}
if (!syncLocalItemsDB(_T("aoitems.db"), aofolder))
{
MessageBox(NULL, _T("AO Item Assistant cannot start without a valid item database."),
_T("Error - AO Item Assistant++"), MB_OK | MB_ICONERROR);
return false;
}
m_db->Exec(_T("ATTACH DATABASE \"aoitems.db\" AS aodb"));
return true;
}
示例4: GetEmailMessageId
std::tstring GetEmailMessageId(IDispatchPtr spDispOutlook, IDispatchPtr spDispNameSpace, Workshare::Mail::Mapi::MapiSession& session, const std::tstring& subject)
{
if(subject.empty())
throw Workshare::ArgumentException(_T("subject"), _T("Blank subject specified for the search"));
Outlook::_MailItemPtr spEmailItem = FindEmail(spDispOutlook, spDispNameSpace, subject);
IMessagePtr spMessage = spEmailItem->MAPIOBJECT;
if(spMessage == 0)
throw Workshare::NullReferenceException(_T("Failed to retrieve MAPIOBJECT for Outlook MailItem"));
Workshare::Mail::Mapi::MapiMailMessage message(spMessage, &session);
return message.Id;
}
示例5: FindLinkedEmail
IDispatchPtr FindLinkedEmail(IDispatchPtr spDispOutlook, IDispatchPtr spDispNameSpace, Workshare::Mail::Mapi::MapiSession& session, const std::tstring& sMessageId)
{
if(spDispOutlook == 0)
throw Workshare::ArgumentNullException(_T("spDispOutlook"), _T("Outlook Application pointer is null."));
if(spDispNameSpace == 0)
throw Workshare::ArgumentNullException(_T("spDispNameSpace"), _T("MAPI NameSpace pointer is null."));
if(sMessageId.empty())
throw Workshare::ArgumentException(_T("sMessageId"), _T("The message ID of the email to find was not specified."));
size_t pos = sMessageId.find(_T(';'));
if(-1 == pos)
throw Workshare::ArgumentException(_T("sMessageId"), _T("Invalid message ID (should be in format EntryId;SearchKey[;InternetId])"));
std::tstring sEntryId = sMessageId.substr(0, pos);
std::tstring sSearchKeyAndInternetId = sMessageId.substr(pos + 1);
std::tstring sSearchKey;
std::tstring sInternetId;
pos = sSearchKeyAndInternetId.find(_T(';'));
if(-1 != pos)
{
sSearchKey = sSearchKeyAndInternetId.substr(0, pos);
sInternetId = sSearchKeyAndInternetId.substr(pos + 1);
}
else
sSearchKey = sSearchKeyAndInternetId;
Outlook::_ApplicationPtr spOutlook = spDispOutlook;
Outlook::_NameSpacePtr spNameSpace = spDispNameSpace;
IDispatchPtr spLinkedEmail;
HRESULT hr = spNameSpace->raw_GetItemFromID(_bstr_t(sEntryId.c_str()), vtMissing, &spLinkedEmail);
if(FAILED(hr))
{
std::tstring sStoreId;
Workshare::Mail::Mapi::FindItemBySearchKey(session, sSearchKey, sEntryId, sStoreId);
_variant_t vtStoreId(sStoreId.c_str());
hr = spNameSpace->raw_GetItemFromID(_bstr_t(sEntryId.c_str()), vtStoreId, &spLinkedEmail);
if(FAILED(hr))
throw Workshare::Com::ComException(_T("Outlook failed to open email"), hr, spNameSpace);
//If this fails we could create a function FindItemByInternetId(session, sInternetId, sEntryId, sStoreId);
}
return spLinkedEmail;
}
示例6: DispatchEvent
/*! Pluginページのメッセージ処理
@param hwndDlg ダイアログボックスのWindow Handlw
@param uMsg メッセージ
@param wParam パラメータ1
@param lParam パラメータ2
*/
INT_PTR CPropPlugin::DispatchEvent( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
NMHDR* pNMHDR;
int idCtrl;
WORD wNotifyCode;
WORD wID;
switch( uMsg ) {
case WM_INITDIALOG:
/* ダイアログデータの設定 Plugin */
InitDialog( hwndDlg );
SetData( hwndDlg );
// Modified by KEITA for WIN64 2003.9.6
::SetWindowLongPtr( hwndDlg, DWLP_USER, lParam );
return TRUE;
case WM_NOTIFY:
idCtrl = (int)wParam;
pNMHDR = (NMHDR*)lParam;
switch( idCtrl ) {
case IDC_PLUGINLIST:
switch( pNMHDR->code ) {
case LVN_ITEMCHANGED:
{
HWND hListView = ::GetDlgItem( hwndDlg, IDC_PLUGINLIST );
int sel = ListView_GetNextItem( hListView, -1, LVNI_SELECTED );
if( sel >= 0 ) {
CPlugin* plugin = CPluginManager::getInstance()->GetPlugin(sel);
if( plugin != NULL ) {
::SetWindowText( ::GetDlgItem( hwndDlg, IDC_LABEL_PLUGIN_Description ), to_tchar(plugin->m_sDescription.c_str()) );
::SetWindowText( ::GetDlgItem( hwndDlg, IDC_LABEL_PLUGIN_Author ), to_tchar(plugin->m_sAuthor.c_str()) );
::SetWindowText( ::GetDlgItem( hwndDlg, IDC_LABEL_PLUGIN_Version ), to_tchar(plugin->m_sVersion.c_str()) );
} else {
::SetWindowText( ::GetDlgItem( hwndDlg, IDC_LABEL_PLUGIN_Description ), _T("") );
::SetWindowText( ::GetDlgItem( hwndDlg, IDC_LABEL_PLUGIN_Author ), _T("") );
::SetWindowText( ::GetDlgItem( hwndDlg, IDC_LABEL_PLUGIN_Version ), _T("") );
}
// 2010.08.21 明らかに使えないときはDisableにする
EPluginState state = m_Common.m_sPlugin.m_PluginTable[sel].m_state;
BOOL bEdit = (state != PLS_DELETED && state != PLS_NONE);
::EnableWindow( ::GetDlgItem( hwndDlg, IDC_PLUGIN_Remove ), bEdit );
::EnableWindow( ::GetDlgItem( hwndDlg, IDC_PLUGIN_OPTION ), state == PLS_LOADED && plugin && plugin->m_options.size() > 0 );
::EnableWindow( ::GetDlgItem( hwndDlg, IDC_PLUGIN_README ),
(state == PLS_INSTALLED || state == PLS_UPDATED || state == PLS_LOADED || state == PLS_DELETED)
&& !GetReadMeFile(to_tchar(m_Common.m_sPlugin.m_PluginTable[sel].m_szName)).empty());
::EnableWindow(::GetDlgItem(hwndDlg, IDC_PLUGIN_URL), state == PLS_LOADED && plugin && plugin->m_sUrl.size() > 0);
}
}
break;
case NM_DBLCLK:
// リストビューへのダブルクリックで「プラグイン設定」を呼び出す
if (::IsWindowEnabled(::GetDlgItem( hwndDlg, IDC_PLUGIN_OPTION )))
{
DispatchEvent( hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_PLUGIN_OPTION, BN_CLICKED), (LPARAM)::GetDlgItem( hwndDlg, IDC_PLUGIN_OPTION ) );
}
break;
}
break;
default:
switch( pNMHDR->code ) {
case PSN_HELP:
OnHelp( hwndDlg, IDD_PROP_PLUGIN );
return TRUE;
case PSN_KILLACTIVE:
/* ダイアログデータの取得 Plugin */
GetData( hwndDlg );
return TRUE;
case PSN_SETACTIVE:
m_nPageNum = ID_PROPCOM_PAGENUM_PLUGIN;
return TRUE;
}
break;
}
break;
case WM_COMMAND:
wNotifyCode = HIWORD(wParam); /* 通知コード */
wID = LOWORD(wParam); /* 項目ID、 コントロールID、 またはアクセラレータID */
switch( wNotifyCode ) {
/* ボタン/チェックボックスがクリックされた */
case BN_CLICKED:
switch( wID ) {
case IDC_PLUGIN_SearchNew: // 新規プラグインを追加
GetData( hwndDlg );
CPluginManager::getInstance()->SearchNewPlugin( m_Common, hwndDlg );
if( m_bTrayProc ) {
LoadPluginTemp(m_Common, *m_pcMenuDrawer);
}
SetData_LIST( hwndDlg ); //リストの再構築
break;
case IDC_PLUGIN_INST_ZIP: // ZIPプラグインを追加
//.........这里部分代码省略.........