monotone

monotone Mtn Source Tree

Root/botan/data_src.h

1/*************************************************
2* DataSource Header File *
3* (C) 1999-2005 The Botan Project *
4*************************************************/
5
6#ifndef BOTAN_DATA_SRC_H__
7#define BOTAN_DATA_SRC_H__
8
9#include <botan/base.h>
10#include <iosfwd>
11
12namespace Botan {
13
14/*************************************************
15* Generic DataSource Interface *
16*************************************************/
17class DataSource
18 {
19 public:
20 virtual u32bit read(byte[], u32bit) = 0;
21 virtual u32bit peek(byte[], u32bit, u32bit) const = 0;
22 virtual bool end_of_data() const = 0;
23 virtual std::string id() const { return ""; }
24
25 u32bit read_byte(byte&);
26 u32bit peek_byte(byte&) const;
27 u32bit discard_next(u32bit);
28
29 DataSource() {}
30 virtual ~DataSource() {}
31 private:
32 DataSource& operator=(const DataSource&) { return (*this); }
33 DataSource(const DataSource&);
34 };
35
36/*************************************************
37* Memory-Based DataSource *
38*************************************************/
39class DataSource_Memory : public DataSource
40 {
41 public:
42 u32bit read(byte[], u32bit);
43 u32bit peek(byte[], u32bit, u32bit) const;
44 bool end_of_data() const;
45
46 DataSource_Memory(const byte[], u32bit);
47 DataSource_Memory(const MemoryRegion<byte>&);
48 private:
49 SecureVector<byte> source;
50 u32bit offset;
51 };
52
53/*************************************************
54* Stream-Based DataSource *
55*************************************************/
56class DataSource_Stream : public DataSource
57 {
58 public:
59 u32bit read(byte[], u32bit);
60 u32bit peek(byte[], u32bit, u32bit) const;
61 bool end_of_data() const;
62 std::string id() const;
63
64 DataSource_Stream(const std::string&, bool = false);
65 ~DataSource_Stream();
66 private:
67 const std::string fsname;
68 std::istream* source;
69 u32bit total_read;
70 };
71
72}
73
74#endif

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status