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 
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;
84  typedef value_type& reference;
85 
87 
88  value_type operator*() const;
89  bool operator==(const const_iterator&) const;
90  bool operator!=(const const_iterator&) const;
91  const_iterator& operator++();
92  const_iterator operator++(int);
93  const_iterator& operator--();
94  const_iterator operator--(int);
95 
96  private:
97  const_iterator(std::string::const_iterator);
98  friend class vtkUnicodeString;
99  std::string::const_iterator Position;
100  };
101 
108  vtkUnicodeString(size_type count, value_type character);
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.
126  static vtkUnicodeString from_utf8(const std::string&);
128 
130  static vtkUnicodeString from_utf16(const vtkTypeUInt16*);
131 
134 
137  const_iterator begin() const;
140  const_iterator end() const;
141 
144  value_type at(size_type offset) const;
147  value_type operator[](size_type offset) const;
148 
151  const char* utf8_str() const;
154  void utf8_str(std::string& result) const;
156  std::vector<vtkTypeUInt16> utf16_str() const;
159  void utf16_str(std::vector<vtkTypeUInt16>& result) const;
160 
162  size_type byte_count() const;
164  size_type character_count() const;
166  bool empty() const;
167 
169  static const size_type npos;
170 
172  vtkUnicodeString& operator+=(value_type);
175 
177  void push_back(value_type);
178 
180 
181  void append(const vtkUnicodeString& value);
182  void append(size_type count, value_type character);
185 
187 
188  void assign(const vtkUnicodeString& value);
189  void assign(size_type count, value_type character);
192 
194  void clear();
195 
202  vtkUnicodeString fold_case() const;
203 
209  int compare(const vtkUnicodeString&) const;
210 
213  vtkUnicodeString substr(size_type offset = 0, size_type count = npos) const;
214 
216  void swap(vtkUnicodeString&);
217 
218 private:
219  std::string Storage;
220  class back_insert_iterator;
221 };
222 
229 
230 #endif
231 
232 // VTK-HeaderTest-Exclude: vtkUnicodeString.h
static vtkUnicodeString from_utf16(const vtkTypeUInt16 *)
VTKCOMMONCORE_EXPORT bool operator>=(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
static bool is_utf8(const char *)
vtkUnicodeString & operator=(const vtkUnicodeString &)
vtkUnicodeString fold_case() const
value_type operator[](size_type offset) const
VTKCOMMONCORE_EXPORT bool operator<=(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
void append(const vtkUnicodeString &value)
void push_back(value_type)
#define VTKCOMMONCORE_EXPORT
std::string::difference_type difference_type
vtkUnicodeStringValueType value_type
VTKCOMMONCORE_EXPORT bool operator<(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
VTKCOMMONCORE_EXPORT bool operator>(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
size_type byte_count() const
size_type character_count() const
int compare(const vtkUnicodeString &) const
vtkUnicodeString & operator+=(value_type)
static vtkUnicodeString from_utf8(const char *)
const char * utf8_str() const
std::vector< vtkTypeUInt16 > utf16_str() const
void swap(vtkUnicodeString &)
void assign(const vtkUnicodeString &value)
static const size_type npos
std::bidirectional_iterator_tag iterator_category
value_type at(size_type offset) const
const_iterator end() const
VTKCOMMONCORE_EXPORT bool operator!=(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
vtkUnicodeString substr(size_type offset=0, size_type count=npos) const
VTKCOMMONCORE_EXPORT bool operator==(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
vtkVector< A, Size > operator*(const vtkVector< A, Size > &v1, const vtkVector< A, Size > &v2)
bool empty() const
vtkTypeUInt32 vtkUnicodeStringValueType
std::string::size_type size_type
vtkUnicodeStringValueType value_type
String class that stores Unicode text.
const_iterator begin() const