Botan 2.19.5 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 <memory>
14#include <iosfwd>
15
16 namespace Botan {
17
18/**
19* This class represents abstract data sink objects.
20*/
21 class BOTAN_PUBLIC_API(2,0) DataSink : public Filter
22 {
23 public:
24 bool attachable() override { return false; }
25 DataSink() = default;
26 virtual ~DataSink() {}
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*/
35 class BOTAN_PUBLIC_API(2,0) DataSink_Stream final : public DataSink
36 {
37 public:
38 /**
39 * Construct a DataSink_Stream from a stream.
40 * @param stream the stream to write to
41 * @param name identifier
42 */
43 DataSink_Stream(std::ostream& stream,
44 const std::string& name = "<std::ostream>");
45
46#if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
47
48 /**
49 * Construct a DataSink_Stream from a filesystem path name.
50 * @param pathname the name of the file to open a stream to
51 * @param use_binary indicates whether to treat the file
52 * as a binary file or not
53 */
54 DataSink_Stream(const std::string& pathname,
55 bool use_binary = false);
56#endif
57
58 std::string name() const override { return m_identifier; }
59
60 void write(const uint8_t[], size_t) override;
61
62 void end_msg() override;
63
64 ~DataSink_Stream();
65
66 private:
67 const std::string m_identifier;
68
69 // May be null, if m_sink was an external reference
70 std::unique_ptr<std::ostream> m_sink_memory;
71 std::ostream& m_sink;
72 };
73
74}
75
76#endif
Botan::DataSink_Stream
Definition: data_snk.h:36
Botan::DataSink_Stream::name
std::string name() const override
Definition: data_snk.h:58
Botan::DataSink
Definition: data_snk.h:22
Botan::DataSink::operator=
DataSink & operator=(const DataSink &)=delete
Botan::DataSink::DataSink
DataSink(const DataSink &)=delete
Botan::DataSink::DataSink
DataSink()=default
Botan::DataSink::attachable
bool attachable() override
Definition: data_snk.h:24
Botan::DataSink::~DataSink
virtual ~DataSink()
Definition: data_snk.h:26
Botan::Filter
Definition: filter.h:22
name
std::string name
Definition: commoncrypto_hash.cpp:24
final
int(* final)(unsigned char *, CTX *)
Definition: commoncrypto_hash.cpp:29
BOTAN_PUBLIC_API
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
Botan
Definition: alg_id.cpp:13