本文整理汇总了C++中wstring::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ wstring::empty方法的具体用法?C++ wstring::empty怎么用?C++ wstring::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wstring
的用法示例。
在下文中一共展示了wstring::empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LongestCommonSubstringLength
size_t LongestCommonSubstringLength(const wstring& str1, const wstring& str2) {
if (str1.empty() || str2.empty())
return 0;
const size_t len1 = str1.length();
const size_t len2 = str2.length();
vector<vector<size_t>> table(len1);
for (auto it = table.begin(); it != table.end(); ++it)
it->resize(len2);
size_t longest_length = 0;
for (size_t i = 0; i < len1; i++) {
for (size_t j = 0; j < len2; j++) {
if (str1[i] == str2[j]) {
if (i == 0 || j == 0) {
table[i][j] = 1;
} else {
table[i][j] = table[i - 1][j - 1] + 1;
}
if (table[i][j] > longest_length) {
longest_length = table[i][j];
}
} else {
table[i][j] = 0;
}
}
}
return longest_length;
}
示例2: Login
BOOL CWaveSession::Login(wstring szUsername, wstring szPassword)
{
ASSERT(!szUsername.empty() && !szPassword.empty());
if (m_nState != WSS_OFFLINE)
{
LOG("Not offline");
return FALSE;
}
if (m_lpRequest != NULL)
{
LOG("Requesting login while a request is running");
return FALSE;
}
m_nState = WSS_CONNECTING;
SignalProgress(WCS_BEGIN_LOGON);
m_szUsername = szUsername;
m_szPassword = szPassword;
return Reconnect();
}
示例3:
connection_spec::connection_spec(
const wstring& host, const wstring& user, const int port)
: m_host(host), m_user(user), m_port(port)
{
if (host.empty())
BOOST_THROW_EXCEPTION(invalid_argument("Host name required"));
if (user.empty())
BOOST_THROW_EXCEPTION(invalid_argument("User name required"));
}
示例4: AppendString
void AppendString(wstring& str0, const wstring& str1, const wstring& str2) {
if (str1.empty())
return;
if (!str0.empty())
str0.append(str2);
str0.append(str1);
}
示例5: set
void Localization::set(wstring &key, wstring &val)
{
if (!key.empty() && !val.empty()) {
STR::unescape_simple(key);
STR::unescape_simple(val);
// dwprintf(L">> %s\n", key.c_str());
mMenu[key] = val;
}
}
示例6: BuildSignedOAuthParameters
HTTPParameters BuildSignedOAuthParameters( const HTTPParameters& requestParameters,
const wstring& url,
const wstring& httpMethod,
const HTTPParameters* postParameters,
const wstring& consumerKey,
const wstring& consumerSecret,
const wstring& requestToken = L"",
const wstring& requestTokenSecret = L"",
const wstring& pin = L"" )
{
wstring timestamp = OAuthCreateTimestamp();
wstring nonce = OAuthCreateNonce();
// create oauth requestParameters
HTTPParameters oauthParameters;
oauthParameters[L"oauth_timestamp"] = timestamp;
oauthParameters[L"oauth_nonce"] = nonce;
oauthParameters[L"oauth_version"] = L"1.0";
oauthParameters[L"oauth_signature_method"] = L"HMAC-SHA1";
oauthParameters[L"oauth_consumer_key"] = consumerKey;
// add the request token if found
if (!requestToken.empty())
{
oauthParameters[L"oauth_token"] = requestToken;
}
// add the authorization pin if found
if (!pin.empty())
{
oauthParameters[L"oauth_verifier"] = pin;
}
// create a parameter list containing both oauth and original parameters
// this will be used to create the parameter signature
HTTPParameters allParameters = requestParameters;
if(Compare(httpMethod, L"POST", false) && postParameters)
{
allParameters.insert(postParameters->begin(), postParameters->end());
}
allParameters.insert(oauthParameters.begin(), oauthParameters.end());
// prepare a signature base, a carefully formatted string containing
// all of the necessary information needed to generate a valid signature
wstring normalUrl = OAuthNormalizeUrl(url);
wstring normalizedParameters = OAuthNormalizeRequestParameters(allParameters);
wstring signatureBase = OAuthConcatenateRequestElements(httpMethod, normalUrl, normalizedParameters);
// obtain a signature and add it to header requestParameters
wstring signature = OAuthCreateSignature(signatureBase, consumerSecret, requestTokenSecret);
oauthParameters[L"oauth_signature"] = signature;
return oauthParameters;
}
示例7: err
void ConsoleHandler::RunAsAdministrator
(
const wstring& strSyncName,
const wstring& strTitle,
const wstring& strInitialDir,
const wstring& strInitialCmd,
PROCESS_INFORMATION& pi
)
{
std::wstring strFile = Helpers::GetModuleFileName(nullptr);
std::wstring strParams;
// admin sync name
strParams += L"-a ";
strParams += Helpers::EscapeCommandLineArg(strSyncName);
// config file
strParams += L" -c ";
strParams += Helpers::EscapeCommandLineArg(g_settingsHandler->GetSettingsFileName());
// tab name
strParams += L" -t ";
strParams += Helpers::EscapeCommandLineArg(strTitle);
// directory
if (!strInitialDir.empty())
{
strParams += L" -d ";
strParams += Helpers::EscapeCommandLineArg(strInitialDir);
}
// startup shell command
if (!strInitialCmd.empty())
{
strParams += L" -r ";
strParams += Helpers::EscapeCommandLineArg(strInitialCmd);
}
SHELLEXECUTEINFO sei = {sizeof(sei)};
sei.hwnd = nullptr;
sei.fMask = /*SEE_MASK_NOCLOSEPROCESS|*/SEE_MASK_NOASYNC;
sei.lpVerb = L"runas";
sei.lpFile = strFile.c_str();
sei.lpParameters = strParams.length() > 0 ? strParams.c_str() : nullptr;
sei.lpDirectory = nullptr,
sei.nShow = SW_SHOWMINIMIZED;
if(!::ShellExecuteEx(&sei))
{
Win32Exception err(::GetLastError());
throw ConsoleException(boost::str(boost::wformat(Helpers::LoadString(IDS_ERR_CANT_START_SHELL_AS_ADMIN)) % strFile % strParams % err.what()));
}
pi.hProcess = sei.hProcess;
pi.dwProcessId = ::GetProcessId(sei.hProcess);
pi.hThread = NULL;
pi.dwThreadId = 0;
}
示例8: switch
extern "C" const wchar_t *
SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType)
{
switch (pathType) {
case SDL_WINRT_PATH_INSTALLED_LOCATION:
{
static wstring path;
if (path.empty()) {
path = Windows::ApplicationModel::Package::Current->InstalledLocation->Path->Data();
}
return path.c_str();
}
case SDL_WINRT_PATH_LOCAL_FOLDER:
{
static wstring path;
if (path.empty()) {
path = ApplicationData::Current->LocalFolder->Path->Data();
}
return path.c_str();
}
#if (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) || (NTDDI_VERSION > NTDDI_WIN8)
case SDL_WINRT_PATH_ROAMING_FOLDER:
{
static wstring path;
if (path.empty()) {
path = ApplicationData::Current->RoamingFolder->Path->Data();
}
return path.c_str();
}
case SDL_WINRT_PATH_TEMP_FOLDER:
{
static wstring path;
if (path.empty()) {
path = ApplicationData::Current->TemporaryFolder->Path->Data();
}
return path.c_str();
}
#endif
default:
break;
}
SDL_Unsupported();
return NULL;
}
示例9: _createRegistryString
void IEAcceptLanguagesAction::_createRegistryString(wstring ®value)
{
wchar_t szFormat[128];
int languages = m_languages.size();
float average, value, cal;
if (languages == 1)
{
regvalue = m_languages.at(0);
return;
}
average = 100 / (float) languages;
regvalue.empty();
_createRegistryStringTwoLangs(regvalue, average);
// More than 2 languages
for (int i = 2; i < languages; i++)
{
cal = 100 - (average * i);
value = floor(cal) / 100;
swprintf_s(szFormat, L",%s;q=%1.1f", m_languages.at(i).c_str(), value);
regvalue += szFormat;
}
}
示例10: authProxy
ns1__user* Server::Connector::AuthenticateByKerberos() {
LOG_DEBUG("call AuthenticateByKerberos ...");
const wstring kerberosServerName = RtnResources::GetOption(L"kerberos.spn", L"");
if (kerberosServerName.empty()) {
throw "Required property 'kerberos.spn' is not set";
}
const string ticket = Auth::GetKerberosTicket(kerberosServerName);
if(ticket.empty()) {
LOG_ERROR("GetKerberosTicket failed");
return false;
}
ns1__authenticateByKerberos request;
const unsigned char* tokenPointer = reinterpret_cast<const unsigned char*>(ticket.c_str());
request.token = new xsd__base64Binary();
request.token->__ptr = const_cast<unsigned char*>(tokenPointer);
request.token->__size = ticket.length();
ns1__authenticateByKerberosResponse response;
string authenticationUrl = IO::ToString(RtnResources::GetWebServiceURL(serverType, serverVersion, L"Authentication"));
ServerAPIBindingProxy authProxy(authenticationUrl.c_str());
int result = authProxy.authenticateByKerberos(&request, &response);
if (result == SOAP_OK) {
LOG_DEBUG("call AuthenticateByKerberos completed");
return response.result;
} else {
LOG_ERROR("call AuthenticateByKerberos failed by '%s'", authenticationUrl.c_str());
Logger::LogWebServiceError(&authProxy);
return NULL;
}
// TODO authProxy.destroy(); if copy constructor for class ns1__user will be available
}
示例11: ReadOneline
/*!
sakura.iniの1行を処理する.
1行の読み込みが完了するごとに呼ばれる.
@param line [in] 読み込んだ行
*/
void CProfile::ReadOneline(
const wstring& line
)
{
// 空行を読み飛ばす
if( line.empty() )
return;
//コメント行を読みとばす
if( 0 == line.compare( 0, 2, LTEXT("//") ))
return;
// セクション取得
// Jan. 29, 2004 genta compare使用
if( line.compare( 0, 1, LTEXT("[") ) == 0
&& line.find( LTEXT("=") ) == line.npos
&& line.find( LTEXT("]") ) == ( line.size() - 1 ) ) {
Section Buffer;
Buffer.strSectionName = line.substr( 1, line.size() - 1 - 1 );
m_ProfileData.push_back( Buffer );
}
// エントリ取得
else if( !m_ProfileData.empty() ) { //最初のセクション以前の行のエントリは無視
wstring::size_type idx = line.find( LTEXT("=") );
if( line.npos != idx ) {
m_ProfileData.back().mapEntries.insert( PAIR_STR_STR( line.substr(0,idx), line.substr(idx+1) ) );
}
}
}
示例12: SetValue
BOOL CADOParameter::SetValue(wstring strValue)
{
_variant_t vtVal;
ASSERT(m_pParameter != NULL);
if(!strValue.empty())
vtVal.vt = VT_BSTR;
else
vtVal.vt = VT_NULL;
vtVal.bstrVal = _bstr_t(strValue.c_str());
try
{
if(m_pParameter->Size == 0)
m_pParameter->Size = sizeof(char) * strValue.length();
m_pParameter->Value = vtVal;
::SysFreeString(vtVal.bstrVal);
return TRUE;
}
catch(_com_error &e)
{
dump_com_error(e);
::SysFreeString(vtVal.bstrVal);
return FALSE;
}
}
示例13: newFromChoice
//选择一个新的采集器 directsound or wasapi
AudioInputPtr AudioInputRegistrar::newFromChoice(wstring choice) {
if (! qmNew)
return AudioInputPtr();
if (!choice.empty() && qmNew->find(choice) != qmNew->end()) {
g_struct.s.qsAudioInput = choice;
current = choice;
AudioInputRegistrar * air = qmNew->find(current)->second;
return AudioInputPtr(air->create());
}
choice = g_struct.s.qsAudioInput;
if (qmNew->find(choice) != qmNew->end()) {
current = choice;
return AudioInputPtr(qmNew->find(choice)->second->create());
}
AudioInputRegistrar *r = NULL;
std::map<wstring, AudioInputRegistrar *>::iterator mit;
for (mit = qmNew->begin(); mit != qmNew->end(); mit++)
{
if (!r || (mit->second->priority > r->priority))
r = mit->second;
}
if (r) {
current = r->name;
g_struct.s.qsAudioInput = current;
return AudioInputPtr(r->create());
}
return AudioInputPtr();
}
示例14: split
void split(const wstring & ws, const wstring & delim, WStringList & out)
{
out.clear();
if(ws.empty())
{
return;
}
// Find first a delimiter
wstring wscopy(ws);
size_t pos = wscopy.find_first_of(delim);
// Loop until no delimiters left
while(pos != wscopy.npos)
{
out.push_back(wscopy.substr(0, pos + 1));
wscopy.erase(0, pos + 1);
pos = wscopy.find_first_of(delim);
}
// Push remainder of wstring onto list
if(!wscopy.empty())
{
out.push_back(wscopy);
}
}
示例15: StartClient
void PerfTest::StartClient()
{
#ifdef PLATFORM_UNIX
console.WriteLine("client process needs to be started manually on Linux");
#else
if (!computer.empty())
{
StartClientOnRemoteComputer();
return;
}
auto cmdline = wformatString(
"{0} {1} {2}",
Path::Combine(Environment::GetExecutablePath(), clientExeName),
listener_->ListenAddress(),
securityProvider_);
console.WriteLine("{0}", cmdline);
HandleUPtr processHandle, threadHandle;
vector<wchar_t> envBlock = vector<wchar_t>();
auto error = ProcessUtility::CreateProcess(
cmdline,
wstring(),
envBlock,
0,
processHandle,
threadHandle);
Invariant(error.IsSuccess());
#endif
}