本文整理汇总了C++中StringX::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ StringX::empty方法的具体用法?C++ StringX::empty怎么用?C++ StringX::empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringX
的用法示例。
在下文中一共展示了StringX::empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetAutoTypeString
StringX PWSAuxParse::GetAutoTypeString(const CItemData &ci,
const PWScore &core,
std::vector<size_t> &vactionverboffsets)
{
// Set up all the data (a shortcut entry will change all of them!)
StringX sxgroup = ci.GetGroup();
StringX sxtitle = ci.GetTitle();
StringX sxuser = ci.GetUser();
StringX sxpwd = ci.GetPassword();
StringX sxnotes = ci.GetNotes();
StringX sxurl = ci.GetURL();
StringX sxemail = ci.GetEmail();
StringX sxautotype = ci.GetAutoType();
if (ci.IsAlias()) {
const CItemData *pbci = core.GetBaseEntry(&ci);
if (pbci != NULL) {
sxpwd = pbci->GetPassword();
} else { // Problem - alias entry without a base!
ASSERT(0);
}
} else if (ci.IsShortcut()) {
const CItemData *pbci = core.GetBaseEntry(&ci);
if (pbci != NULL) {
sxgroup = pbci->GetGroup();
sxtitle = pbci->GetTitle();
sxuser = pbci->GetUser();
sxpwd = pbci->GetPassword();
sxnotes = pbci->GetNotes();
sxurl = pbci->GetURL();
sxemail = pbci->GetEmail();
sxautotype = pbci->GetAutoType();
} else { // Problem - shortcut entry without a base!
ASSERT(0);
}
} // ci.IsShortcut()
// If empty, try the database default
if (sxautotype.empty()) {
sxautotype = PWSprefs::GetInstance()->
GetPref(PWSprefs::DefaultAutotypeString);
// If still empty, take this default
if (sxautotype.empty()) {
// checking for user and password for default settings
if (!sxpwd.empty()){
if (!sxuser.empty())
sxautotype = DEFAULT_AUTOTYPE;
else
sxautotype = _T("\\p\\n");
}
}
}
return PWSAuxParse::GetAutoTypeString(sxautotype, sxgroup,
sxtitle, sxuser, sxpwd,
sxnotes, sxurl, sxemail,
vactionverboffsets);
}
示例2: ParseNotes
static void ParseNotes(StringX &sxNotes,
std::vector<StringX> &vsxnotes_lines)
{
if (!sxNotes.empty()) {
// Use \n and \r to tokenise this line
StringX::size_type st_start(0), st_end(0);
const StringX sxdelim = _T("\r\n");
StringX sxline;
StringX::size_type st_index;
while (st_end != StringX::npos) {
st_end = sxNotes.find(sxdelim, st_start);
sxline = (sxNotes.substr(st_start,
(st_end == StringX::npos) ? StringX::npos : st_end - st_start));
st_index = 0;
// Remove all tabs - \t
for (;;) {
st_index = sxline.find(_T("\\t"), st_index);
if (st_index == StringX::npos)
break;
sxline.replace(st_index, 2, _T(""));
st_index += 1;
}
vsxnotes_lines.push_back(sxline);
st_start = ((st_end > (StringX::npos - sxdelim.size()))
? StringX::npos : st_end + sxdelim.size());
}
}
}
示例3: CheckPasskey
int PWSfile::CheckPasskey(const StringX &filename, const StringX &passkey, VERSION &version)
{
/**
* We start with V3 because it's the quickest to rule out
* due to header/footer.
* V4 can take a looong time if the iter value's too big.
* XXX Need to address this later with a popup prompting the user.
*/
if (passkey.empty())
return WRONG_PASSWORD;
int status;
version = UNKNOWN_VERSION;
status = PWSfileV3::CheckPasskey(filename, passkey);
if (status == SUCCESS) {
version = V30;
} else {
status = PWSfileV4::CheckPasskey(filename, passkey);
if (status == SUCCESS)
version = V40;
else {
status = PWSfileV1V2::CheckPasskey(filename, passkey);
if (status == SUCCESS)
version = V20; // or V17?
}
}
return status;
}
示例4: ItemFieldsToDialog
void EditShortcut::ItemFieldsToDialog()
{
// Populate the combo box
std::vector<stringT> aryGroups;
m_core.GetUniqueGroups(aryGroups);
for (size_t igrp = 0; igrp < aryGroups.size(); igrp++) {
m_groupCtrl->Append(aryGroups[igrp].c_str());
}
// select relevant group
const StringX group = m_item->GetGroup();
if (!group.empty())
for (size_t igrp = 0; igrp < aryGroups.size(); igrp++)
if (group == aryGroups[igrp].c_str()) {
m_groupCtrl->SetSelection(reinterpret_cast<int &>(igrp));
break;
}
m_title = m_item->GetTitle().c_str();
m_user = m_item->GetUser().c_str();
m_created = m_item->GetCTimeL().c_str();
m_lastAccess = m_item->GetATimeL().c_str();
m_lastAny = m_item->GetRMTimeL().c_str();
const CItemData *base = m_core.GetBaseEntry(m_item);
if (base != NULL) {
m_lastChanged = base->GetRMTimeL().c_str();
} else {
m_lastChanged = _("Unknown"); // Internal error
}
}
示例5: ReMergeNotes
static StringX ReMergeNotes(const CItemData &item)
{
StringX notes = item.GetNotes();
const StringX url(item.GetURL());
if (!url.empty()) {
notes += _T("\r\n"); notes += url;
}
const StringX at(item.GetAutoType());
if (!at.empty()) {
stringT cs_autotype;
LoadAString(cs_autotype, IDSC_AUTOTYPE);
notes += _T("\r\n");
notes += cs_autotype.c_str();
notes += at;
}
return notes;
}
示例6: GetDefaultSymbols
stringT CPasswordCharPool::GetDefaultSymbols()
{
stringT symbols;
const StringX sx_symbols = PWSprefs::GetInstance()->GetPref(PWSprefs::DefaultSymbols);
if (!sx_symbols.empty())
symbols = sx_symbols.c_str();
else
symbols = std_symbol_chars;
return symbols;
}
示例7: while
lines_vec stream2vec(StringXStream &wss) {
lines_vec vlines;
do {
StringX line;
std::getline(wss, line);
if ( !line.empty() ) vlines.push_back(line);
}
while( !wss.eof() );
return vlines;
}
示例8: DoCopyEmail
void PasswordSafeFrame::DoCopyEmail(CItemData &item)
{
const StringX mailto = item.IsEmailEmpty()?
(item.IsURLEmail()? item.GetURL(): StringX())
: item.GetEmail();
if (!mailto.empty()) {
PWSclipboard::GetInstance()->SetData(mailto);
UpdateAccessTime(item);
}
}
示例9: GetAllMenuItemStrings
bool CRUEList::GetAllMenuItemStrings(vector<RUEntryData> &ListofAllMenuStrings) const
{
RUEntryData ruentrydata;
bool retval = false;
RUEListConstIter iter;
for (iter = m_RUEList.begin(); iter != m_RUEList.end(); iter++) {
ItemListConstIter pw_listpos = m_core.Find(*iter);
if (pw_listpos == m_core.GetEntryEndIter()) {
ruentrydata.string = L"";
ruentrydata.image = -1;
ruentrydata.pci = NULL;
} else {
const CItemData &ci = m_core.GetEntry(pw_listpos);
StringX group = ci.GetGroup();
StringX title = ci.GetTitle();
StringX user = ci.GetUser();
if (group.empty())
group = L" ";
if (title.empty())
title = L" ";
if (user.empty())
user = L" ";
// Looks similar to <g><t><u>
ruentrydata.string = L"\xab" + group + L"\xbb " +
L"\xab" + title + L"\xbb " +
L"\xab" + user + L"\xbb";
ruentrydata.image = app.GetMainDlg()->GetEntryImage(ci);
ruentrydata.pci = (CItemData *)&ci;
}
ListofAllMenuStrings.push_back(ruentrydata);
retval = true;
}
return retval;
}
示例10: AddGroup
wxTreeItemId PWSTreeCtrl::AddGroup(const StringX &group)
{
wxTreeItemId ti = GetRootItem();
if (!ti.IsOk())
ti=AddRoot(wxString());
// Add a group at the end of path
wxTreeItemId si;
if (!group.empty()) {
StringX path = group;
StringX s;
do {
s = GetPathElem(path);
if (!ExistsInTree(ti, s, si)) {
ti = AppendItem(ti, s.c_str());
wxTreeCtrl::SetItemImage(ti, NODE_II);
} else
ti = si;
} while (!path.empty());
}
return ti;
}
示例11: switch
inline wostream& print_field_value(wostream &os, wchar_t tag,
const CItemData &item, CItemData::FieldType ft)
{
StringX fieldValue;
switch (ft) {
case CItemData::DCA:
case CItemData::SHIFTDCA:
{
int16 dca = -1;
if (item.GetDCA(dca) != -1) {
LoadAString(fieldValue, dca2str(dca));
}
break;
}
case CItemData::PWHIST:
{
const StringX pwh_str = item.GetPWHistory();
if (!pwh_str.empty()) {
StringXStream value_stream;
size_t ignored;
PWHistList pwhl;
const bool save_pwhistory = CreatePWHistoryList(pwh_str, ignored, ignored, pwhl, PWSUtil::TMC_LOCALE);
value_stream << L"Save: " << (save_pwhistory? L"Yes" : L"No");
if ( !pwhl.empty() ) value_stream << endl;
for( const auto &pwh: pwhl) value_stream << pwh.changedate << L": " << pwh.password << endl;
fieldValue = value_stream.str();
}
break;
}
case CItemData::POLICY:
{
PWPolicy policy;
item.GetPWPolicy(policy);
fieldValue = policy.GetDisplayString();
break;
}
default:
fieldValue = item.GetFieldValue(ft);
break;
}
const StringX sep1{L' '}, sep2{L": "};
StringXStream tmpStream;
tmpStream << tag << L' ' << item.FieldName(ft) << L": " << fieldValue;
const auto offset = 1 /*tag*/ + sep1.size() + sep2.size() + item.FieldName(ft).size();
lines_vec lines{ stream2vec(tmpStream)};
if ( lines.size() > 1) {
std::for_each( lines.begin()+1, lines.end(), [offset](StringX &line) { line.insert(0, offset, L' '); });
}
for( const auto &line: lines ) os << line << endl;
return os;
}
示例12: CheckPasskey
int PWSfile::CheckPasskey(const StringX &filename,
const StringX &passkey, VERSION &version)
{
if (passkey.empty())
return WRONG_PASSWORD;
int status;
version = UNKNOWN_VERSION;
status = PWSfileV3::CheckPasskey(filename, passkey);
if (status == SUCCESS)
version = V30;
if (status == NOT_PWS3_FILE) {
status = PWSfileV1V2::CheckPasskey(filename, passkey);
if (status == SUCCESS)
version = V20; // or V17?
}
return status;
}
示例13: context_tag
/////////////////////////////////////////////////////////////////
// Context diff
////////
inline wchar_t context_tag(CItem::FieldType ft, const CItemData::FieldBits &fields,
const CItemData &item, const CItemData &otherItem)
{
// The two items were compared & found to be differing on this field
// only show this tag for fields there were compared
if (fields.test(ft))
return '!';
const StringX val{item.GetFieldValue(ft)};
// This field was not compared, it could be different. Print it only if
// it is the same in both items
if (val == otherItem.GetFieldValue(ft))
return L' ';
if (val.empty())
return L'+';
// Don't print it
return L'-';
}
示例14: issuecmd
bool PWSRun::issuecmd(const StringX &sxFile, const StringX &sxParameters,
const bool &bAutotype) const
{
SHELLEXECUTEINFO si;
ZeroMemory(&si, sizeof(SHELLEXECUTEINFO));
si.cbSize = sizeof(SHELLEXECUTEINFO);
si.nShow = SW_SHOWNORMAL;
si.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_DOENVSUBST;
si.lpFile = sxFile.c_str();
if (!sxParameters.empty()) {
si.lpParameters = sxParameters.c_str();
}
BOOL bAT_init(FALSE);
if (bAutotype && isValid()) {
if (pImpl->pInit != NULL && pImpl->pUnInit != NULL &&
pImpl->hCBWnd != NULL) {
// OK - try and make it tell us! Won't if another instance of
// PWS is doing this at exactly the same time - silly user!
bAT_init = pImpl->pInit(pImpl->hCBWnd);
pws_os::Trace(_T("PWSRun::issuecmd - AT_HK_Initialise: %s\n"),
bAT_init == TRUE ? _T("OK") : _T("FAILED"));
}
}
BOOL shellExecStatus = ::ShellExecuteEx(&si);
if (shellExecStatus != TRUE) {
// ShellExecute writes its own message on failure!
if (bAT_init) {
bAT_init = pImpl->pUnInit(pImpl->hCBWnd);
pws_os::Trace(_T("PWSRun::issuecmd - AT_HK_UnInitialise: %s\n"),
bAT_init == TRUE ? _T("OK") : _T("FAILED"));
}
return false;
}
return true;
}
示例15: ASSERT
bool CUTF8Conv::ToUTF8(const StringX &data,
const unsigned char *&utf8, size_t &utf8Len)
{
// If we're not in Unicode, call MultiByteToWideChar to get from
// current codepage to Unicode, and then WideCharToMultiByte to
// get to UTF-8 encoding.
if (data.empty()) {
utf8Len = 0;
return true;
}
wchar_t *wcPtr = const_cast<wchar_t *>(data.c_str());
size_t wcLen = data.length()+1;
// first get needed utf8 buffer size
size_t mbLen = pws_os::wcstombs(NULL, 0, wcPtr, wcLen);
if (mbLen == 0) { // uh-oh
ASSERT(0);
m_utf8Len = 0;
return false;
}
// Allocate buffer (if previous allocation was smaller)
if (mbLen > m_utf8MaxLen) {
if (m_utf8 != NULL)
trashMemory(m_utf8, m_utf8MaxLen);
delete[] m_utf8;
m_utf8 = new unsigned char[mbLen];
m_utf8MaxLen = mbLen;
}
// Finally get result
m_utf8Len = pws_os::wcstombs(reinterpret_cast<char *>(m_utf8), mbLen, wcPtr, wcLen);
ASSERT(m_utf8Len != 0);
m_utf8Len--; // remove unneeded null termination
utf8 = m_utf8;
utf8Len = m_utf8Len;
return true;
}