Overview   Project   Class   Tree   Index 
CEF3 C++ API Docs - Version 75.1.4+g4210896+chromium-75.0.3770.100
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD

(default)
Class CefStringBase

   in cef_string_wrappers.h

template < class traits > class CefStringBase

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).

1. Implicit conversion using the assignment operator overload.

  CefStringWide aCefString;
  std::string aUTF8String;
  aCefString = aUTF8String; // Assign std::string to CefStringWide
  aUTF8String = aCefString; // Assign CefStringWide to std::string
2. Explicit conversion using the FromString/ToString methods.
  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.


Inner Classes, Typedefs, and Enums
typedef CefStringBase::char_type
          
CefStringBase::std
          
typedef CefStringBase::struct_type
          
typedef CefStringBase::userfree_struct_type
          
 
Constructor Summary
CefStringBase( const std::wstring& src )
          Create a new string from an existing std::wstring.
CefStringBase( const CefStringBase& str )
          Create a new string from an existing string.
CefStringBase( const std::string& src )
          Create a new string from an existing std::string.
CefStringBase( const char* src )
          
CefStringBase()
          Default constructor.
CefStringBase( const wchar_t* src )
          
CefStringBase( const CefStringBase::char_type* src, size_t src_len, bool copy )
          Create a new string from an existing character array.
CefStringBase( const CefStringBase::struct_type* src )
          Create a new string referencing an existing string structure without taking ownership.
virtual ~CefStringBase()
          
 
Method Summary
 void Attach( CefStringBase::struct_type* str, bool owner )
          Attach to the specified string structure.
 void AttachToUserFree( CefStringBase::userfree_struct_type str )
          Take ownership of the specified userfree structure's string data.
 const CefStringBase::char_type* c_str() const
          Return a read-only pointer to the string data.
 void clear()
          Clear the string data.
 void ClearAndFree()
          Clear the state of this class.
 int compare( const CefStringBase& str ) const
          Compare this string to the specified string.
 void Detach()
          Detach from the underlying string structure.
 CefStringBase::userfree_struct_type DetachToUserFree()
          Create a userfree structure and give it ownership of this class' string data.
 bool empty() const
          Returns true if the string is empty.
 bool FromASCII( const char* str )
          Set this string's data from an existing ASCII string.
 bool FromString( const CefStringBase::char_type* src, size_t src_len, bool copy )
          Set this string's data to the specified character array.
 bool FromString( const std::string& str )
          Set this string's data from an existing std::string.
 bool FromString16( const base::string16& str )
          Set this string's data from an existing string16.
 bool FromWString( const std::wstring& str )
          Set this string's data from an existing std::wstring.
 const CefStringBase::struct_type* GetStruct() const
          Returns a read-only pointer to the underlying string structure.
 CefStringBase::struct_type* GetWritableStruct()
          Returns a writable pointer to the underlying string structure.
 bool IsOwner() const
          Returns true if this class owns the underlying string structure.
 size_t length() const
          Return the length of the string data.
 bool operator!=( const CefStringBase& str ) const
          
 bool operator<( const CefStringBase& str ) const
          Comparison operator overloads.
 bool operator<=( const CefStringBase& str ) const
          
 CefStringBase& operator=( const char* str )
          
 CefStringBase& operator=( const wchar_t* str )
          
 CefStringBase& operator=( const std::wstring& str )
          
 CefStringBase& operator=( const std::string& str )
          
 CefStringBase& operator=( const CefStringBase& str )
          Assignment operator overloads.
 bool operator==( const CefStringBase& str ) const
          
 bool operator>( const CefStringBase& str ) const
          
 bool operator>=( const CefStringBase& str ) const
          
 inline size_t size() const
          Return the length of the string data.
 void swap( CefStringBase& str )
          Swap this string's contents with the specified string.
 std::string ToString() const
          Return this string's data as a std::string.
 base::string16 ToString16() const
          Return this string's data as a string16.
 std::wstring ToWString() const
          Return this string's data as a std::wstring.
 

Constructor Detail

CefStringBase

public CefStringBase( const std::wstring& src );
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.

CefStringBase

public CefStringBase( const CefStringBase& str );
Create a new string from an existing string. Data will always be copied.

CefStringBase

public CefStringBase( const std::string& src );
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.

CefStringBase

public CefStringBase( const char* src );

CefStringBase

public CefStringBase();
Default constructor.

CefStringBase

public CefStringBase( const wchar_t* src );

CefStringBase

public CefStringBase( const CefStringBase::char_type* src, size_t src_len, bool copy );
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.

CefStringBase

public CefStringBase( const CefStringBase::struct_type* src );
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.

~CefStringBase

public virtual ~CefStringBase();


Method Detail

Attach

public void Attach( CefStringBase::struct_type* str, bool owner );
Attach to the specified string structure. If |owner| is true this class will take ownership of the structure.

AttachToUserFree

public void AttachToUserFree( CefStringBase::userfree_struct_type str );
Take ownership of the specified userfree structure's string data. The userfree structure itself will be freed. Only use this method with userfree structures.

c_str

public const CefStringBase::char_type* c_str() const;
Return a read-only pointer to the string data.

clear

public void clear();
Clear the string data.

ClearAndFree

public void ClearAndFree();
Clear the state of this class. The underlying string structure and data will be freed if this class owns the structure.

compare

public int compare( const CefStringBase& str ) const;
Compare this string to the specified string.

Detach

public void Detach();
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.

DetachToUserFree

public CefStringBase::userfree_struct_type DetachToUserFree();
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.

empty

public bool empty() const;
Returns true if the string is empty.

FromASCII

public bool FromASCII( const char* str );
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.

FromString

public bool FromString( const CefStringBase::char_type* src, size_t src_len, bool copy );
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.

FromString

public bool FromString( const std::string& str );
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.

FromString16

public bool FromString16( const base::string16& str );
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.

FromWString

public bool FromWString( const std::wstring& str );
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.

GetStruct

public const CefStringBase::struct_type* GetStruct() const;
Returns a read-only pointer to the underlying string structure. May return NULL if no structure is currently allocated.

GetWritableStruct

public CefStringBase::struct_type* GetWritableStruct();
Returns a writable pointer to the underlying string structure. Will never return NULL.

IsOwner

public bool IsOwner() const;
Returns true if this class owns the underlying string structure.

length

public size_t length() const;
Return the length of the string data.

operator!=

public bool operator!=( const CefStringBase& str ) const;

operator<

public bool operator<( const CefStringBase& str ) const;
Comparison operator overloads.

operator<=

public bool operator<=( const CefStringBase& str ) const;

operator=

public CefStringBase& operator=( const char* str );

operator=

public CefStringBase& operator=( const wchar_t* str );

operator=

public CefStringBase& operator=( const std::wstring& str );

operator=

public CefStringBase& operator=( const std::string& str );

operator=

public CefStringBase& operator=( const CefStringBase& str );
Assignment operator overloads.

operator==

public bool operator==( const CefStringBase& str ) const;

operator>

public bool operator>( const CefStringBase& str ) const;

operator>=

public bool operator>=( const CefStringBase& str ) const;

size

public inline size_t size() const;
Return the length of the string data.

swap

public void swap( CefStringBase& str );
Swap this string's contents with the specified string.

ToString

public std::string ToString() const;
Return this string's data as a std::string. Translation will occur if necessary based on the underlying string type.

ToString16

public base::string16 ToString16() const;
Return this string's data as a string16. Translation will occur if necessary based on the underlying string type.

ToWString

public std::wstring ToWString() const;
Return this string's data as a std::wstring. Translation will occur if necessary based on the underlying string type.

 Overview   Project   Class   Tree   Index 
CEF3 C++ API Docs - Version 75.1.4+g4210896+chromium-75.0.3770.100
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD

Chromium Embedded Framework (CEF) Copyright © 2016 Marshall A. Greenblatt