MIRA
Public Member Functions | List of all members
HashStream< T > Class Template Reference

A template base class for hash functions based on std::ostream. More...

#include <security/HashStream.h>

Inheritance diagram for HashStream< T >:
Inheritance graph
[legend]

Public Member Functions

 HashStream ()
 Th default constructor. More...
 
virtual ~HashStream ()
 The destructor. More...
 
virtual void reset ()
 Reset the hash value. More...
 
HashDigest getDigest () const
 Return the current digest of the hash algorithm. More...
 
HashStreamoperator<< (const char *value)
 Put a C-string in the hash stream. More...
 
HashStreamoperator<< (const std::string &value)
 Put a STL string in the hash stream. More...
 
HashStreamoperator<< (const bool &value)
 Put a bool in the hash stream. More...
 
HashStreamoperator<< (const char &value)
 Put a char in the hash stream. More...
 
HashStreamoperator<< (const uint8 &value)
 Put a uint8 in the hash stream. More...
 
HashStreamoperator<< (const uint16 &value)
 Put a uint16 in the hash stream. More...
 
HashStreamoperator<< (const uint32 &value)
 Put a uint32 in the hash stream. More...
 
HashStreamoperator<< (const uint64 &value)
 Put a uint64 in the hash stream. More...
 
HashStreamoperator<< (const int8 &value)
 Put a int8 in the hash stream. More...
 
HashStreamoperator<< (const int16 &value)
 Put a int16 in the hash stream. More...
 
HashStreamoperator<< (const int32 &value)
 Put a int32 in the hash stream. More...
 
HashStreamoperator<< (const int64 &value)
 Put a int64 in the hash stream. More...
 
HashStreamoperator<< (const float &value)
 Put a float in the hash stream. More...
 
HashStreamoperator<< (const double &value)
 Put a double in the hash stream. More...
 

Detailed Description

template<class T>
class mira::HashStream< T >

A template base class for hash functions based on std::ostream.

To use this class, a specialization of this template using a specific implementation of HashStreamBuf has to be used.

Usage example:

// Implementation of an own HashStreamBuf class
class MyHashStreamBuf :
public HashStreamBuf
{
public:
MyHashStreamBuf() { ... }
~MyHashStreamBuf() { ... }
public:
// Implementation of HashStreamBuf::reset
virtual void reset() { ... }
// Implementation of HashStreamBuf::getDigest
virtual HashDigest getDigest() const { ... }
protected:
// Implementation of std::basic_streambuf::xsputn
virtual std::streamsize xsputn(const char* s, std::streamsize n) { ... }
};
// Typedef for the hash function
typedef HashStream<MyHashStreamBuf> MyHash;
int main(int pArgc, char* pArgv[])
{
MyHash hash;
hash << "Some data.";
std::cout << "Digest1: " << hash.getDigest().toString() << std::endl;
hash.reset();
hash << "Some other data.";
std::cout << "Digest2: " << hash.getDigest().toString() << std::endl;
}

Constructor & Destructor Documentation

◆ HashStream()

HashStream ( )
inline

Th default constructor.

◆ ~HashStream()

virtual ~HashStream ( )
inlinevirtual

The destructor.

Member Function Documentation

◆ reset()

virtual void reset ( )
inlinevirtual

Reset the hash value.

◆ getDigest()

HashDigest getDigest ( ) const
inline

Return the current digest of the hash algorithm.

Returns
The hash digest.

◆ operator<<() [1/14]

HashStream& operator<< ( const char *  value)
inline

Put a C-string in the hash stream.

◆ operator<<() [2/14]

HashStream& operator<< ( const std::string &  value)
inline

Put a STL string in the hash stream.

◆ operator<<() [3/14]

HashStream& operator<< ( const bool &  value)
inline

Put a bool in the hash stream.

◆ operator<<() [4/14]

HashStream& operator<< ( const char &  value)
inline

Put a char in the hash stream.

◆ operator<<() [5/14]

HashStream& operator<< ( const uint8 &  value)
inline

Put a uint8 in the hash stream.

◆ operator<<() [6/14]

HashStream& operator<< ( const uint16 &  value)
inline

Put a uint16 in the hash stream.

◆ operator<<() [7/14]

HashStream& operator<< ( const uint32 &  value)
inline

Put a uint32 in the hash stream.

◆ operator<<() [8/14]

HashStream& operator<< ( const uint64 &  value)
inline

Put a uint64 in the hash stream.

◆ operator<<() [9/14]

HashStream& operator<< ( const int8 &  value)
inline

Put a int8 in the hash stream.

◆ operator<<() [10/14]

HashStream& operator<< ( const int16 &  value)
inline

Put a int16 in the hash stream.

◆ operator<<() [11/14]

HashStream& operator<< ( const int32 &  value)
inline

Put a int32 in the hash stream.

◆ operator<<() [12/14]

HashStream& operator<< ( const int64 &  value)
inline

Put a int64 in the hash stream.

◆ operator<<() [13/14]

HashStream& operator<< ( const float &  value)
inline

Put a float in the hash stream.

◆ operator<<() [14/14]

HashStream& operator<< ( const double &  value)
inline

Put a double in the hash stream.


The documentation for this class was generated from the following file: