VTK
vtkUnicodeString.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkUnicodeString.h
5 
6 -------------------------------------------------------------------------
7  Copyright 2008 Sandia Corporation.
8  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9  the U.S. Government retains certain rights in this software.
10 -------------------------------------------------------------------------
11 
12  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
13  All rights reserved.
14  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
15 
16  This software is distributed WITHOUT ANY WARRANTY; without even
17  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18  PURPOSE. See the above copyright notice for more information.
19 
20 =========================================================================*/
21 
49 #ifndef vtkUnicodeString_h
50 #define vtkUnicodeString_h
51 
52 #include "vtkCommonCoreModule.h" // For export macro
53 #include "vtkSystemIncludes.h"
54 #include <string>
55 #include <vector>
56 
57 class vtkUnicodeString;
58 
59 typedef vtkTypeUInt32 vtkUnicodeStringValueType;
60 
61 //
62 // The following should be eventually placed in vtkSetGet.h
63 //
64 
65 // This is same as extra extended template macro with an
66 // additional case for VTK_UNICODE_STRING
67 #define vtkSuperExtraExtendedTemplateMacro(call) \
68  vtkExtraExtendedTemplateMacro(call); \
69  vtkTemplateMacroCase(VTK_UNICODE_STRING, vtkUnicodeString, call)
70 
72 {
73 public:
75  typedef std::string::size_type size_type;
76 
78  {
79  public:
80  typedef std::bidirectional_iterator_tag iterator_category;
82  typedef std::string::difference_type difference_type;
83  typedef value_type* pointer;
85 
87 
89  bool operator==(const const_iterator&) const;
90  bool operator!=(const const_iterator&) const;
95 
96  private:
97  const_iterator(std::string::const_iterator);
98  friend class vtkUnicodeString;
99  std::string::const_iterator Position;
100  };
101 
111 
113 
115  static bool is_utf8(const char*);
116  static bool is_utf8(const std::string&);
118 
120 
122  static vtkUnicodeString from_utf8(const char*);
123  // Constructs a string from a half-open sequence of UTF-8 encoded characters.
124  static vtkUnicodeString from_utf8(const char* begin, const char* end);
125  // Constructs a string from a sequence of UTF-8 encoded characters.
128 
130  static vtkUnicodeString from_utf16(const vtkTypeUInt16*);
131 
134 
141 
148 
151  const char* utf8_str() const;
156  std::vector<vtkTypeUInt16> utf16_str() const;
159  void utf16_str(std::vector<vtkTypeUInt16>& result) const;
160 
166  bool empty() const;
167 
169  static const size_type npos;
170 
175 
178 
180 
182  void append(size_type count, value_type character);
185 
187 
189  void assign(size_type count, value_type character);
192 
194  void clear();
195 
203 
209  int compare(const vtkUnicodeString&) const;
210 
214 
217 
218 private:
219  std::string Storage;
220  class back_insert_iterator;
221 };
222 
229 
230 #endif
231 
232 // VTK-HeaderTest-Exclude: vtkUnicodeString.h
vtkUnicodeString::vtkUnicodeString
vtkUnicodeString(const vtkUnicodeString &)
vtkUnicodeString::operator+=
vtkUnicodeString & operator+=(const vtkUnicodeString &rhs)
vtkUnicodeString::const_iterator::difference_type
std::string::difference_type difference_type
Definition: vtkUnicodeString.h:82
VTKCOMMONCORE_EXPORT
#define VTKCOMMONCORE_EXPORT
Definition: vtkCommonCoreModule.h:15
vtkUnicodeString::from_utf16
static vtkUnicodeString from_utf16(const vtkTypeUInt16 *)
vtkUnicodeString::compare
int compare(const vtkUnicodeString &) const
vtkgl::count
GLuint GLuint GLsizei count
Definition: vtkgl.h:11315
vtkUnicodeString::value_type
vtkUnicodeStringValueType value_type
Definition: vtkUnicodeString.h:74
vtkUnicodeString::vtkUnicodeString
vtkUnicodeString(const_iterator begin, const_iterator end)
vtkUnicodeString::const_iterator::operator--
const_iterator & operator--()
vtkUnicodeString::operator=
vtkUnicodeString & operator=(const vtkUnicodeString &)
vtkUnicodeString::append
void append(const_iterator begin, const_iterator end)
vtkUnicodeString::push_back
void push_back(value_type)
vtkgl::end
GLuint GLuint end
Definition: vtkgl.h:11315
vtkUnicodeString::from_utf8
static vtkUnicodeString from_utf8(const std::string &)
vtkUnicodeString::from_utf8
static vtkUnicodeString from_utf8(const char *begin, const char *end)
vtkUnicodeString::fold_case
vtkUnicodeString fold_case() const
operator<
VTKCOMMONCORE_EXPORT bool operator<(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
vtkUnicodeString::from_utf8
static vtkUnicodeString from_utf8(const char *)
vtkUnicodeString::utf8_str
void utf8_str(std::string &result) const
vtkUnicodeString::character_count
size_type character_count() const
vtkgl::value
GLsizei const GLfloat * value
Definition: vtkgl.h:12021
vtkUnicodeString::swap
void swap(vtkUnicodeString &)
vtkCommonCoreModule.h
vtkUnicodeString::const_iterator::operator++
const_iterator operator++(int)
vtkUnicodeString::const_iterator::const_iterator
const_iterator()
vtkUnicodeString::operator+=
vtkUnicodeString & operator+=(value_type)
vtkUnicodeString::is_utf8
static bool is_utf8(const std::string &)
vtkUnicodeString::substr
vtkUnicodeString substr(size_type offset=0, size_type count=npos) const
vtkUnicodeString::const_iterator::iterator_category
std::bidirectional_iterator_tag iterator_category
Definition: vtkUnicodeString.h:80
vtkUnicodeString
String class that stores Unicode text.
Definition: vtkUnicodeString.h:72
vtkUnicodeString::at
value_type at(size_type offset) const
vtkUnicodeString::end
const_iterator end() const
vtkUnicodeStringValueType
vtkTypeUInt32 vtkUnicodeStringValueType
Definition: vtkUnicodeString.h:57
vtkUnicodeString::utf8_str
const char * utf8_str() const
vtkgl::offset
GLintptr offset
Definition: vtkgl.h:11844
vtkUnicodeString::const_iterator::operator++
const_iterator & operator++()
vtkUnicodeString::npos
static const size_type npos
Definition: vtkUnicodeString.h:169
vtkUnicodeString::utf16_str
std::vector< vtkTypeUInt16 > utf16_str() const
operator==
VTKCOMMONCORE_EXPORT bool operator==(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
vtkUnicodeString::const_iterator::reference
value_type & reference
Definition: vtkUnicodeString.h:84
vtkUnicodeString::assign
void assign(size_type count, value_type character)
vtkUnicodeString::const_iterator::operator==
bool operator==(const const_iterator &) const
vtkUnicodeString::empty
bool empty() const
vtkUnicodeString::const_iterator
Definition: vtkUnicodeString.h:78
vtkgl::result
GLuint64EXT * result
Definition: vtkgl.h:18868
vtkUnicodeString::operator[]
value_type operator[](size_type offset) const
operator>=
VTKCOMMONCORE_EXPORT bool operator>=(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
vtkUnicodeString::assign
void assign(const vtkUnicodeString &value)
vtkUnicodeString::byte_count
size_type byte_count() const
vtkUnicodeString::const_iterator::operator--
const_iterator operator--(int)
operator!=
VTKCOMMONCORE_EXPORT bool operator!=(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
vtkUnicodeString::size_type
std::string::size_type size_type
Definition: vtkUnicodeString.h:75
operator>
VTKCOMMONCORE_EXPORT bool operator>(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
vtkUnicodeString::append
void append(size_type count, value_type character)
vtkUnicodeString::utf16_str
void utf16_str(std::vector< vtkTypeUInt16 > &result) const
vtkUnicodeString::append
void append(const vtkUnicodeString &value)
vtkUnicodeString::vtkUnicodeString
vtkUnicodeString(size_type count, value_type character)
vtkUnicodeString::assign
void assign(const_iterator begin, const_iterator end)
vtkUnicodeString::const_iterator::operator!=
bool operator!=(const const_iterator &) const
operator<=
VTKCOMMONCORE_EXPORT bool operator<=(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
vtkUnicodeString::const_iterator::operator*
value_type operator*() const
vtkgl::string
GLsizei const GLchar ** string
Definition: vtkgl.h:12011
vtkUnicodeString::is_utf8
static bool is_utf8(const char *)
vtkSystemIncludes.h
vtkUnicodeString::begin
const_iterator begin() const
vtkUnicodeString::vtkUnicodeString
vtkUnicodeString()
vtkUnicodeString::const_iterator::pointer
value_type * pointer
Definition: vtkUnicodeString.h:83
vtkUnicodeString::const_iterator::value_type
vtkUnicodeStringValueType value_type
Definition: vtkUnicodeString.h:81
vtkUnicodeString::clear
void clear()