3
* (C) 1999-2007 Jack Lloyd
6
* Botan is released under the Simplified BSD License (see license.txt)
9
#ifndef BOTAN_DATA_SINK_H_
10
#define BOTAN_DATA_SINK_H_
12
#include <botan/filter.h>
19
* This class represents abstract data sink objects.
21
class BOTAN_PUBLIC_API(2,0) DataSink : public Filter
24
bool attachable() override { return false; }
26
virtual ~DataSink() = default;
28
DataSink& operator=(const DataSink&) = delete;
29
DataSink(const DataSink&) = delete;
33
* This class represents a data sink which writes its output to a stream.
35
class BOTAN_PUBLIC_API(2,0) DataSink_Stream final : public DataSink
39
* Construct a DataSink_Stream from a stream.
40
* @param stream the stream to write to
41
* @param name identifier
43
DataSink_Stream(std::ostream& stream,
44
const std::string& name = "<std::ostream>");
46
#if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
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
54
DataSink_Stream(const std::string& pathname,
55
bool use_binary = false);
58
std::string name() const override { return m_identifier; }
60
void write(const uint8_t[], size_t) override;
62
void end_msg() override;
67
const std::string m_identifier;
69
// May be null, if m_sink was an external reference
70
std::unique_ptr<std::ostream> m_sink_memory;