Chromium Embedded Framework (CEF)
122.1.5+gf09a9bc+chromium-122.0.6261.29
|
CEF string classes can convert between all supported string types. More...
#include "include/internal/cef_string_wrappers.h"
Public Types | |
typedef traits::char_type | char_type |
typedef traits::struct_type | struct_type |
typedef traits::userfree_struct_type | userfree_struct_type |
Public Member Functions | |
CefStringBase () | |
Default constructor. More... | |
CefStringBase (const CefStringBase &str) | |
Create a new string from an existing string. More... | |
CefStringBase (const std::string &src) | |
Create a new string from an existing std::string. More... | |
CefStringBase (const char *src, size_t length=0) | |
CefStringBase (const std::wstring &src) | |
Create a new string from an existing std::wstring. More... | |
CefStringBase (const wchar_t *src, size_t length=0) | |
CefStringBase (const std::u16string &src) | |
Create a new string from an existing string16. More... | |
CefStringBase (const std::u16string::value_type *src, size_t length=0) | |
CefStringBase (const char_type *src, size_t src_len, bool copy) | |
Create a new string from an existing character array. More... | |
CefStringBase (const struct_type *src) | |
Create a new string referencing an existing string structure without taking ownership. More... | |
~CefStringBase () | |
const char_type * | c_str () const |
The following methods are named for compatibility with the standard library string template types. More... | |
size_t | length () const |
Return the length of the string data. More... | |
size_t | size () const |
Return the length of the string data. More... | |
bool | empty () const |
Returns true if the string is empty. More... | |
int | compare (const CefStringBase &str) const |
Compare this string to the specified string. More... | |
void | clear () |
Clear the string data. More... | |
void | swap (CefStringBase &str) |
Swap this string's contents with the specified string. More... | |
bool | IsOwner () const |
Returns true if this class owns the underlying string structure. More... | |
const struct_type * | GetStruct () const |
Returns a read-only pointer to the underlying string structure. More... | |
struct_type * | GetWritableStruct () |
Returns a writable pointer to the underlying string structure. More... | |
void | ClearAndFree () |
Clear the state of this class. More... | |
void | Attach (struct_type *str, bool owner) |
Attach to the specified string structure. More... | |
void | AttachToUserFree (userfree_struct_type str) |
Take ownership of the specified userfree structure's string data. More... | |
void | Detach () |
Detach from the underlying string structure. More... | |
userfree_struct_type | DetachToUserFree () |
Create a userfree structure and give it ownership of this class' string data. More... | |
bool | FromString (const char_type *src, size_t src_len, bool copy) |
Set this string's data to the specified character array. More... | |
bool | FromASCII (const char *str) |
Set this string's data from an existing ASCII string. More... | |
std::string | ToString () const |
Return this string's data as a std::string. More... | |
bool | FromString (const std::string &str) |
Set this string's data from an existing std::string. More... | |
bool | FromString (const std::string::value_type *data, size_t length=0) |
Set this string's data from existing |data| and optional |length|. More... | |
std::wstring | ToWString () const |
Return this string's data as a std::wstring. More... | |
bool | FromWString (const std::wstring &str) |
Set this string's data from an existing std::wstring. More... | |
bool | FromWString (const std::wstring::value_type *data, size_t length=0) |
Set this string's data from existing |data| and optional |length|. More... | |
std::u16string | ToString16 () const |
Return this string's data as a string16. More... | |
bool | FromString16 (const std::u16string &str) |
Set this string's data from an existing string16. More... | |
bool | FromString16 (const std::u16string::value_type *data, size_t length=0) |
Set this string's data from existing |data| and optional |length|. More... | |
bool | operator< (const CefStringBase &str) const |
Comparison operator overloads. More... | |
bool | operator<= (const CefStringBase &str) const |
bool | operator> (const CefStringBase &str) const |
bool | operator>= (const CefStringBase &str) const |
bool | operator== (const CefStringBase &str) const |
bool | operator!= (const CefStringBase &str) const |
CefStringBase & | operator= (const CefStringBase &str) |
Assignment operator overloads. More... | |
operator std::string () const | |
CefStringBase & | operator= (const std::string &str) |
CefStringBase & | operator= (const std::string::value_type *str) |
operator std::wstring () const | |
CefStringBase & | operator= (const std::wstring &str) |
CefStringBase & | operator= (const std::wstring::value_type *str) |
operator std::u16string () const | |
CefStringBase & | operator= (const std::u16string &str) |
CefStringBase & | operator= (const std::u16string::value_type *str) |
CEF string classes can convert between all supported string types.
For example, the CefStringWide class uses wchar_t as the underlying character type and provides two approaches for converting data to/from a UTF8 string (std::string).
CefStringWide aCefString; std::string aUTF8String; aCefString = aUTF8String; // Assign std::string to CefStringWide aUTF8String = aCefString; // Assign CefStringWide to std::string
CefStringWide aCefString; std::string aUTF8String; aCefString.FromString(aUTF8String); // Assign std::string to CefStringWide aUTF8String = aCefString.ToString(); // Assign CefStringWide to std::string
Conversion will only occur if the assigned value is a different string type. Assigning a std::string to a CefStringUTF8, for example, will copy the data without performing a conversion.
CEF string classes are safe for reading from multiple threads but not for modification. It is the user's responsibility to provide synchronization if modifying CEF strings from multiple threads.
typedef traits::char_type CefStringBase< traits >::char_type |
typedef traits::struct_type CefStringBase< traits >::struct_type |
typedef traits::userfree_struct_type CefStringBase< traits >::userfree_struct_type |
|
inline |
Default constructor.
|
inline |
Create a new string from an existing string.
Data will always be copied.
|
inline |
Create a new string from an existing std::string.
Data will be always copied. Translation will occur if necessary based on the underlying string type.
|
inline |
|
inline |
Create a new string from an existing std::wstring.
Data will be always copied. Translation will occur if necessary based on the underlying string type.
|
inline |
|
inline |
Create a new string from an existing string16.
Data will be always copied. Translation will occur if necessary based on the underlying string type.
|
inline |
|
inline |
Create a new string from an existing character array.
If |copy| is true this class will copy the data. Otherwise, this class will reference the existing data. Referenced data must exist for the lifetime of this class and will not be freed by this class.
|
inline |
Create a new string referencing an existing string structure without taking ownership.
Referenced structures must exist for the lifetime of this class and will not be freed by this class.
|
inline |
|
inline |
Attach to the specified string structure.
If |owner| is true this class will take ownership of the structure.
|
inline |
Take ownership of the specified userfree structure's string data.
The userfree structure itself will be freed. Only use this method with userfree structures.
Free the |str| structure but not the data.
|
inline |
The following methods are named for compatibility with the standard library string template types.
Return a read-only pointer to the string data.
|
inline |
Clear the string data.
|
inline |
Clear the state of this class.
The underlying string structure and data will be freed if this class owns the structure.
|
inline |
Compare this string to the specified string.
|
inline |
Detach from the underlying string structure.
To avoid memory leaks only use this method if you already hold a pointer to the underlying string structure.
|
inline |
Create a userfree structure and give it ownership of this class' string data.
This class will be disassociated from the data. May return NULL if this string class currently contains no data.
|
inline |
Returns true if the string is empty.
|
inline |
Set this string's data from an existing ASCII string.
Data will be always copied. Translation will occur if necessary based on the underlying string type.
|
inline |
Set this string's data to the specified character array.
If |copy| is true this class will copy the data. Otherwise, this class will reference the existing data. Referenced data must exist for the lifetime of this class and will not be freed by this class.
|
inline |
Set this string's data from an existing std::string.
Data will be always copied. Translation will occur if necessary based on the underlying string type.
|
inline |
Set this string's data from existing |data| and optional |length|.
Data will be always copied. Translation will occur if necessary based on the underlying string type.
|
inline |
Set this string's data from an existing string16.
Data will be always copied. Translation will occur if necessary based on the underlying string type.
|
inline |
Set this string's data from existing |data| and optional |length|.
Data will be always copied. Translation will occur if necessary based on the underlying string type.
|
inline |
Set this string's data from an existing std::wstring.
Data will be always copied. Translation will occur if necessary based on the underlying string type.
|
inline |
Set this string's data from existing |data| and optional |length|.
Data will be always copied. Translation will occur if necessary based on the underlying string type.
|
inline |
Returns a read-only pointer to the underlying string structure.
May return NULL if no structure is currently allocated.
|
inline |
Returns a writable pointer to the underlying string structure.
Will never return NULL.
|
inline |
Returns true if this class owns the underlying string structure.
|
inline |
Return the length of the string data.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Comparison operator overloads.
|
inline |
|
inline |
Assignment operator overloads.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Return the length of the string data.
|
inline |
Swap this string's contents with the specified string.
|
inline |
Return this string's data as a std::string.
Translation will occur if necessary based on the underlying string type.
|
inline |
Return this string's data as a string16.
Translation will occur if necessary based on the underlying string type.
|
inline |
Return this string's data as a std::wstring.
Translation will occur if necessary based on the underlying string type.