VTK  9.5.20251214
vtkResourceStream.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
3#ifndef vtkResourceStream_h
4#define vtkResourceStream_h
5
6#include "vtkIOCoreModule.h" // For export macro
7#include "vtkObject.h"
8#include "vtkSmartPointer.h" // For vtkSmartPointer
9
10#include <cstdlib> // for std::size_t
11#include <memory> // for std::unique_ptr
12#include <streambuf> // for std::basic_streambuf
13
14VTK_ABI_NAMESPACE_BEGIN
15
32class VTKIOCORE_EXPORT vtkResourceStream : public vtkObject
33{
34 struct vtkInternals;
35
36public:
37 enum class SeekDirection
38 {
39 Begin = 0,
41 End = 2
42 };
43
45 void PrintSelf(ostream& os, vtkIndent indent) override;
46
58 virtual std::size_t Read(void* buffer, std::size_t bytes) = 0;
59
71 virtual bool EndOfStream() = 0;
72
83 virtual vtkTypeInt64 Seek(vtkTypeInt64 pos, SeekDirection dir);
84
94 virtual vtkTypeInt64 Tell();
95
101 bool SupportSeek() const;
102
103#ifndef __VTK_WRAP__
110 std::unique_ptr<std::streambuf> ToStreambuf();
111#endif
112
113protected:
122 vtkResourceStream(bool supportSeek);
126
127private:
128 std::unique_ptr<vtkInternals> Impl;
129};
130
131VTK_ABI_NAMESPACE_END
132
133#endif
a simple class to control print indentation
Definition vtkIndent.h:108
vtkResourceStream(bool supportSeek)
Constructor.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual bool EndOfStream()=0
Check if the stream reached an end.
virtual vtkTypeInt64 Tell()
Get the stream cursor position.
vtkResourceStream & operator=(const vtkResourceStream &)=delete
bool SupportSeek() const
Check if stream supports Seek and Tell functions.
virtual vtkTypeInt64 Seek(vtkTypeInt64 pos, SeekDirection dir)
Move the stream cursor position.
vtkResourceStream(const vtkResourceStream &)=delete
std::unique_ptr< std::streambuf > ToStreambuf()
Create a new std::streambuf from this stream, which can be used to create an istream.
~vtkResourceStream() override
virtual std::size_t Read(void *buffer, std::size_t bytes)=0
Read data form the stream.