Botan 3.6.1
Crypto and TLS for C&
data_snk.h
Go to the documentation of this file.
1/*
2* DataSink
3* (C) 1999-2007 Jack Lloyd
4* 2017 Philippe Lieser
5*
6* Botan is released under the Simplified BSD License (see license.txt)
7*/
8
9#ifndef BOTAN_DATA_SINK_H_
10#define BOTAN_DATA_SINK_H_
11
12#include <botan/filter.h>
13#include <iosfwd>
14#include <memory>
15
16namespace Botan {
17
18/**
19* This class represents abstract data sink objects.
20*/
21class BOTAN_PUBLIC_API(2, 0) DataSink : public Filter {
22 public:
23 bool attachable() override { return false; }
24
25 DataSink() = default;
26 ~DataSink() override = default;
27
28 DataSink& operator=(const DataSink&) = delete;
29 DataSink(const DataSink&) = delete;
30};
31
32/**
33* This class represents a data sink which writes its output to a stream.
34*/
36 public:
37 /**
38 * Construct a DataSink_Stream from a stream.
39 * @param stream the stream to write to
40 * @param name identifier
41 */
42 DataSink_Stream(std::ostream& stream, std::string_view name = "<std::ostream>");
43
44#if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
45
46 /**
47 * Construct a DataSink_Stream from a filesystem path name.
48 * @param pathname the name of the file to open a stream to
49 * @param use_binary indicates whether to treat the file
50 * as a binary file or not
51 */
52 DataSink_Stream(std::string_view pathname, bool use_binary = false);
53#endif
54
55 std::string name() const override { return m_identifier; }
56
57 void write(const uint8_t[], size_t) override;
58
59 void end_msg() override;
60
61 ~DataSink_Stream() override;
62
63 private:
64 const std::string m_identifier;
65
66 // May be null, if m_sink was an external reference
67 std::unique_ptr<std::ostream> m_sink_memory;
68 std::ostream& m_sink;
69};
70
71} // namespace Botan
72
73#endif
std::string name() const override
Definition data_snk.h:55
~DataSink_Stream() override
DataSink & operator=(const DataSink &)=delete
DataSink(const DataSink &)=delete
DataSink()=default
bool attachable() override
Definition data_snk.h:23
~DataSink() override=default
std::string name
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition compiler.h:31