PDF SDK Documentation

Comprehensive Guide for Developers: Features, Integration, and API Reference

Loading...
Searching...
No Matches
read_stream.h
1// Copyright (c) 2009-2025 Avanquest Software. All rights reserved.
2
3#ifndef PDFSDK_CXX_PDF_READ_STREAM_H_INCLUDED_
4#define PDFSDK_CXX_PDF_READ_STREAM_H_INCLUDED_
5
7
8#include "wrapper_base.h"
9
10namespace PDF {
11
15class ReadStream : public detail::RefCountedHandle<PDReadStream> {
16public:
23 size_t Read(void* buffer, size_t nbytes);
24
29 int ReadChar();
30
35 std::string ReadAll() {
36 std::string data;
37 static constexpr size_t BUFFER_SIZE = 4096;
38 char buffer[BUFFER_SIZE];
39 size_t nread = Read(buffer, BUFFER_SIZE);
40 while (nread != 0) {
41 data.append(buffer, nread);
42 nread = Read(buffer, BUFFER_SIZE);
43 }
44 return data;
45 }
46
50 void Close();
51
52 PDF_CXX_CORE_WRAPPER_DEFINE_MEMBERS_(ReadStream, PDReadStream)
53};
54
55} // namespace PDF
56
57#include "read_stream_impl.inl"
58
59#endif // PDFSDK_CXX_PDF_READ_STREAM_H_INCLUDED_
Represents a read stream for reading data.
Definition read_stream.h:15
std::string ReadAll()
Reads all data from the stream and returns it as a string.
Definition read_stream.h:35
size_t Read(void *buffer, size_t nbytes)
Reads data from the stream into the specified buffer.
void Close()
Closes the read stream.
Objects API.