PoDoFo 1.2.0
Loading...
Searching...
No Matches
PdfStringStream.h
1// SPDX-FileCopyrightText: 2022 Francesco Pretto <ceztko@gmail.com>
2// SPDX-License-Identifier: LGPL-2.0-or-later OR MPL-2.0
3
4#ifndef PDF_STRING_STREAM
5#define PDF_STRING_STREAM
6
7#include "PdfDeclarations.h"
8#include <podofo/auxiliary/OutputStream.h>
9
10namespace PoDoFo
11{
15 class PODOFO_API PdfStringStream final : public OutputStream
16 {
17 public:
19
20 template <typename T>
21 inline PdfStringStream& operator<<(T const& val)
22 {
23 (*m_stream) << val;
24 return *this;
25 }
26
27 // This is needed to allow using std::endl
29 std::ostream& (*pfn)(std::ostream&));
30
32
34
35 std::string_view GetString() const;
36
37 std::string TakeString();
38
39 void Clear();
40
41 void SetPrecision(unsigned short value);
42
43 unsigned short GetPrecision() const;
44
45 unsigned GetSize() const;
46
47 explicit operator std::ostream& () { return *m_stream; }
48
49 protected:
50 void writeBuffer(const char* buffer, size_t size);
51
52 private:
53 using OutputStream::Flush;
54 using OutputStream::Write;
55
56 private:
57 charbuff m_temp;
58 std::unique_ptr<std::ostream> m_stream;
59 };
60}
61
62#endif // PDF_STRING_STREAM
This file should be included as the FIRST file in every header of PoDoFo lib.
An interface for writing blocks of data to a data source.
Definition OutputStream.h:15
A specialized Pdf output string stream It supplies an iostream-like operator<< interface,...
Definition PdfStringStream.h:16
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