Botan 1.10.17

data_snk.h
Go to the documentation of this file.
1 /*
2 * DataSink
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7
8 #ifndef BOTAN_DATA_SINK_H__
9 #define BOTAN_DATA_SINK_H__
10
11 #include <botan/filter.h>
12 #include <iosfwd>
13
14 namespace Botan {
15
16 /**
17 * This class represents abstract data sink objects.
18 */
19 class BOTAN_DLL DataSink : public Filter
20 {
21 public:
22 bool attachable() { return false; }
23 DataSink() {}
24 virtual ~DataSink() {}
25 private:
26 DataSink& operator=(const DataSink&) { return (*this); }
27 DataSink(const DataSink&);
28 };
29
30 /**
31 * This class represents a data sink which writes its output to a stream.
32 */
33 class BOTAN_DLL DataSink_Stream : public DataSink
34 {
35 public:
36 std::string name() const { return identifier; }
37
38 void write(const byte[], size_t);
39
40 /**
41 * Construct a DataSink_Stream from a stream.
42 * @param stream the stream to write to
43 * @param name identifier
44 */
45 DataSink_Stream(std::ostream& stream,
46 const std::string& name = "<std::ostream>");
47
48 /**
49 * Construct a DataSink_Stream from a stream.
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
57 ~DataSink_Stream();
58 private:
59 const std::string identifier;
60
61 std::ostream* sink_p;
62 std::ostream& sink;
63 };
64
65 }
66
67 #endif
Botan::DataSink::attachable
bool attachable()
Definition: data_snk.h:22
Botan::DataSink_Stream::name
std::string name() const
Definition: data_snk.h:36
Botan::DataSink::DataSink
DataSink()
Definition: data_snk.h:23
Botan::byte
unsigned char byte
Definition: types.h:22
Botan::Filter
Definition: filter.h:19
Botan
Definition: algo_base.h:14
Botan::DataSink
Definition: data_snk.h:19
Botan::DataSink::~DataSink
virtual ~DataSink()
Definition: data_snk.h:24
Botan::DataSink_Stream
Definition: data_snk.h:33