VTK  9.1.0
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
47#ifndef vtkUnicodeString_h
48#define vtkUnicodeString_h
49
50#include "vtkCommonCoreModule.h" // For export macro
51#include "vtkDeprecation.h"
52#include "vtkSystemIncludes.h"
53#include <string>
54#include <vector>
55
57
58typedef vtkTypeUInt32 vtkUnicodeStringValueType;
59
60//
61// The following should be eventually placed in vtkSetGet.h
62//
63
64// This is same as extra extended template macro with an
65// additional case for VTK_UNICODE_STRING
66#define vtkSuperExtraExtendedTemplateMacro(call) \
67 vtkExtraExtendedTemplateMacro(call); \
68 vtkTemplateMacroCase(VTK_UNICODE_STRING, vtkUnicodeString, call)
69
71
72VTKCOMMONCORE_EXPORT bool operator==(const vtkUnicodeString& lhs, const vtkUnicodeString& rhs);
73VTKCOMMONCORE_EXPORT bool operator!=(const vtkUnicodeString& lhs, const vtkUnicodeString& rhs);
74VTKCOMMONCORE_EXPORT bool operator<(const vtkUnicodeString& lhs, const vtkUnicodeString& rhs);
75VTKCOMMONCORE_EXPORT bool operator<=(const vtkUnicodeString& lhs, const vtkUnicodeString& rhs);
76VTKCOMMONCORE_EXPORT bool operator>=(const vtkUnicodeString& lhs, const vtkUnicodeString& rhs);
77VTKCOMMONCORE_EXPORT bool operator>(const vtkUnicodeString& lhs, const vtkUnicodeString& rhs);
78
79class VTKCOMMONCORE_EXPORT vtkUnicodeString
80{
81public:
83 typedef std::string::size_type size_type;
84
85 class VTKCOMMONCORE_EXPORT const_iterator
86 {
87 public:
88 typedef std::bidirectional_iterator_tag iterator_category;
90 typedef std::string::difference_type difference_type;
93
95
97 bool operator==(const const_iterator&) const;
98 bool operator!=(const const_iterator&) const;
103
104 private:
105 const_iterator(std::string::const_iterator);
106 friend class vtkUnicodeString;
107 std::string::const_iterator Position;
108 };
109
113 VTK_DEPRECATED_IN_9_1_0("Use std::string instead.")
118 VTK_DEPRECATED_IN_9_1_0("Use std::string instead.")
124 VTK_DEPRECATED_IN_9_1_0("Use std::string instead.")
129 VTK_DEPRECATED_IN_9_1_0("Use std::string instead.")
131
133
136 VTK_DEPRECATED_IN_9_1_0("Use std::string instead.")
137 static bool is_utf8(const char*);
138 VTK_DEPRECATED_IN_9_1_0("Use std::string instead.")
139 static bool is_utf8(const std::string&);
141
143
146 VTK_DEPRECATED_IN_9_1_0("Use std::string instead.")
147 static vtkUnicodeString from_utf8(const char*);
148 // Constructs a string from a half-open sequence of UTF-8 encoded characters.
149 VTK_DEPRECATED_IN_9_1_0("Use std::string instead.")
150 static vtkUnicodeString from_utf8(const char* begin, const char* end);
151 // Constructs a string from a sequence of UTF-8 encoded characters.
152 VTK_DEPRECATED_IN_9_1_0("Use std::string instead.")
153 static vtkUnicodeString from_utf8(const std::string&);
155
158 VTK_DEPRECATED_IN_9_1_0("Use std::string instead.")
159 static vtkUnicodeString from_utf16(const vtkTypeUInt16*);
160
165
170 const_iterator begin() const;
174 const_iterator end() const;
175
180 value_type at(size_type offset) const;
185 value_type operator[](size_type offset) const;
186
190 const char* utf8_str() const;
195 void utf8_str(std::string& result) const;
199 std::vector<vtkTypeUInt16> utf16_str() const;
204 void utf16_str(std::vector<vtkTypeUInt16>& result) const;
205
209 size_type byte_count() const;
213 size_type character_count() const;
217 bool empty() const;
218
222 static const size_type npos;
223
231 vtkUnicodeString& operator+=(const vtkUnicodeString& rhs);
232
236 void push_back(value_type);
237
239
242 void append(const vtkUnicodeString& value);
243 void append(size_type count, value_type character);
244 void append(const_iterator begin, const_iterator end);
246
248
251 void assign(const vtkUnicodeString& value);
252 void assign(size_type count, value_type character);
253 void assign(const_iterator begin, const_iterator end);
255
259 void clear();
260
269 vtkUnicodeString fold_case() const;
270
278 int compare(const vtkUnicodeString&) const;
279
284 vtkUnicodeString substr(size_type offset = 0, size_type count = npos) const;
285
289 void swap(vtkUnicodeString&);
290
291private:
292 std::string Storage;
293 class back_insert_iterator;
294};
295
296#endif
297
298// VTK-HeaderTest-Exclude: vtkUnicodeString.h
const_iterator operator++(int)
std::string::difference_type difference_type
std::bidirectional_iterator_tag iterator_category
const_iterator operator--(int)
bool operator==(const const_iterator &) const
bool operator!=(const const_iterator &) const
vtkUnicodeStringValueType value_type
String class that stores Unicode text.
vtkUnicodeStringValueType value_type
std::string::size_type size_type
#define VTK_DEPRECATED_IN_9_1_0(reason)
VTKCOMMONCORE_EXPORT bool operator!=(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
vtkTypeUInt32 vtkUnicodeStringValueType
VTKCOMMONCORE_EXPORT bool operator==(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
VTKCOMMONCORE_EXPORT bool operator>(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
VTKCOMMONCORE_EXPORT bool operator<(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
VTKCOMMONCORE_EXPORT bool operator>=(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
VTKCOMMONCORE_EXPORT bool operator<=(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)