Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef HASHSTREAM_H_
00009 #define HASHSTREAM_H_
00010
00011 #include "ibrcommon/Exceptions.h"
00012 #include <streambuf>
00013 #include <iostream>
00014
00015 namespace ibrcommon
00016 {
00017 class HashStream : public std::basic_streambuf<char, std::char_traits<char> >, public std::iostream
00018 {
00019 public:
00020 HashStream(const size_t hash, const size_t buffer = 2048);
00021 virtual ~HashStream();
00022
00023 protected:
00024 virtual void update(char *buf, const size_t size) = 0;
00025 virtual void finalize(char * hash, unsigned int &size) = 0;
00026
00027 virtual int sync();
00028 virtual int overflow(int = std::char_traits<char>::eof());
00029 virtual int underflow();
00030
00031 private:
00032
00033 char *data_buf_;
00034
00035
00036 size_t data_size_;
00037
00038
00039 char *hash_buf_;
00040
00041
00042 unsigned int hash_size_;
00043
00044 bool final_;
00045 };
00046 }
00047
00048 #endif