1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
// Copyright (c) 2012-2014 Konstantin Isakov <ikm@zbackup.org> and ZBackup contributors, see CONTRIBUTORS
// Part of ZBackup. Licensed under GNU GPLv2 or later + OpenSSL, see LICENSE
#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 );
};
bool operator <( const ChunkId &lhs, const ChunkId &rhs );
#endif
|