zbackup/chunk_id.hh

40 lines
881 B
C++
Raw Normal View History

// Part of ZBackup. Licensed under GNU GPLv2 or later + OpenSSL, see LICENSE
2013-07-18 21:33:25 +04:00
#ifndef CHUNK_ID_HH_INCLUDED__
#define CHUNK_ID_HH_INCLUDED__
#include <string>
#include "rolling_hash.hh"
using std::string;
/// Chunk is identified by its crypto hash concatenated with its rolling hash
struct ChunkId
{
typedef char CryptoHashPart[ 16 ];
CryptoHashPart cryptoHash;
typedef RollingHash::Digest RollingHashPart;
RollingHashPart rollingHash;
enum
{
BlobSize = sizeof( CryptoHashPart ) + sizeof( RollingHashPart )
};
string toBlob() const;
/// Faster version - should point to a buffer with at least BlobSize bytes
void toBlob( void * ) const;
/// Set the chunk id data reading from the given blob
void setFromBlob( void const * );
ChunkId() {}
ChunkId( string const & blob );
};
2014-07-14 00:11:01 +04:00
bool operator <( const ChunkId &lhs, const ChunkId &rhs );
2013-07-18 21:33:25 +04:00
#endif