Botan
1.10.9
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
src
filters
data_snk.cpp
Go to the documentation of this file.
1
/*
2
* DataSink
3
* (C) 1999-2007 Jack Lloyd
4
* 2005 Matthew Gregan
5
*
6
* Distributed under the terms of the Botan license
7
*/
8
9
#include <botan/data_snk.h>
10
#include <botan/exceptn.h>
11
#include <fstream>
12
13
namespace
Botan
{
14
15
/*
16
* Write to a stream
17
*/
18
void
DataSink_Stream::write
(
const
byte
out[],
size_t
length)
19
{
20
sink.write(reinterpret_cast<const char*>(out), length);
21
if
(!sink.good())
22
throw
Stream_IO_Error
(
"DataSink_Stream: Failure writing to "
+
23
identifier);
24
}
25
26
/*
27
* DataSink_Stream Constructor
28
*/
29
DataSink_Stream::DataSink_Stream
(std::ostream& out,
30
const
std::string& name) :
31
identifier(name),
32
sink_p(0),
33
sink(out)
34
{
35
}
36
37
/*
38
* DataSink_Stream Constructor
39
*/
40
DataSink_Stream::DataSink_Stream
(
const
std::string& path,
41
bool
use_binary) :
42
identifier(path),
43
sink_p(new
std
::ofstream(
44
path.c_str(),
45
use_binary ?
std
::ios::binary :
std
::ios::out)),
46
sink(*sink_p)
47
{
48
if
(!sink.good())
49
{
50
delete
sink_p;
51
throw
Stream_IO_Error
(
"DataSink_Stream: Failure opening "
+ path);
52
}
53
}
54
55
/*
56
* DataSink_Stream Destructor
57
*/
58
DataSink_Stream::~DataSink_Stream
()
59
{
60
delete
sink_p;
61
}
62
63
}
Botan::Stream_IO_Error
Definition:
exceptn.h:165
std
Definition:
secmem.h:422
Botan::byte
unsigned char byte
Definition:
types.h:22
Botan::DataSink_Stream::DataSink_Stream
DataSink_Stream(std::ostream &stream, const std::string &name="<std::ostream>")
Definition:
data_snk.cpp:29
Botan
Definition:
algo_base.h:14
Botan::DataSink_Stream::write
void write(const byte[], size_t)
Definition:
data_snk.cpp:18
Botan::DataSink_Stream::~DataSink_Stream
~DataSink_Stream()
Definition:
data_snk.cpp:58
Generated on Sat Aug 20 2016 08:18:47 for Botan by
1.8.9.1