@ -18,11 +18,11 @@ class base_blob
{
{
protected :
protected :
static constexpr int WIDTH = BITS / 8 ;
static constexpr int WIDTH = BITS / 8 ;
uint8_t data[ WIDTH ] ;
uint8_t m_ data[ WIDTH ] ;
public :
public :
base_blob ( )
base_blob ( )
{
{
memset ( data, 0 , sizeof ( data) ) ;
memset ( m_ data, 0 , sizeof ( m_ data) ) ;
}
}
explicit base_blob ( const std : : vector < unsigned char > & vch ) ;
explicit base_blob ( const std : : vector < unsigned char > & vch ) ;
@ -30,17 +30,17 @@ public:
bool IsNull ( ) const
bool IsNull ( ) const
{
{
for ( int i = 0 ; i < WIDTH ; i + + )
for ( int i = 0 ; i < WIDTH ; i + + )
if ( data[ i ] ! = 0 )
if ( m_ data[ i ] ! = 0 )
return false ;
return false ;
return true ;
return true ;
}
}
void SetNull ( )
void SetNull ( )
{
{
memset ( data, 0 , sizeof ( data) ) ;
memset ( m_ data, 0 , sizeof ( m_ data) ) ;
}
}
inline int Compare ( const base_blob & other ) const { return memcmp ( data, other . data, sizeof ( data) ) ; }
inline int Compare ( const base_blob & other ) const { return memcmp ( m_ data, other . m_ data, sizeof ( m_ data) ) ; }
friend inline bool operator = = ( const base_blob & a , const base_blob & b ) { return a . Compare ( b ) = = 0 ; }
friend inline bool operator = = ( const base_blob & a , const base_blob & b ) { return a . Compare ( b ) = = 0 ; }
friend inline bool operator ! = ( const base_blob & a , const base_blob & b ) { return a . Compare ( b ) ! = 0 ; }
friend inline bool operator ! = ( const base_blob & a , const base_blob & b ) { return a . Compare ( b ) ! = 0 ; }
@ -53,32 +53,32 @@ public:
unsigned char * begin ( )
unsigned char * begin ( )
{
{
return & data[ 0 ] ;
return & m_ data[ 0 ] ;
}
}
unsigned char * end ( )
unsigned char * end ( )
{
{
return & data[ WIDTH ] ;
return & m_ data[ WIDTH ] ;
}
}
const unsigned char * begin ( ) const
const unsigned char * begin ( ) const
{
{
return & data[ 0 ] ;
return & m_ data[ 0 ] ;
}
}
const unsigned char * end ( ) const
const unsigned char * end ( ) const
{
{
return & data[ WIDTH ] ;
return & m_ data[ WIDTH ] ;
}
}
unsigned int size ( ) const
unsigned int size ( ) const
{
{
return sizeof ( data) ;
return sizeof ( m_ data) ;
}
}
uint64_t GetUint64 ( int pos ) const
uint64_t GetUint64 ( int pos ) const
{
{
const uint8_t * ptr = data + pos * 8 ;
const uint8_t * ptr = m_ data + pos * 8 ;
return ( ( uint64_t ) ptr [ 0 ] ) | \
return ( ( uint64_t ) ptr [ 0 ] ) | \
( ( uint64_t ) ptr [ 1 ] ) < < 8 | \
( ( uint64_t ) ptr [ 1 ] ) < < 8 | \
( ( uint64_t ) ptr [ 2 ] ) < < 16 | \
( ( uint64_t ) ptr [ 2 ] ) < < 16 | \
@ -92,13 +92,13 @@ public:
template < typename Stream >
template < typename Stream >
void Serialize ( Stream & s ) const
void Serialize ( Stream & s ) const
{
{
s . write ( ( char * ) data, sizeof ( data) ) ;
s . write ( ( char * ) m_ data, sizeof ( m_ data) ) ;
}
}
template < typename Stream >
template < typename Stream >
void Unserialize ( Stream & s )
void Unserialize ( Stream & s )
{
{
s . read ( ( char * ) data, sizeof ( data) ) ;
s . read ( ( char * ) m_ data, sizeof ( m_ data) ) ;
}
}
} ;
} ;