Botan 2.19.2
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
16namespace Botan {
17
18/**
19* This class represents abstract data sink objects.
20*/
21class BOTAN_PUBLIC_API(2,0) DataSink : public Filter
22 {
23 public:
24 bool attachable() override { return false; }
25 DataSink() = default;
26 virtual ~DataSink() = 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 {
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
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
std::string name() const override
Definition: data_snk.h:58
DataSink & operator=(const DataSink &)=delete
DataSink(const DataSink &)=delete
DataSink()=default
virtual ~DataSink()=default
bool attachable() override
Definition: data_snk.h:24
std::string name
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
Definition: alg_id.cpp:13