PoDoFo  1.0.0-dev
PdfStringStream.h
1 
7 #ifndef PDF_STRING_STREAM
8 #define PDF_STRING_STREAM
9 
10 #include "PdfDeclarations.h"
11 #include <podofo/auxiliary/OutputStream.h>
12 
13 namespace PoDoFo
14 {
19  class PODOFO_API PdfStringStream final : public OutputStream
20  {
21  public:
23 
24  template <typename T>
25  inline PdfStringStream& operator<<(T const& val)
26  {
27  (*m_stream) << val;
28  return *this;
29  }
30 
31  // This is needed to allow using std::endl
32  PdfStringStream& operator<<(
33  std::ostream& (*pfn)(std::ostream&));
34 
35  PdfStringStream& operator<<(float val);
36 
37  PdfStringStream& operator<<(double val);
38 
39  std::string_view GetString() const;
40 
41  std::string TakeString();
42 
43  void Clear();
44 
45  void SetPrecision(unsigned short value);
46 
47  unsigned short GetPrecision() const;
48 
49  unsigned GetSize() const;
50 
51  explicit operator std::ostream& () { return *m_stream; }
52 
53  protected:
54  void writeBuffer(const char* buffer, size_t size);
55 
56  private:
57  using OutputStream::Flush;
58  using OutputStream::Write;
59 
60  private:
61  charbuff m_temp;
62  std::unique_ptr<std::ostream> m_stream;
63  };
64 }
65 
66 #endif // PDF_STRING_STREAM
SPDX-FileCopyrightText: (C) 2005 Dominik Seichter domseichter@web.de SPDX-FileCopyrightText: (C) 2020...
An interface for writing blocks of data to a data source.
Definition: OutputStream.h:18
void Write(char ch)
Write the character in the device.
Definition: OutputStream.cpp:17
A specialized Pdf output string stream It supplies an iostream-like operator<< interface,...
Definition: PdfStringStream.h:20
Convenient type for char array storage and/or buffer with std::string compatibility.
Definition: basetypes.h:38
SPDX-FileCopyrightText: (C) 2022 Francesco Pretto ceztko@gmail.com SPDX-License-Identifier: LGPL-2....
Definition: basetypes.h:16