bioformats  5.1.8
Public Member Functions | Private Attributes | List of all members
ome::common::xml::String Class Reference

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

Private Attributes

char * narrow
 The char * string representation.
 
XMLCh * wide
 The XMLCh * string representation.
 

Detailed Description

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.

Constructor & Destructor Documentation

ome::common::xml::String::String ( const XMLCh *  str)
inline

Construct a String from an XMLCh * string.

The string content will be copied; no ownership is taken of the original string. The string will also be transcoded to a NUL-terminated char * string.

Parameters
stran XMLCh *string.

References narrow, and wide.

ome::common::xml::String::String ( const char *  str)
inline

Construct a String from a NUL-terminated string.

The string content will be copied into a NUL-terminated char * string. The string will also be transcoded to an XMLCh * string.

Parameters
stra char * NUL-terminated string.

References narrow, and wide.

ome::common::xml::String::String ( std::string const &  str)
inline

Construct a String from a std::string.

The string content will be copied into a NUL-terminated char * string. The string will also be transcoded to an XMLCh * string.

Parameters
stra std::string.

References narrow, and wide.

ome::common::xml::String::~String ( )
inline

Destructor.

The allocated char * and XMLCh * strings will be freed.

References narrow, and wide.

Member Function Documentation

ome::common::xml::String::operator const XMLCh * ( ) const
inline

Cast String to XMLCh *.

Returns
a NUL-terminated XMLCh * string.

References wide.

bool ome::common::xml::String::operator!= ( const char *  rhs)
inline

Compare a String for inequality with a C string.

Parameters
rhsthe string to compare.
Returns
true if not equal, false otherwise.
bool ome::common::xml::String::operator!= ( const std::string &  rhs)
inline

Compare a String for inequality with a std::string.

Parameters
rhsthe string to compare.
Returns
true if not equal, false otherwise.
bool ome::common::xml::String::operator!= ( const String rhs)
inline

Compare a String for inequality with a String.

Parameters
rhsthe string to compare.
Returns
true if not equal, false otherwise.
ome::common::xml::String::operator::std::string ( ) const
inline

Cast String to a std::string.

Returns
a std::string.

References narrow.

bool ome::common::xml::String::operator== ( const char *  rhs)
inline

Compare a String for equality with a C string.

Parameters
rhsthe string to compare.
Returns
true if equal, false otherwise.

References narrow.

bool ome::common::xml::String::operator== ( const std::string &  rhs)
inline

Compare a String for equality with a std::string.

Parameters
rhsthe string to compare.
Returns
true if equal, false otherwise.

References narrow.

bool ome::common::xml::String::operator== ( const String rhs)
inline

Compare a String for equality with a String.

Parameters
rhsthe string to compare.
Returns
true if equal, false otherwise.

References narrow.

inline ::std::string ome::common::xml::String::str ( ) const
inline

Get the String content as a std::string.

Returns
a std::string containing the String content.

References narrow.


The documentation for this class was generated from the following file: