monotone

monotone Mtn Source Tree

Root/botan/data_src.h

1/*************************************************
2* DataSource Header File *
3* (C) 1999-2006 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 std::string&);
47 DataSource_Memory(const byte[], u32bit);
48 DataSource_Memory(const MemoryRegion<byte>&);
49 private:
50 SecureVector<byte> source;
51 u32bit offset;
52 };
53
54/*************************************************
55* Stream-Based DataSource *
56*************************************************/
57class DataSource_Stream : public DataSource
58 {
59 public:
60 u32bit read(byte[], u32bit);
61 u32bit peek(byte[], u32bit, u32bit) const;
62 bool end_of_data() const;
63 std::string id() const;
64
65 DataSource_Stream(const std::string&, bool = false);
66 ~DataSource_Stream();
67 private:
68 const std::string fsname;
69 std::istream* source;
70 u32bit total_read;
71 };
72
73}
74
75#endif

Archive Download this file

Branches

Tags

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