Jive reference manual
|
Converts a String object to a null-terminated character array. More...
#include <jem/base/CString.h>
Public Member Functions | |
CString () | |
Creates an empty CString object. More... | |
CString (const String &str) | |
Creates a CString from a String object. More... | |
CString (const CString &rhs) | |
Copy constructor. More... | |
~CString () | |
Deallocates resources. More... | |
CString & | operator= (const CString &rhs) |
Copies another CString object. More... | |
operator const char * () const | |
Conversion operator. More... | |
const char * | addr () const |
Returns the character array encapsulated by this object. More... | |
Related Functions | |
(Note that these are not member functions.) | |
CString | makeCString (const String &str) |
Converts a String object to a CString object. More... | |
The CString
class helps you convert String
objects to null-terminated character arrays that can be passed to standard C/C++ functions. CString
objects are normally created by calling the non-member function makeCString()
. Here is a typical example:
A CString
object is basically a simple wrapper around a dynamically allocated null-terminated character array. Although multiple CString
objects may point to the same array, only one of these objects is the owner of the array. When the owner is destroyed it will deallocate the character array. All other CString
objects pointing to the same character array then become invalid and should no longer be used.
String
, makeCString()
jem::CString::CString | ( | ) |
|
explicit |
jem::CString::CString | ( | const CString & | rhs | ) |
jem::CString::~CString | ( | ) |
If this object is the owner of its character array, it will delete the character array. All other CString
objects pointing to the same character array then become invalid.
Copies the character array pointed to by the rhs object to this object. Ownership of the character array is passed from the rhs object to this object.
If this object is the owner of its current character array, it will delete that array.
rhs | - the CString object to be copied. |
*this
this->addr() == rhs.addr()
jem::CString::operator const char * | ( | ) | const |
const char* jem::CString::addr | ( | ) | const |
Returns a pointer to the null-terminated character array encapsulated by this CString
object. The pointer is valid as long as the array is not deallocated.