Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

data_snk.h
Go to the documentation of this file.
1 /*
2 * DataSink
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7
8 #ifndef BOTAN_DATA_SINK_H__
9 #define BOTAN_DATA_SINK_H__
10
11 #include <botan/filter.h>
12 #include <memory>
13 #include <iosfwd>
14
15 namespace Botan {
16
17 /**
18 * This class represents abstract data sink objects.
19 */
20 class BOTAN_DLL DataSink : public Filter
21 {
22 public:
23 bool attachable() override { return false; }
24 DataSink() = default;
25 virtual ~DataSink() = default;
26
27 DataSink& operator=(const DataSink&) = delete;
28 DataSink(const DataSink&) = delete;
29 };
30
31 /**
32 * This class represents a data sink which writes its output to a stream.
33 */
34 class BOTAN_DLL DataSink_Stream : public DataSink
35 {
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,
43 const std::string& name = "<std::ostream>");
44
45 #if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
46
47 /**
48 * Construct a DataSink_Stream from a filesystem path name.
49 * @param pathname the name of the file to open a stream to
50 * @param use_binary indicates whether to treat the file
51 * as a binary file or not
52 */
53 DataSink_Stream(const std::string& pathname,
54 bool use_binary = false);
55 #endif
56
57 std::string name() const override { return m_identifier; }
58
59 void write(const uint8_t[], size_t) override;
60
61 ~DataSink_Stream();
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 }
72
73 #endif
Botan::Filter
Definition: filter.h:21
Botan::DataSink::attachable
bool attachable() override
Definition: data_snk.h:23
Botan
Definition: alg_id.cpp:13
Botan::DataSink
Definition: data_snk.h:20
Botan::DataSink_Stream::name
std::string name() const override
Definition: data_snk.h:57
Botan::DataSink_Stream
Definition: data_snk.h:34