VTK
dox/Common/Core/vtkUnicodeString.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkUnicodeString.h
00005 
00006 -------------------------------------------------------------------------
00007   Copyright 2008 Sandia Corporation.
00008   Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00009   the U.S. Government retains certain rights in this software.
00010 -------------------------------------------------------------------------
00011 
00012   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00013   All rights reserved.
00014   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00015 
00016      This software is distributed WITHOUT ANY WARRANTY; without even
00017      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00018      PURPOSE.  See the above copyright notice for more information.
00019 
00020 =========================================================================*/
00021 
00049 #ifndef __vtkUnicodeString_h
00050 #define __vtkUnicodeString_h
00051 
00052 #include "vtkCommonCoreModule.h" // For export macro
00053 #include <vtkSystemIncludes.h>
00054 #include <string>
00055 #include <vector>
00056 
00057 class vtkUnicodeString;
00058 
00059 typedef vtkTypeUInt32 vtkUnicodeStringValueType;
00060 
00061 //
00062 // The following should be eventually placed in vtkSetGet.h
00063 //
00064 
00065 // This is same as extra extended template macro with an
00066 // additional case for VTK_UNICODE_STRING
00067 #define vtkSuperExtraExtendedTemplateMacro(call)                                 \
00068   vtkExtraExtendedTemplateMacro(call);                                            \
00069   vtkTemplateMacroCase(VTK_UNICODE_STRING, vtkUnicodeString, call)
00070 
00071 class VTKCOMMONCORE_EXPORT vtkUnicodeString
00072 {
00073 public:
00074   typedef vtkUnicodeStringValueType value_type;
00075   typedef std::string::size_type size_type;
00076 
00077   class VTKCOMMONCORE_EXPORT const_iterator
00078   {
00079   public:
00080     typedef std::bidirectional_iterator_tag iterator_category;
00081     typedef vtkUnicodeStringValueType value_type;
00082     typedef std::string::difference_type difference_type;
00083     typedef value_type* pointer;
00084     typedef value_type& reference;
00085 
00086     const_iterator();
00087 
00088     value_type operator*() const;
00089     bool operator==(const const_iterator&) const;
00090     bool operator!=(const const_iterator&) const;
00091     const_iterator& operator++();
00092     const_iterator operator++(int);
00093     const_iterator& operator--();
00094     const_iterator operator--(int);
00095 
00096   private:
00097     const_iterator(std::string::const_iterator);
00098     friend class vtkUnicodeString;
00099     std::string::const_iterator Position;
00100   };
00101 
00103   vtkUnicodeString();
00105   vtkUnicodeString(const vtkUnicodeString&);
00108   vtkUnicodeString(size_type count, value_type character);
00110   vtkUnicodeString(const_iterator begin, const_iterator end);
00111 
00113 
00115   static bool is_utf8(const char*);
00116   static bool is_utf8(const std::string&);
00118 
00120 
00122   static vtkUnicodeString from_utf8(const char*);
00123   // Constructs a string from a half-open sequence of UTF-8 encoded characters.
00124   static vtkUnicodeString from_utf8(const char* begin, const char* end);
00125   // Constructs a string from a sequence of UTF-8 encoded characters.
00126   static vtkUnicodeString from_utf8(const std::string&);
00128 
00130   static vtkUnicodeString from_utf16(const vtkTypeUInt16*);
00131 
00133   vtkUnicodeString& operator=(const vtkUnicodeString&);
00134 
00137   const_iterator begin() const;
00140   const_iterator end() const;
00141 
00144   value_type at(size_type offset) const;
00147   value_type operator[](size_type offset) const;
00148 
00151   const char* utf8_str() const;
00154   void utf8_str(std::string& result) const;
00156   std::vector<vtkTypeUInt16> utf16_str() const;
00159   void utf16_str(std::vector<vtkTypeUInt16>& result) const;
00160 
00162   size_type byte_count() const;
00164   size_type character_count() const;
00166   bool empty() const;
00167 
00169   static const size_type npos;
00170 
00172   vtkUnicodeString& operator+=(value_type);
00174   vtkUnicodeString& operator+=(const vtkUnicodeString& rhs);
00175 
00177   void push_back(value_type);
00178 
00180 
00181   void append(const vtkUnicodeString& value);
00182   void append(size_type count, value_type character);
00183   void append(const_iterator begin, const_iterator end);
00185 
00187 
00188   void assign(const vtkUnicodeString& value);
00189   void assign(size_type count, value_type character);
00190   void assign(const_iterator begin, const_iterator end);
00192 
00194   void clear();
00195 
00202   vtkUnicodeString fold_case() const;
00203 
00209   int compare(const vtkUnicodeString&) const;
00210 
00213   vtkUnicodeString substr(size_type offset = 0, size_type count = npos) const;
00214 
00216   void swap(vtkUnicodeString&);
00217 
00218 private:
00219   std::string Storage;
00220   class back_insert_iterator;
00221 };
00222 
00223 VTKCOMMONCORE_EXPORT bool operator==(const vtkUnicodeString& lhs, const vtkUnicodeString& rhs);
00224 VTKCOMMONCORE_EXPORT bool operator!=(const vtkUnicodeString& lhs, const vtkUnicodeString& rhs);
00225 VTKCOMMONCORE_EXPORT bool operator<(const vtkUnicodeString& lhs, const vtkUnicodeString& rhs);
00226 VTKCOMMONCORE_EXPORT bool operator<=(const vtkUnicodeString& lhs, const vtkUnicodeString& rhs);
00227 VTKCOMMONCORE_EXPORT bool operator>=(const vtkUnicodeString& lhs, const vtkUnicodeString& rhs);
00228 VTKCOMMONCORE_EXPORT bool operator>(const vtkUnicodeString& lhs, const vtkUnicodeString& rhs);
00229 
00230 #endif
00231 
00232 // VTK-HeaderTest-Exclude: vtkUnicodeString.h