VTK  9.1.0
vtkTextCodec.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3 Program: Visualization Toolkit
4 Module: vtkTextCodec.h
5 
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /*-------------------------------------------------------------------------
16  Copyright 2008 Sandia Corporation.
17  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
18  the U.S. Government retains certain rights in this software.
19 -------------------------------------------------------------------------*/
37 #ifndef vtkTextCodec_h
38 #define vtkTextCodec_h
39 
40 #include "vtkIOCoreModule.h" // For export macro
41 #include "vtkObject.h"
42 #include "vtkUnicodeString.h" // for the value type and for function return.
43 
44 class VTKIOCORE_EXPORT vtkTextCodec : public vtkObject
45 {
46 public:
47  vtkTypeMacro(vtkTextCodec, vtkObject);
48 
50 
54  virtual const char* Name();
55  void PrintSelf(ostream& os, vtkIndent indent) override;
57 
58  virtual bool CanHandle(const char* NameString);
59 
63  virtual bool IsValid(istream& InputStream);
64 
66 
72  // FIXME(#18327): This class should be migrated to do UTF-8-based processing.
73  // Currently it works based on `vtkUnicodeString` due to the `vtkTypeUInt32`
74  // item type.
76  {
77  public:
78  virtual OutputIterator& operator++(int) { return *this; }
79  virtual OutputIterator& operator*() { return *this; }
80  virtual OutputIterator& operator=(const vtkTypeUInt32& value) = 0;
81 
82  OutputIterator() = default;
83  virtual ~OutputIterator() = default;
84 
85  private:
86  OutputIterator(const OutputIterator&) = delete;
87  OutputIterator& operator=(const OutputIterator&) = delete;
88  };
90 
96  virtual void ToUnicode(istream& inputStream, vtkTextCodec::OutputIterator& output);
97 
102  std::string ToString(istream& inputStream);
103  VTK_DEPRECATED_IN_9_1_0("Use std::string ToString(istream& inputStream)")
104  vtkUnicodeString ToUnicode(istream& inputStream);
105 
111  virtual vtkTypeUInt32 NextUTF32CodePoint(istream& inputStream) = 0;
112  VTK_DEPRECATED_IN_9_1_0("Use vtkTypeUInt32 NextUTF32CodePoint(istream& inputStream)")
113  vtkUnicodeString::value_type NextUnicode(istream& inputStream);
114 
115 protected:
117  ~vtkTextCodec() override;
118 
119 private:
120  vtkTextCodec(const vtkTextCodec&) = delete;
121  void operator=(const vtkTextCodec&) = delete;
122 };
123 
124 #endif
a simple class to control print indentation
Definition: vtkIndent.h:34
abstract base class for most VTK objects
Definition: vtkObject.h:63
a base class that any output iterators need to derive from to use the first signature of to_unicode.
Definition: vtkTextCodec.h:76
virtual OutputIterator & operator++(int)
Definition: vtkTextCodec.h:78
virtual OutputIterator & operator*()
Definition: vtkTextCodec.h:79
virtual ~OutputIterator()=default
virtual OutputIterator & operator=(const vtkTypeUInt32 &value)=0
Virtual class to act as an interface for all text codecs.
Definition: vtkTextCodec.h:45
std::string ToString(istream &inputStream)
convenience method to take data from the stream and put it into a string.
virtual bool CanHandle(const char *NameString)
void PrintSelf(ostream &os, vtkIndent indent) override
The name this codec goes by - should match the string the factory will take to create it.
virtual bool IsValid(istream &InputStream)
is the given sample valid for this codec? The stream will not be advanced.
virtual void ToUnicode(istream &inputStream, vtkTextCodec::OutputIterator &output)
Iterate through the sequence represented by the stream assigning the result to the output iterator.
virtual const char * Name()
The name this codec goes by - should match the string the factory will take to create it.
String class that stores Unicode text.
@ value
Definition: vtkX3D.h:226
@ string
Definition: vtkX3D.h:496
#define VTK_DEPRECATED_IN_9_1_0(reason)