| Version: 3.2.5

Public Member Functions | List of all members
wxSecretString Class Reference

`#include <wx/secretstore.h>`

Inheritance diagram for wxSecretString:
[legend]

## Detailed Description

Temporary string whose contents will be overwritten when it is destroyed.

Objects of this class must not be used polymorphically as it derives from wxString which doesn't have a virtual destructor. Typically, they are used as local variables, e.g.

void TryToAuthenticate(const wxString& secretValue)
{
wxSecretString password(secretValue);
... use password as any wxString ...
// Here password memory is overwritten to prevent the password from
// remaining in memory.
}
wxSecretString
Temporary string whose contents will be overwritten when it is destroyed.
Definition: secretstore.h:31
wxString
String class for passing textual data to or receiving it from wxWidgets.
Definition: string.h:315

Since
  3.1.5

## Public Member Functions

| wxSecretString ()
| Default constructor creates an empty string. More...
| wxSecretString (const wxString &value)
| Constructor from a plain string. More...
| wxSecretString (const wxSecretValue &value)
| Constructor from a secret value. More...
| ~wxSecretString ()
| Destructor calls wxSecretValue::WipeString() More...
Public Member Functions inherited from wxString
| wxString ()
| Default constructor. More...
| wxString (const wxString &stringSrc)
| Creates a string from another string. More...
| wxString (wxUniChar ch, size_t nRepeat=1)
| Construct a string consisting of nRepeat copies of ch. More...
| wxString (wxUniCharRef ch, size_t nRepeat=1)
| Construct a string consisting of nRepeat copies of ch. More...
| wxString (char ch, size_t nRepeat=1)
| Construct a string consisting of nRepeat copies of ch converted to Unicode using the current locale encoding. More...
| wxString (wchar_t ch, size_t nRepeat=1)
| Construct a string consisting of nRepeat copies of ch. More...
| wxString (const char *psz)
| Constructs a string from the string literal psz using the current locale encoding to convert it to Unicode (wxConvLibc). More...
| wxString (const char *psz, const wxMBConv &conv)
| Constructs a string from the string literal psz using conv to convert it Unicode. More...
| wxString (const char *psz, size_t nLength)
| Constructs a string from the first nLength bytes of the string literal psz using the current locale encoding to convert it to Unicode (wxConvLibc). More...
| wxString (const char *psz, const wxMBConv &conv, size_t nLength)
| Constructs a string from the first nLength bytes of the string literal psz using conv to convert it Unicode. More...
| wxString (const wchar_t *pwz)
| Constructs a string from the string literal pwz. More...
| wxString (const wchar_t *pwz, size_t nLength)
| Constructs a string from the first nLength characters of the string literal pwz. More...
| wxString (const wxCharBuffer &buf)
| Constructs a string from buf using the using the current locale encoding to convert it to Unicode. More...
| wxString (const wxWCharBuffer &buf)
| Constructs a string from buf. More...
| wxString (const std::string &str)
| Constructs a string from str using the using the current locale encoding to convert it to Unicode (wxConvLibc). More...
| wxString (const std::wstring &str)
| Constructs a string from str. More...
| ~wxString ()
| String destructor. More...
wxString | operator= (const wxString &str)
| Assignment: see the relative wxString constructor. More...
wxString | operator= (wxUniChar c)
| Assignment: see the relative wxString constructor. More...
size_t | Len () const
| Returns the length of the string. More...
size_t | Length () const
| Returns the length of the string (same as Len). More...
bool | IsEmpty () const
| Returns true if the string is empty. More...
bool | IsNull () const
| Returns true if the string is empty (same as wxString::IsEmpty). More...
bool | operator! () const
| Empty string is false, so !string will only return true if the string is empty. More...
wxUniChar | GetChar (size_t n) const
| Returns the character at position n (read-only). More...
const wxCStrData | GetData () const
| wxWidgets compatibility conversion. More...
wxUniCharRef | GetWritableChar (size_t n)
| Returns a reference to the character at position n. More...
wxStringCharType * | GetWriteBuf (size_t len)
| Returns a writable buffer of at least len bytes. More...
void | UngetWriteBuf ()
| Puts the string back into a reasonable state (in which it can be used normally), after GetWriteBuf() was called. More...
void | UngetWriteBuf (size_t len)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
void | SetChar (size_t n, wxUniChar ch)
| Sets the character at position n. More...
wxUniChar | Last () const
| Returns the last character. More...
wxUniCharRef | Last ()
| Returns a reference to the last character (writable). More...
wxUniChar | operator[] (size_t i) const
| Returns the i-th character of the string. More...
wxUniCharRef | operator[] (size_t i)
| Returns a writable reference to the i-th character of the string. More...
wxCStrData | c_str () const
| Returns a lightweight intermediate class which is in turn implicitly convertible to both `const` `char*` and to `const` `wchar_t*`. More...
wxWritableCharBuffer | char_str (const wxMBConv &conv=wxConvLibc) const
| Returns an object with string data that is implicitly convertible to `char*` pointer. More...
template<typename T >
wxCharTypeBuffer< T > | tchar_str (size_t *len=NULL) const
| Returns buffer of the specified type containing the string data. More...
const TYPE | fn_str () const
| Returns a string representation suitable for passing to OS' functions for file handling. More...
const wxCharBuffer | mb_str (const wxMBConv &conv=wxConvLibc) const
| Returns the multibyte (C string) representation of the string using conv's wxMBConv::cWC2MB method and returns wxCharBuffer. More...
const wxScopedCharBuffer | utf8_str () const
| Converts the strings contents to UTF-8 and returns it either as a temporary wxCharBuffer object or as a pointer to the internal string contents in UTF-8 build. More...
const std::string | utf8_string () const
| Return the string as an std::string using UTF-8 encoding. More...
const TYPE | wc_str () const
| Converts the strings contents to the wide character representation and returns it as a temporary wxWCharBuffer object (Unix and macOS) or returns a pointer to the internal string contents in wide character mode (Windows). More...
wxWritableWCharBuffer | wchar_str () const
| Returns an object with string data that is implicitly convertible to `char*` pointer. More...
const wxStringCharType * | wx_str () const
| Explicit conversion to C string in the internal representation (either wchar_t* or UTF-8-encoded char*, depending on the build). More...
const wxScopedCharBuffer | To8BitData () const
| Converts the string to an 8-bit string in ISO-8859-1 encoding in the form of a wxCharBuffer (Unicode builds only). More...
const TYPE | ToAscii (char replaceWith='_') const
| Converts the string to an ASCII, 7-bit string in the form of a wxCharBuffer (Unicode builds only) or a C string (ANSI builds). More...
std::string | ToStdString (const wxMBConv &conv=wxConvLibc) const
| Return the string as a std::string using conv's wxMBConv::cWC2MB method. More...
std::wstring | ToStdWstring () const
| Return the string as a std::wstring. More...
const wxScopedCharBuffer | ToUTF8 () const
| Same as utf8_str(). More...
wxString & | Append (const char *psz)
| Appends the string literal psz. More...
wxString & | Append (const wchar_t *pwz)
| Appends the wide string literal pwz. More...
wxString & | Append (const char *psz, size_t nLen)
| Appends the string literal psz with max length nLen. More...
wxString & | Append (const wchar_t *pwz, size_t nLen)
| Appends the wide string literal psz with max length nLen. More...
wxString & | Append (const wxString &s)
| Appends the string s. More...
wxString & | Append (wxUniChar ch, size_t count=1u)
| Appends the character ch count times. More...
wxString & | Prepend (const wxString &str)
| Prepends str to this string, returning a reference to this string. More...
wxString | operator+ (const wxString &x, const wxString &y)
| Concatenation: returns a new string equal to the concatenation of the operands. More...
wxString | operator+ (const wxString &x, wxUniChar y)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
wxString & | operator<< (const wxString &s)
| Appends the string literal psz. More...
wxString & | operator<< (const char *psz)
| Appends the string literal psz. More...
wxString & | operator<< (const wchar_t *pwz)
| Appends the string literal psz. More...
wxString & | operator<< (const wxCStrData &psz)
| Appends the string literal psz. More...
wxString & | operator<< (char ch)
| Appends the string literal psz. More...
wxString & | operator<< (unsigned char ch)
| Appends the string literal psz. More...
wxString & | operator<< (wchar_t ch)
| Appends the string literal psz. More...
wxString & | operator<< (const wxCharBuffer &s)
| Appends the string literal psz. More...
wxString & | operator<< (const wxWCharBuffer &s)
| Appends the string literal psz. More...
wxString & | operator<< (wxUniChar ch)
| Appends the string literal psz. More...
wxString & | operator<< (wxUniCharRef ch)
| Appends the string literal psz. More...
wxString & | operator<< (unsigned int ui)
| Appends the string literal psz. More...
wxString & | operator<< (long l)
| Appends the string literal psz. More...
wxString & | operator<< (unsigned long ul)
| Appends the string literal psz. More...
wxString & | operator<< (wxLongLong_t ll)
| Appends the string literal psz. More...
wxString & | operator<< (wxULongLong_t ul)
| Appends the string literal psz. More...
wxString & | operator<< (float f)
| Appends the string literal psz. More...
wxString & | operator<< (double d)
| Appends the string literal psz. More...
void | operator+= (const wxString &str)
| Concatenation in place: the argument is appended to the string. More...
void | operator+= (wxUniChar c)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
int | Cmp (const wxString &s) const
| Case-sensitive comparison. More...
int | CmpNoCase (const wxString &s) const
| Case-insensitive comparison. More...
bool | IsSameAs (const wxString &s, bool caseSensitive=true) const
| Test whether the string is equal to another string s. More...
bool | IsSameAs (wxUniChar ch, bool caseSensitive=true) const
| Test whether the string is equal to the single character ch. More...
bool | Matches (const wxString &mask) const
| Returns true if the string contents matches a mask containing '*' and '?'. More...
bool | StartsWith (const wxString &prefix, wxString *rest=NULL) const
| This function can be used to test if the string starts with the specified prefix. More...
bool | EndsWith (const wxString &suffix, wxString *rest=NULL) const
| This function can be used to test if the string ends with the specified suffix. More...
wxString | Mid (size_t first, size_t nCount=wxString::npos) const
| Returns a substring starting at first, with length count, or the rest of the string if count is the default value. More...
wxString | SubString (size_t from, size_t to) const
| Returns the part of the string between the indices from and to inclusive. More...
wxString | operator() (size_t start, size_t len) const
| Same as Mid() (substring extraction). More...
wxString | Left (size_t count) const
| Returns the first count characters of the string. More...
wxString | Right (size_t count) const
| Returns the last count characters. More...
wxString | AfterFirst (wxUniChar ch) const
| Gets all the characters after the first occurrence of ch. More...
wxString | AfterLast (wxUniChar ch) const
| Gets all the characters after the last occurrence of ch. More...
wxString | BeforeFirst (wxUniChar ch, wxString *rest=NULL) const
| Gets all characters before the first occurrence of ch. More...
wxString | BeforeLast (wxUniChar ch, wxString *rest=NULL) const
| Gets all characters before the last occurrence of ch. More...
wxString | Capitalize () const
| Return the copy of the string with the first string character in the upper case and the subsequent ones in the lower case. More...
wxString | Lower () const
| Returns this string converted to the lower case. More...
void | LowerCase ()
| Same as MakeLower. More...
wxString & | MakeCapitalized ()
| Converts the first characters of the string to the upper case and all the subsequent ones to the lower case and returns the result. More...
wxString & | MakeLower ()
| Converts all characters to lower case and returns the reference to the modified string. More...
wxString & | MakeUpper ()
| Converts all characters to upper case and returns the reference to the modified string. More...
wxString | Upper () const
| Returns this string converted to upper case. More...
void | UpperCase ()
| The same as MakeUpper(). More...
int | Find (wxUniChar ch, bool fromEnd=false) const
| Searches for the given character ch. More...
int | Find (const wxString &sub) const
| Searches for the given string sub. More...
int | First (wxUniChar ch) const
| Same as Find(). More...
int | First (const wxString &str) const
| Same as Find(). More...
size_t | Replace (const wxString &strOld, const wxString &strNew, bool replaceAll=true)
| Replace first (or all) occurrences of substring with another one. More...
bool | ToDouble (double *val) const
| Attempts to convert the string to a floating point number. More...
bool | ToCDouble (double *val) const
| Variant of ToDouble(), always working in "C" locale. More...
bool | ToInt (int *val, int base=10) const
| Works like ToLong() but for signed integers. More...
bool | ToUInt (unsigned int *val, int base=10) const
| Works like ToULong() but for unsigned integers. More...
bool | ToLong (long *val, int base=10) const
| Attempts to convert the string to a signed integer in base base. More...
bool | ToCLong (long *val, int base=10) const
| Variant of ToLong() always working in "C" locale. More...
bool | ToLongLong (wxLongLong_t *val, int base=10) const
| This is exactly the same as ToLong() but works with 64 bit integer numbers. More...
bool | ToULong (unsigned long *val, int base=10) const
| Attempts to convert the string to an unsigned integer in base base. More...
bool | ToCULong (unsigned long *val, int base=10) const
| Variant of ToULong() always working in "C" locale. More...
bool | ToULongLong (wxULongLong_t *val, int base=10) const
| This is exactly the same as ToULong() but works with 64 bit integer numbers. More...
int | Printf (const wxString &pszFormat,...)
| Similar to the standard function sprintf(). More...
int | PrintfV (const wxString &pszFormat, va_list argPtr)
| Similar to vprintf. More...
bool | Alloc (size_t nLen)
| Preallocate enough space for wxString to store nLen characters. More...
bool | Shrink ()
| Minimizes the string's memory. More...
wxString | Clone () const
| Returns a deep copy of the string. More...
void | Clear ()
| Empties the string and frees memory occupied by it. More...
bool | Contains (const wxString &str) const
| Returns true if target appears anywhere in wxString; else false. More...
void | Empty ()
| Makes the string empty, but doesn't free memory occupied by the string. More...
int | Freq (wxUniChar ch) const
| Returns the number of occurrences of ch in the string. More...
bool | IsAscii () const
| Returns true if the string contains only ASCII characters. More...
bool | IsNumber () const
| Returns true if the string is an integer (with possible sign). More...
bool | IsWord () const
| Returns true if the string is a word. More...
wxString & | Pad (size_t count, wxUniChar chPad=' ', bool fromRight=true)
| Adds count copies of chPad to the beginning, or to the end of the string (the default). More...
wxString & | Remove (size_t pos)
| Removes all characters from the string starting at pos. More...
wxString & | Remove (size_t pos, size_t len)
| Removes len characters from the string, starting at pos. More...
wxString & | RemoveLast (size_t n=1)
| Removes the last character. More...
wxString | Strip (stripType s=trailing) const
| Strip characters at the front and/or end. More...
wxString & | Trim (bool fromRight=true)
| Removes white-space (space, tabs, form feed, newline and carriage return) from the left or from the right end of the string (right is default). More...
wxString & | Truncate (size_t len)
| Truncate the string to the given length. More...
const_iterator | begin () const
iterator | begin ()
const_iterator | cbegin () const
const_iterator | end () const
iterator | end ()
const_iterator | cend () const
const_reverse_iterator | rbegin () const
reverse_iterator | rbegin ()
const_reverse_iterator | crbegin () const
const_reverse_iterator | rend () const
reverse_iterator | rend ()
const_reverse_iterator | crend () const
wxString & | append (const wxString &str, size_t pos, size_t n)
wxString & | append (const wxString &str)
wxString & | append (const char *sz, size_t n)
wxString & | append (const wchar_t *sz, size_t n)
wxString & | append (size_t n, wxUniChar ch)
wxString & | append (const_iterator first, const_iterator last)
wxString & | assign (const wxString &str, size_t pos, size_t n)
wxString & | assign (const wxString &str)
wxString & | assign (const char *sz, size_t n)
wxString & | assign (const wchar_t *sz, size_t n)
wxString & | assign (size_t n, wxUniChar ch)
wxString & | assign (const_iterator first, const_iterator last)
wxUniChar | at (size_t n) const
wxUniCharRef | at (size_t n)
void | clear ()
size_type | capacity () const
int | compare (const wxString &str) const
int | compare (size_t nStart, size_t nLen, const wxString &str) const
int | compare (size_t nStart, size_t nLen, const wxString &str, size_t nStart2, size_t nLen2) const
int | compare (size_t nStart, size_t nLen, const char *sz, size_t nCount=npos) const
int | compare (size_t nStart, size_t nLen, const wchar_t *sz, size_t nCount=npos) const
wxCStrData | data () const
bool | empty () const
wxString & | erase (size_type pos=0, size_type n=npos)
iterator | erase (iterator first, iterator last)
iterator | erase (iterator first)
size_t | find (const wxString &str, size_t nStart=0) const
size_t | find (const char *sz, size_t nStart=0, size_t n=npos) const
size_t | find (const wchar_t *sz, size_t nStart=0, size_t n=npos) const
size_t | find (wxUniChar ch, size_t nStart=0) const
size_t | find_first_of (const char *sz, size_t nStart=0) const
size_t | find_first_of (const wchar_t *sz, size_t nStart=0) const
size_t | find_first_of (const char *sz, size_t nStart, size_t n) const
size_t | find_first_of (const wchar_t *sz, size_t nStart, size_t n) const
size_t | find_first_of (wxUniChar c, size_t nStart=0) const
size_t | find_last_of (const wxString &str, size_t nStart=npos) const
size_t | find_last_of (const char *sz, size_t nStart=npos) const
size_t | find_last_of (const wchar_t *sz, size_t nStart=npos) const
size_t | find_last_of (const char *sz, size_t nStart, size_t n) const
size_t | find_last_of (const wchar_t *sz, size_t nStart, size_t n) const
size_t | find_last_of (wxUniChar c, size_t nStart=npos) const
size_t | find_first_not_of (const wxString &str, size_t nStart=0) const
size_t | find_first_not_of (const char *sz, size_t nStart=0) const
size_t | find_first_not_of (const wchar_t *sz, size_t nStart=0) const
size_t | find_first_not_of (const char *sz, size_t nStart, size_t n) const
size_t | find_first_not_of (const wchar_t *sz, size_t nStart, size_t n) const
size_t | find_first_not_of (wxUniChar ch, size_t nStart=0) const
size_t | find_last_not_of (const wxString &str, size_t nStart=npos) const
size_t | find_last_not_of (const char *sz, size_t nStart=npos) const
size_t | find_last_not_of (const wchar_t *sz, size_t nStart=npos) const
size_t | find_last_not_of (const char *sz, size_t nStart, size_t n) const
size_t | find_last_not_of (const wchar_t *sz, size_t nStart, size_t n) const
wxString & | insert (size_t nPos, const wxString &str)
wxString & | insert (size_t nPos, const wxString &str, size_t nStart, size_t n)
wxString & | insert (size_t nPos, const char *sz, size_t n)
wxString & | insert (size_t nPos, const wchar_t *sz, size_t n)
wxString & | insert (size_t nPos, size_t n, wxUniChar ch)
iterator | insert (iterator it, wxUniChar ch)
void | insert (iterator it, const_iterator first, const_iterator last)
void | insert (iterator it, size_type n, wxUniChar ch)
size_t | length () const
size_type | max_size () const
void | reserve (size_t sz)
void | resize (size_t nSize, wxUniChar ch='\0')
wxString & | replace (size_t nStart, size_t nLen, const wxString &str)
wxString & | replace (size_t nStart, size_t nLen, size_t nCount, wxUniChar ch)
wxString & | replace (size_t nStart, size_t nLen, const wxString &str, size_t nStart2, size_t nLen2)
wxString & | replace (size_t nStart, size_t nLen, const char *sz, size_t nCount)
wxString & | replace (size_t nStart, size_t nLen, const wchar_t *sz, size_t nCount)
wxString & | replace (size_t nStart, size_t nLen, const wxString &s, size_t nCount)
wxString & | replace (iterator first, iterator last, const wxString &s)
wxString & | replace (iterator first, iterator last, const char *s, size_type n)
wxString & | replace (iterator first, iterator last, const wchar_t *s, size_type n)
wxString & | replace (iterator first, iterator last, size_type n, wxUniChar ch)
wxString & | replace (iterator first, iterator last, const_iterator first1, const_iterator last1)
wxString & | replace (iterator first, iterator last, const char *first1, const char *last1)
wxString & | replace (iterator first, iterator last, const wchar_t *first1, const wchar_t *last1)
size_t | rfind (const wxString &str, size_t nStart=npos) const
size_t | rfind (const char *sz, size_t nStart=npos, size_t n=npos) const
size_t | rfind (const wchar_t *sz, size_t nStart=npos, size_t n=npos) const
size_t | rfind (wxUniChar ch, size_t nStart=npos) const
size_type | size () const
wxString | substr (size_t nStart=0, size_t nLen=npos) const
void | swap (wxString &str)
bool | starts_with (const wxString &str) const
bool | starts_with (const char *sz) const
bool | starts_with (const wchar_t *sz) const
bool | ends_with (const wxString &str) const
bool | ends_with (const char *sz) const
bool | ends_with (const wchar_t *sz) const

## Additional Inherited Members

Public Types inherited from wxString
typedef wxUniChar | value_type
typedef wxUniChar | char_type
typedef wxUniCharRef | reference
typedef wxChar * | pointer
typedef const wxChar * | const_pointer
typedef size_t | size_type
typedef wxUniChar | const_reference
Static Public Member Functions inherited from wxString
static wxString | Format (const wxString &format,...)
| This static function returns the string containing the result of calling Printf() with the passed parameters on it. More...
static wxString | FormatV (const wxString &format, va_list argptr)
| This static function returns the string containing the result of calling PrintfV() with the passed parameters on it. More...
static wxString | FromCDouble (double val, int precision=-1)
| Returns a string with the textual representation of the number in C locale. More...
static wxString | FromDouble (double val, int precision=-1)
| Returns a string with the textual representation of the number. More...
static wxString | From8BitData (const char *buf, size_t len)
| Converts given buffer of binary data from 8-bit string to wxString. More...
static wxString | From8BitData (const char *buf)
| Converts given buffer of binary data from 8-bit string to wxString. More...
static wxString | FromAscii (const char *s)
| Converts the string or character from an ASCII, 7-bit form to the native wxString representation. More...
static wxString | FromAscii (const unsigned char *s)
| Converts the string or character from an ASCII, 7-bit form to the native wxString representation. More...
static wxString | FromAscii (const char *s, size_t len)
| Converts the string or character from an ASCII, 7-bit form to the native wxString representation. More...
static wxString | FromAscii (const unsigned char *s, size_t len)
| Converts the string or character from an ASCII, 7-bit form to the native wxString representation. More...
static wxString | FromAscii (char c)
| Converts the string or character from an ASCII, 7-bit form to the native wxString representation. More...
static wxString | FromUTF8 (const char *s)
| Converts C string encoded in UTF-8 to wxString. More...
static wxString | FromUTF8 (const char *s, size_t len)
| Converts C string encoded in UTF-8 to wxString. More...
static wxString | FromUTF8 (const std::string &s)
| Converts C string encoded in UTF-8 to wxString. More...
static wxString | FromUTF8Unchecked (const char *s)
| Converts C string encoded in UTF-8 to wxString without checking its validity. More...
static wxString | FromUTF8Unchecked (const char *s, size_t len)
| Converts C string encoded in UTF-8 to wxString without checking its validity. More...
static wxString | FromUTF8Unchecked (const std::string &s)
| Converts C string encoded in UTF-8 to wxString without checking its validity. More...
Static Public Attributes inherited from wxString
static const size_t | npos
| An 'invalid' value for string index. More...

## Constructor & Destructor Documentation

## ◆ wxSecretString() [1/3]

wxSecretString::wxSecretString | ( |  | ) |

Default constructor creates an empty string.

## ◆ wxSecretString() [2/3]

wxSecretString::wxSecretString | ( | const wxString & | value | ) |

Constructor from a plain string.

## ◆ wxSecretString() [3/3]

wxSecretString::wxSecretString | ( | const wxSecretValue & | value | ) |

explicit

Constructor from a secret value.

## ◆ ~wxSecretString()

wxSecretString::~wxSecretString | ( |  | ) |

Destructor calls wxSecretValue::WipeString()