本文整理汇总了C++中StringX::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ StringX::c_str方法的具体用法?C++ StringX::c_str怎么用?C++ StringX::c_str使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringX
的用法示例。
在下文中一共展示了StringX::c_str方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetData
bool PWSclip::SetData(const StringX &text)
{
if (wxTheClipboard->Open()) {
wxTheClipboard->SetData(new wxTextDataObject(text.c_str()));
wxTheClipboard->Close();
return true;
} else
return false;
}
示例2: 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;
}
示例3: ReadVersion
PWSfile::VERSION PWSfile::ReadVersion(const StringX &filename)
{
if (pws_os::FileExists(filename.c_str())) {
VERSION v;
if (PWSfileV3::IsV3x(filename, v))
return v;
else
return V20;
} else
return UNKNOWN_VERSION;
}
示例4: WriteCBC
size_t PWSfileV1V2::WriteCBC(unsigned char type, const StringX &data)
{
#ifndef UNICODE
const unsigned char *datastr = (const unsigned char *)data.c_str();
return PWSfile::WriteCBC(type, datastr, data.length());
#else
wchar_t *wcPtr = const_cast<wchar_t *>(data.c_str());
size_t wcLen = data.length() + 1;
size_t mbLen = 3 * wcLen;
unsigned char *acp = new unsigned char[mbLen];
size_t acpLen = pws_os::wcstombs(reinterpret_cast<char *>(acp), mbLen,
wcPtr, wcLen, false);
ASSERT(acpLen != 0);
acpLen--; // remove unneeded null termination
size_t retval = PWSfile::WriteCBC(type, acp, acpLen);
trashMemory(acp, mbLen);
delete[] acp;
return retval;
#endif
}
示例5: OnGeneratePassword
void CPasswordPolicyDlg::OnGeneratePassword()
{
UpdateData(TRUE);
PWPolicy st_pp;
if (m_UseNamedPolicy == BST_UNCHECKED) {
// Use specific policy but validate it first
if (Validate() == FALSE)
return;
if (m_PWUseLowercase == TRUE)
st_pp.flags |= PWPolicy::UseLowercase;
if (m_PWUseUppercase == TRUE)
st_pp.flags |= PWPolicy::UseUppercase;
if (m_PWUseDigits == TRUE)
st_pp.flags |= PWPolicy::UseDigits;
if (m_PWUseSymbols == TRUE)
st_pp.flags |= PWPolicy::UseSymbols;
if (m_PWUseHexdigits == TRUE)
st_pp.flags |= PWPolicy::UseHexDigits;
if (m_PWEasyVision == TRUE)
st_pp.flags |= PWPolicy::UseEasyVision;
if (m_PWMakePronounceable == TRUE)
st_pp.flags |= PWPolicy::MakePronounceable;
st_pp.length = m_PWDefaultLength;
st_pp.digitminlength = m_PWDigitMinLength;
st_pp.lowerminlength = m_PWLowerMinLength;
st_pp.symbolminlength = m_PWSymbolMinLength;
st_pp.upperminlength = m_PWUpperMinLength;
m_SymbolsEdit.GetWindowText(m_Symbols);
st_pp.symbols = LPCWSTR(m_Symbols);
} else {
// Use named policy
if (m_PolicyNameEdit.IsWindowVisible()) {
m_PolicyNameEdit.GetWindowText((CString &)m_policyname);
} else {
int index = m_cbxPolicyNames.GetCurSel();
m_cbxPolicyNames.GetLBText(index, m_policyname);
}
StringX sxPolicyName(m_policyname);
GetMainDlg()->GetPolicyFromName(sxPolicyName, st_pp);
}
StringX passwd;
GetMainDlg()->MakeRandomPassword(passwd, st_pp);
m_password = passwd.c_str();
m_ex_password.SetWindowText(m_password);
m_ex_password.Invalidate();
UpdateData(FALSE);
}
示例6: SetData
/**
* Put text data to clipboard
* @param[in] data data to store in clipboard
* @param isSensitive if data sensitive, we remember its hash and will clear on ClearCBData() call
* @return \c true, if we could open the clipboard and put the data
*/
bool PWSclipboard::SetData(const StringX &data)
{
wxMutexLocker clip(m_clipboardMutex);
bool res = false;
if (wxTheClipboard->Open()) {
res = wxTheClipboard->SetData(new wxTextDataObject(data.c_str()));
wxTheClipboard->Close();
}
m_set = true;
if (res) {
// identify data in clipboard as ours, so as not to clear the wrong data later
// of course, we don't want an extra copy of a password floating around
// in memory, so we'll use the hash
SHA256 ctx;
const wchar_t *str = data.c_str();
ctx.Update(reinterpret_cast<const unsigned char *>(str), data.length()*sizeof(wchar_t));
ctx.Final(m_digest);
}
return res;
}
示例7: 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;
}
示例8: InsertItemIntoGUITree
void CCompareWithSelectDlg::InsertItemIntoGUITree(CItemData &ci)
{
HTREEITEM ti;
StringX treeDispString = (LPCWSTR)m_cwItemTree.MakeTreeDisplayString(ci);
// get path, create if necessary, add title as last node
ti = m_cwItemTree.AddGroup(ci.GetGroup().c_str());
ti = m_cwItemTree.InsertItem(treeDispString.c_str(), ti, TVI_SORT);
m_cwItemTree.SetItemData(ti, (DWORD_PTR)&ci);
int nImage = m_cwItemTree.GetEntryImage(ci);
m_cwItemTree.SetItemImage(ti, nImage, nImage);
}
示例9: ReadVersion
PWSfile::VERSION PWSfile::ReadVersion(const StringX &filename, const StringX &passkey)
{
if (pws_os::FileExists(filename.c_str())) {
VERSION v;
if (PWSfileV3::IsV3x(filename, v))
return v;
else if (PWSfileV4::IsV4x(filename, passkey, v))
return v;
else if (PWSfileV1V2::CheckPasskey(filename, passkey) == SUCCESS)
return V20;
else
return UNKNOWN_VERSION;
} else
return UNKNOWN_VERSION;
}
示例10: OnOkClick
void CSafeCombinationSetup::OnOkClick( wxCommandEvent& /* evt */ )
{
if (Validate() && TransferDataFromWindow()) {
if (m_password != m_verify) {
wxMessageDialog err(this, _("The two entries do not match."),
_("Error"), wxOK | wxICON_EXCLAMATION);
err.ShowModal();
return;
}
if (m_password.empty()) {
wxMessageDialog err(this, _("Please enter the key and verify it."),
_("Error"), wxOK | wxICON_EXCLAMATION);
err.ShowModal();
return;
}
// Vox populi vox dei - folks want the ability to use a weak
// passphrase, best we can do is warn them...
// If someone want to build a version that insists on proper
// passphrases, then just define the preprocessor macro
// PWS_FORCE_STRONG_PASSPHRASE in the build properties/Makefile
// (also used in CPasskeyChangeDlg)
#ifndef _DEBUG // for debug, we want no checks at all, to save time
StringX errmess;
if (!CPasswordCharPool::CheckPassword(tostringx(m_password), errmess)) {
wxString cs_msg;
cs_msg = _("Weak passphrase:");
cs_msg += wxT("\n\n");
cs_msg += errmess.c_str();
#ifndef PWS_FORCE_STRONG_PASSPHRASE
cs_msg += wxT("\n");
cs_msg += _("Use it anyway?");
wxMessageDialog mb(this, cs_msg, _("Warning"),
wxYES_NO | wxNO_DEFAULT | wxICON_HAND);
int rc = mb.ShowModal();
if (rc == wxID_NO)
return;
#else
cs_msg += wxT("\n");
cs_msg += _("Please try another");
wxMessageDialog mb(this, cs_msg, _("Error"), wxOK | wxICON_HAND);
mb.ShowModal();
return;
#endif // PWS_FORCE_STRONG_PASSPHRASE
}
#endif // _DEBUG
EndModal(wxID_OK);
}
}
示例11: Diff
///////////////////////////////////
// dispatcher. Called from main()
/////////
int Diff(PWScore &core, const UserArgs &ua)
{
CompareData current, comparison, conflicts, identical;
PWScore otherCore;
const StringX otherSafe{std2stringx(ua.opArg)};
CItemData::FieldBits safeFields{ua.fields};
for( auto ft: diff_fields ) {
if (ua.fields.test(ft) && CItemData::IsTextField(ft)) {
safeFields.set(ft);
}
}
safeFields.reset(CItem::RMTIME);
int status = OpenCore(otherCore, otherSafe);
if ( status == PWScore::SUCCESS ) {
constexpr bool treatWhitespacesAsEmpty = false;
core.Compare( &otherCore,
safeFields,
ua.subset.valid(),
treatWhitespacesAsEmpty,
ua.subset.value,
ua.subset.field,
ua.subset.rule,
current,
comparison,
conflicts,
identical);
switch (ua.dfmt) {
case UserArgs::DiffFmt::Unified:
unified_diff(core, otherCore, current, comparison, conflicts, identical);
break;
case UserArgs::DiffFmt::Context:
context_diff(core, otherCore, current, comparison, conflicts, identical);
break;
case UserArgs::DiffFmt::SideBySide:
sidebyside_diff(core, otherCore, current, comparison, conflicts, identical, safeFields, ua.colwidth);
break;
default:
assert(false);
break;
}
otherCore.UnlockFile(otherSafe.c_str());
}
return status;
}
示例12: OnYubibtnClick
void CSafeCombinationSetup::OnYubibtnClick( wxCommandEvent& /* event */ )
{
if (Validate() && TransferDataFromWindow()) {
if (m_password != m_verify) {
wxMessageDialog err(this, _("The two entries do not match."),
_("Error"), wxOK | wxICON_EXCLAMATION);
err.ShowModal();
return;
}
StringX response;
bool oldYubiChallenge = ::wxGetKeyState(WXK_SHIFT); // for pre-0.94 databases
if (PerformChallengeResponse(this, tostringx(m_password), response, oldYubiChallenge)) {
m_password = response.c_str();
EndModal(wxID_OK);
}
}
}
示例13: ExistsInTree
bool PWSTreeCtrl::ExistsInTree(wxTreeItemId node,
const StringX &s, wxTreeItemId &si) const
{
// returns true iff s is a direct descendant of node
wxTreeItemIdValue cookie;
wxTreeItemId ti = GetFirstChild(node, cookie);
while (ti) {
const wxString itemText = GetItemText(ti);
if (itemText == s.c_str()) {
si = ti;
return true;
}
ti = GetNextSibling(ti);
}
return false;
}
示例14: OnOkClick
void CSafeCombinationChange::OnOkClick( wxCommandEvent& /* evt */ )
{
if (Validate() && TransferDataFromWindow()) {
StringX errmess;
const StringX old = m_oldresponse.empty() ? m_oldpasswd : m_oldresponse;
int rc = m_core.CheckPasskey(m_core.GetCurFile(), old);
if (rc == PWScore::WRONG_PASSWORD) {
wxMessageDialog err(this, _("The old safe combination is not correct"),
_("Error"), wxOK | wxICON_EXCLAMATION);
err.ShowModal();
} else if (rc == PWScore::CANT_OPEN_FILE) {
wxMessageDialog err(this, _("Cannot verify old safe combination - file gone?"),
_("Error"), wxOK | wxICON_EXCLAMATION);
err.ShowModal();
} else if (m_confirm != m_newpasswd) {
wxMessageDialog err(this, _("New safe combination and confirmation do not match"),
_("Error"), wxOK | wxICON_EXCLAMATION);
err.ShowModal();
// Vox populi vox dei - folks want the ability to use a weak
// passphrase, best we can do is warn them...
// If someone want to build a version that insists on proper
// passphrases, then just define the preprocessor macro
// PWS_FORCE_STRONG_PASSPHRASE in the build properties/Makefile
// (also used in CPasskeySetup)
} else if (!CPasswordCharPool::CheckPassword(m_newpasswd, errmess)) {
wxString msg = _("Weak passphrase:");
msg += wxT("\n\n");
msg += errmess.c_str();
#ifndef PWS_FORCE_STRONG_PASSPHRASE
msg += wxT("\n");
msg += _("Use it anyway?");
wxMessageDialog err(this, msg,
_("Error"), wxYES_NO | wxICON_HAND);
int rc1 = err.ShowModal();
if (rc1 == wxID_YES)
EndModal(wxID_OK);
#else
wxMessageDialog err(this, msg,
_("Error"), wxOK | wxICON_HAND);
err.ShowModal();
#endif // PWS_FORCE_STRONG_PASSPHRASE
} else { // password checks out OK.
EndModal(wxID_OK);
}
}
}
示例15: CheckLatestVersion
CheckVersion::CheckStatus CAboutDlg::CheckLatestVersion(std::wstring &latest)
{
CInternetSession session(L"PasswordSafe Version Check");
CStdioFile *fh;
// Put up hourglass...this might take a while
CWaitCursor waitCursor;
try {
// Loading the file as binary since we're treating it as UTF-8
fh = session.OpenURL(L"https://pwsafe.org/latest.xml",
1, (INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_RELOAD));
} catch (CInternetException *) {
// throw;
return CheckVersion::CANT_CONNECT;
}
ASSERT(fh != NULL);
CString latest_xml;
unsigned char buff[BUFSIZ + 1];
StringX chunk;
UINT nRead;
CUTF8Conv conv;
while ((nRead = fh->Read(buff, BUFSIZ)) != 0) {
buff[nRead] = '\0';
// change to widechar representation
if (!conv.FromUTF8(buff, nRead, chunk)) {
fh->Close();
delete fh;
session.Close();
return CheckVersion::CANT_READ;
} else
latest_xml += chunk.c_str();
}
fh->Close();
delete fh;
session.Close();
waitCursor.Restore(); // restore normal cursor
CheckVersion vh(m_nMajor, m_nMinor, m_nBuild);
return vh.CheckLatestVersion(LPCWSTR(latest_xml), latest);
}