PoDoFo 1.2.0
Loading...
Searching...
No Matches
InputStream.h
1// SPDX-FileCopyrightText: 2007 Dominik Seichter <domseichter@web.de>
2// SPDX-FileCopyrightText: 2020 Francesco Pretto <ceztko@gmail.com>
3// SPDX-License-Identifier: LGPL-2.0-or-later OR MPL-2.0
4
5#ifndef AUX_INPUT_STREAM_H
6#define AUX_INPUT_STREAM_H
7
8#include "basedefs.h"
9
10namespace PoDoFo {
11
12class OutputStream;
13
16class PODOFO_API InputStream
17{
18public:
20 virtual ~InputStream();
21
27 void Read(char* buffer, size_t size);
28
34 size_t Read(char* buffer, size_t size, bool& eof);
35
40 char ReadChar();
41
46 bool Read(char& ch);
47
51 void CopyTo(OutputStream& stream);
52
56 void CopyTo(OutputStream& stream, size_t size);
57
58protected:
62 static size_t ReadBuffer(InputStream& stream, char* buffer, size_t size, bool& eof);
63 static bool ReadChar(InputStream& stream, char& ch);
64
65protected:
69 virtual size_t readBuffer(char* buffer, size_t size, bool& eof) = 0;
70
73 virtual bool readChar(char& ch);
74
77 virtual void checkRead() const;
78
79protected:
90 const char* m_head;
91 const char* m_tail;
92
93private:
96 void readSlowPath(char* buffer, size_t size);
97 size_t readSlowPath(char* buffer, size_t size, bool& eof);
98 char readCharSlowPath();
99 bool tryReadCharSlowPath(char& ch);
100
101private:
102 InputStream(const InputStream&) = delete;
103 InputStream& operator=(const InputStream&) = delete;
104};
105
106};
107
108#endif // AUX_INPUT_STREAM_H
An interface for reading blocks of data from a data source.
Definition InputStream.h:17
const char * m_head
Inline read window over memory that already holds the bytes at the current logical position.
Definition InputStream.h:90
virtual size_t readBuffer(char *buffer, size_t size, bool &eof)=0
Read a buffer from the stream.
An interface for writing blocks of data to a data source.
Definition OutputStream.h:15
Convenient type for char array storage and/or buffer with std::string compatibility.
Definition basetypes.h:30
All classes, functions, types and enums of PoDoFo are members of these namespace.
Definition basetypes.h:13