ome-common
5.5.0
|
Xerces string wrapper. More...
#include <ome/common/xml/String.h>
Public Member Functions | |
String (const XMLCh *str) | |
Construct a String from an XMLCh * string. More... | |
String (const char *str) | |
Construct a String from a NUL-terminated string. More... | |
String (std::string const &str) | |
Construct a String from a std::string. More... | |
~String () | |
Destructor. More... | |
operator const XMLCh * () const | |
Cast String to XMLCh *. More... | |
operator::std::string () const | |
Cast String to a std::string. More... | |
inline ::std::string | str () const |
Get the String content as a std::string. More... | |
bool | operator== (const char *rhs) |
Compare a String for equality with a C string. More... | |
bool | operator== (const std::string &rhs) |
Compare a String for equality with a std::string. More... | |
bool | operator== (const String &rhs) |
Compare a String for equality with a String. More... | |
bool | operator!= (const char *rhs) |
Compare a String for inequality with a C string. More... | |
bool | operator!= (const std::string &rhs) |
Compare a String for inequality with a std::string. More... | |
bool | operator!= (const String &rhs) |
Compare a String for inequality with a String. More... | |
Static Public Member Functions | |
static char * | transcode (const XMLCh *str) |
Transcode UTF-16 string to UTF-8 string. More... | |
static XMLCh * | transcode (const char *str) |
Transcode UTF-8 string to UTF-16 string. More... | |
Private Attributes | |
char * | narrow |
The char * string representation. | |
XMLCh * | wide |
The XMLCh * string representation. | |
Xerces string wrapper.
Xerces uses UTF-16 internally, which is incompatible with the standard library string and stream classes. This class interconverts between std::string and XMLCh *, as well as managing the memory of XMLCh * objects. All Xerces functions and class methods which take XMLCh * inputs may be transparently called with instances of this class, and likewise functions and methods returning XMLCh * may directly construct instances of this class using the return value.
This class does have an overhead of maintaining two copies of the string (char * and XMLCh *), as well as the cost of transcoding between the two forms upon construction.
Assignment of std::string or XMLCh * is not supported. This class is only intended to transiently transcode between the two types and manage the memory for this.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Compare a String for inequality with a C string.
rhs | the string to compare. |
true
if not equal, false
otherwise.
|
inline |
Compare a String for inequality with a std::string.
rhs | the string to compare. |
true
if not equal, false
otherwise.
|
inline |
Compare a String for inequality with a String.
rhs | the string to compare. |
true
if not equal, false
otherwise. References str(), and transcode().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Get the String content as a std::string.
References narrow.
Referenced by operator!=(), and ome::common::xml::operator<<().
|
static |
Transcode UTF-16 string to UTF-8 string.
str | a UTF-16 string. |
Referenced by operator!=().
|
static |
Transcode UTF-8 string to UTF-16 string.
str | a UTF-8 string. |