VTK
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
vtkUnicodeString Class Reference

String class that stores Unicode text. More...

#include <vtkUnicodeString.h>

Classes

class  const_iterator
 

Public Types

typedef vtkUnicodeStringValueType value_type
 
typedef std::string::size_type size_type
 

Public Member Functions

 vtkUnicodeString ()
 Constructs an empty string. More...
 
 vtkUnicodeString (const vtkUnicodeString &)
 Makes a deep-copy of another sequence. More...
 
 vtkUnicodeString (size_type count, value_type character)
 Constructs a sequence of repeated characters. More...
 
 vtkUnicodeString (const_iterator begin, const_iterator end)
 Constructs a string from a sequence of Unicode characters. More...
 
vtkUnicodeStringoperator= (const vtkUnicodeString &)
 Replaces the current sequence with a deep copy of another. More...
 
const_iterator begin () const
 Returns a forward iterator that points at the first element of the sequence (or just beyond the end of an empty sequence). More...
 
const_iterator end () const
 Returns a forward iterator that points just beyond the end of the sequence. More...
 
value_type at (size_type offset) const
 Returns the Unicode character at the given character offset within the sequence, or throws std::out_of_range if the offset is invalid. More...
 
value_type operator[] (size_type offset) const
 Returns the Unicode character at the given character offset within the sequence. More...
 
const char * utf8_str () const
 Returns the sequence as a null-terminated sequence of UTF-8 encoded characters. More...
 
void utf8_str (std::string &result) const
 Inserts the sequence into the supplied storage as a collection of UTF-8 encoded characters. More...
 
std::vector< vtkTypeUInt16 > utf16_str () const
 Returns the sequence as a collection of UTF-16 encoded characters. More...
 
void utf16_str (std::vector< vtkTypeUInt16 > &result) const
 Inserts the sequence into the supplied storage as a collection of UTF-16 encoded characters. More...
 
size_type byte_count () const
 Returns the number of bytes (not characters) in the sequence. More...
 
size_type character_count () const
 Returns the number of characters (not bytes) in the sequence. More...
 
bool empty () const
 Returns true if the string contains an empty sequence. More...
 
vtkUnicodeStringoperator+= (value_type)
 Append a Unicode character to the end of the sequence. More...
 
vtkUnicodeStringoperator+= (const vtkUnicodeString &rhs)
 Append a Unicode sequence to the end of the current sequence. More...
 
void push_back (value_type)
 Append a Unicode character to the end of the sequence. More...
 
void append (const vtkUnicodeString &value)
 Append Unicode to the current sequence. More...
 
void append (size_type count, value_type character)
 
void append (const_iterator begin, const_iterator end)
 
void assign (const vtkUnicodeString &value)
 Replace the current sequence with another. More...
 
void assign (size_type count, value_type character)
 
void assign (const_iterator begin, const_iterator end)
 
void clear ()
 Resets the string to an empty sequence. More...
 
vtkUnicodeString fold_case () const
 Returns a copy of the current sequence, modified so that differences in case are eliminated. More...
 
int compare (const vtkUnicodeString &) const
 Returns a negative value if the sequence compares less-than the operand sequence, zero if the two sequences compare equal, or a positive value otherwise. More...
 
vtkUnicodeString substr (size_type offset=0, size_type count=npos) const
 Returns a subset of the current sequence that up-to 'count' characters in length, starting at character 'offset'. More...
 
void swap (vtkUnicodeString &)
 Swap the sequences stored by two strings. More...
 

Static Public Member Functions

static bool is_utf8 (const char *)
 Tests a sequence of bytes, returning true iff they are a valid UTF-8 sequence. More...
 
static bool is_utf8 (const std::string &)
 
static vtkUnicodeString from_utf8 (const char *)
 Constructs a string from a null-terminated sequence of UTF-8 encoded characters. More...
 
static vtkUnicodeString from_utf8 (const char *begin, const char *end)
 
static vtkUnicodeString from_utf8 (const std::string &)
 
static vtkUnicodeString from_utf16 (const vtkTypeUInt16 *)
 Constructs a string from a null-terminated sequence of UTF-16 encoded characters. More...
 

Static Public Attributes

static const size_type npos
 The largest representable value of size_type, used as a special-code. More...
 

Detailed Description

String class that stores Unicode text.

vtkUnicodeString provides storage for Unicode text. Conceptually, it acts as a container for a sequence of Unicode characters, providing a public interface similar to basic_string<>. For character-oriented operations, this means reading / writing 32-bit UTF-32 / UCS-4 characters. Internally, characters may be stored using variable-length encodings for efficiency. Explicit conversions to-and-from other encodings are provided, and implicit conversions are deliberately avoided, to avoid confusion.

Note that, because vtkUnicodeString uses variable-length encodings for storage, character-oriented operations will generally provide O(N) access instead of O(1).

The current implementation stores the sequence with UTF-8 encoding, but this choice is subject to change and might become a compile-time or run-time option.

Thanks:
Developed by Timothy M. Shead (tshea.nosp@m.d@sa.nosp@m.ndia..nosp@m.gov) at Sandia National Laboratories.

Definition at line 69 of file vtkUnicodeString.h.

Member Typedef Documentation

◆ value_type

Definition at line 72 of file vtkUnicodeString.h.

◆ size_type

typedef std::string::size_type vtkUnicodeString::size_type

Definition at line 73 of file vtkUnicodeString.h.

Constructor & Destructor Documentation

◆ vtkUnicodeString() [1/4]

vtkUnicodeString::vtkUnicodeString ( )

Constructs an empty string.

◆ vtkUnicodeString() [2/4]

vtkUnicodeString::vtkUnicodeString ( const vtkUnicodeString )

Makes a deep-copy of another sequence.

◆ vtkUnicodeString() [3/4]

vtkUnicodeString::vtkUnicodeString ( size_type  count,
value_type  character 
)

Constructs a sequence of repeated characters.

Note: throws an exception if the character isn't a valid Unicode code point.

◆ vtkUnicodeString() [4/4]

vtkUnicodeString::vtkUnicodeString ( const_iterator  begin,
const_iterator  end 
)

Constructs a string from a sequence of Unicode characters.

Member Function Documentation

◆ is_utf8() [1/2]

static bool vtkUnicodeString::is_utf8 ( const char *  )
static

Tests a sequence of bytes, returning true iff they are a valid UTF-8 sequence.

◆ is_utf8() [2/2]

static bool vtkUnicodeString::is_utf8 ( const std::string &  )
static

◆ from_utf8() [1/3]

static vtkUnicodeString vtkUnicodeString::from_utf8 ( const char *  )
static

Constructs a string from a null-terminated sequence of UTF-8 encoded characters.

◆ from_utf8() [2/3]

static vtkUnicodeString vtkUnicodeString::from_utf8 ( const char *  begin,
const char *  end 
)
static

◆ from_utf8() [3/3]

static vtkUnicodeString vtkUnicodeString::from_utf8 ( const std::string &  )
static

◆ from_utf16()

static vtkUnicodeString vtkUnicodeString::from_utf16 ( const vtkTypeUInt16 *  )
static

Constructs a string from a null-terminated sequence of UTF-16 encoded characters.

◆ operator=()

vtkUnicodeString& vtkUnicodeString::operator= ( const vtkUnicodeString )

Replaces the current sequence with a deep copy of another.

◆ begin()

const_iterator vtkUnicodeString::begin ( ) const

Returns a forward iterator that points at the first element of the sequence (or just beyond the end of an empty sequence).

◆ end()

const_iterator vtkUnicodeString::end ( ) const

Returns a forward iterator that points just beyond the end of the sequence.

◆ at()

value_type vtkUnicodeString::at ( size_type  offset) const

Returns the Unicode character at the given character offset within the sequence, or throws std::out_of_range if the offset is invalid.

◆ operator[]()

value_type vtkUnicodeString::operator[] ( size_type  offset) const

Returns the Unicode character at the given character offset within the sequence.

Behavior is undefined if the position is invalid.

◆ utf8_str() [1/2]

const char* vtkUnicodeString::utf8_str ( ) const

Returns the sequence as a null-terminated sequence of UTF-8 encoded characters.

◆ utf8_str() [2/2]

void vtkUnicodeString::utf8_str ( std::string &  result) const

Inserts the sequence into the supplied storage as a collection of UTF-8 encoded characters.

◆ utf16_str() [1/2]

std::vector<vtkTypeUInt16> vtkUnicodeString::utf16_str ( ) const

Returns the sequence as a collection of UTF-16 encoded characters.

◆ utf16_str() [2/2]

void vtkUnicodeString::utf16_str ( std::vector< vtkTypeUInt16 > &  result) const

Inserts the sequence into the supplied storage as a collection of UTF-16 encoded characters.

◆ byte_count()

size_type vtkUnicodeString::byte_count ( ) const

Returns the number of bytes (not characters) in the sequence.

◆ character_count()

size_type vtkUnicodeString::character_count ( ) const

Returns the number of characters (not bytes) in the sequence.

◆ empty()

bool vtkUnicodeString::empty ( ) const

Returns true if the string contains an empty sequence.

◆ operator+=() [1/2]

vtkUnicodeString& vtkUnicodeString::operator+= ( value_type  )

Append a Unicode character to the end of the sequence.

◆ operator+=() [2/2]

vtkUnicodeString& vtkUnicodeString::operator+= ( const vtkUnicodeString rhs)

Append a Unicode sequence to the end of the current sequence.

◆ push_back()

void vtkUnicodeString::push_back ( value_type  )

Append a Unicode character to the end of the sequence.

◆ append() [1/3]

void vtkUnicodeString::append ( const vtkUnicodeString value)

Append Unicode to the current sequence.

◆ append() [2/3]

void vtkUnicodeString::append ( size_type  count,
value_type  character 
)

◆ append() [3/3]

void vtkUnicodeString::append ( const_iterator  begin,
const_iterator  end 
)

◆ assign() [1/3]

void vtkUnicodeString::assign ( const vtkUnicodeString value)

Replace the current sequence with another.

◆ assign() [2/3]

void vtkUnicodeString::assign ( size_type  count,
value_type  character 
)

◆ assign() [3/3]

void vtkUnicodeString::assign ( const_iterator  begin,
const_iterator  end 
)

◆ clear()

void vtkUnicodeString::clear ( )

Resets the string to an empty sequence.

◆ fold_case()

vtkUnicodeString vtkUnicodeString::fold_case ( ) const

Returns a copy of the current sequence, modified so that differences in case are eliminated.

Thus, you can run fold_case() on two strings and then comparse them to obtain a case-insensitive comparison. Note that the string returned by fold_case() may be larger than the original source sequence,

See http://www.unicode.org/Public/UNIDATA/CaseFolding.txt for details.

◆ compare()

int vtkUnicodeString::compare ( const vtkUnicodeString ) const

Returns a negative value if the sequence compares less-than the operand sequence, zero if the two sequences compare equal, or a positive value otherwise.

Note that the definition of "less-than" is undefined, so you should use some other method if you wish to establish a specific ordering (such as alphabetical).

◆ substr()

vtkUnicodeString vtkUnicodeString::substr ( size_type  offset = 0,
size_type  count = npos 
) const

Returns a subset of the current sequence that up-to 'count' characters in length, starting at character 'offset'.

◆ swap()

void vtkUnicodeString::swap ( vtkUnicodeString )

Swap the sequences stored by two strings.

Member Data Documentation

◆ npos

const size_type vtkUnicodeString::npos
static

The largest representable value of size_type, used as a special-code.

Definition at line 202 of file vtkUnicodeString.h.


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