ome-common 5.3.2

Public Member Functions | Static 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...

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

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

## § String() [1/3]

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

  str | an XMLCh *string.

References narrow, and wide.

## § String() [2/3]

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

  str | a char * NUL-terminated string.

References narrow, and wide.

## § String() [3/3]

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

  str | a std::string.

References narrow, and wide.

## § ~String()

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

Destructor.

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

References narrow, and wide.

## Member Function Documentation

## § operator const XMLCh *()

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

Cast String to XMLCh *.

Returns
  a NUL-terminated XMLCh * string.

References wide.

## § operator!=() [1/3]

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

Compare a String for inequality with a C string.

Parameters

  rhs | the string to compare.

Returns
  `true` if not equal, `false` otherwise.

## § operator!=() [2/3]

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

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

Parameters

  rhs | the string to compare.

Returns
  `true` if not equal, `false` otherwise.

## § operator!=() [3/3]

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

Compare a String for inequality with a String.

Parameters

  rhs | the string to compare.

Returns
  `true` if not equal, `false` otherwise.

References str(), and transcode().

## § operator::std::string()

ome::common::xml::String::operator::std::string | ( |  | ) | const
| inline

Cast String to a std::string.

Returns
  a std::string.

References narrow.

## § operator==() [1/3]

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

Compare a String for equality with a C string.

Parameters

  rhs | the string to compare.

Returns
  `true` if equal, `false` otherwise.

References narrow.

## § operator==() [2/3]

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

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

Parameters

  rhs | the string to compare.

Returns
  `true` if equal, `false` otherwise.

References narrow.

## § operator==() [3/3]

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

Compare a String for equality with a String.

Parameters

  rhs | the string to compare.

Returns
  `true` if equal, `false` otherwise.

References narrow.

## § str()

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.

Referenced by operator!=(), and ome::common::xml::operator<<().

Here is the caller graph for this function:

## § transcode() [1/2]

char * ome::common::xml::String::transcode | ( | const XMLCh * | str | ) |
| static

Transcode UTF-16 string to UTF-8 string.

Parameters

  str | a UTF-16 string.

Returns
  a UTF-8 string (must be freed by caller with xercesc::XMLString::release).

Referenced by operator!=().

Here is the caller graph for this function:

## § transcode() [2/2]

XMLCh * ome::common::xml::String::transcode | ( | const char * | str | ) |
| static

Transcode UTF-8 string to UTF-16 string.

Parameters

  str | a UTF-8 string.

Returns
  a UTF-16 string (must be freed by caller with xercesc::XMLString::release).

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

- ome/common/xml/String.h
- ome/common/xml/String.cpp