/*************************************************
* DataSource Header File                         *
* (C) 1999-2003 The Botan Project                *
*************************************************/

#ifndef BOTAN_DATA_SRC__
#define BOTAN_DATA_SRC__

#include <botan/base.h>
#include <iosfwd>

namespace Botan {

/*************************************************
* Generic DataSource Interface                   *
*************************************************/
class DataSource
   {
   public:
      virtual u32bit read(byte[], u32bit) = 0;
      virtual bool end_of_data() const = 0;
      u32bit read_byte(byte&);
      DataSource() {}
      virtual ~DataSource() {}
   private:
      DataSource& operator=(const DataSource&) { return (*this); }
      DataSource(const DataSource&);
   };

/*************************************************
* Memory-Based DataSource                        *
*************************************************/
class DataSource_Memory : public DataSource
   {
   public:
      u32bit read(byte[], u32bit);
      bool end_of_data() const;
      DataSource_Memory(const byte[], u32bit);
      DataSource_Memory(const SecureVector<byte>&);
   private:
      SecureVector<byte> source;
      u32bit offset;
   };

/*************************************************
* Stream-Based DataSource                        *
*************************************************/
class DataSource_Stream : public DataSource
   {
   public:
      u32bit read(byte[], u32bit);
      bool end_of_data() const;
      DataSource_Stream(std::istream&);
      DataSource_Stream(const std::string&);
      ~DataSource_Stream();
   private:
      std::istream* source;
      bool owns;
   };

}

#endif
