BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlde::Crc32 Class Reference

#include <bdlde_crc32.h>

Public Member Functions

 Crc32 ()
 
 Crc32 (const void *data, bsl::size_t length)
 
 Crc32 (const Crc32 &original)
 
 ~Crc32 ()=default
 Destroy this object.
 
Crc32operator= (const Crc32 &rhs)
 
template<class STREAM >
STREAM & bdexStreamIn (STREAM &stream, int version)
 
unsigned int checksumAndReset ()
 
void reset ()
 
void update (const void *data, bsl::size_t length)
 
template<class STREAM >
STREAM & bdexStreamOut (STREAM &stream, int version) const
 
unsigned int checksum () const
 Return the current value of this checksum.
 
bsl::ostream & print (bsl::ostream &stream) const
 
unsigned int view () const
 

Static Public Member Functions

static int maxSupportedBdexVersion (int versionSelector)
 
static int maxSupportedBdexVersion ()
 

Friends

bool operator== (const Crc32 &, const Crc32 &)
 

Detailed Description

This class represents a CRC-32 checksum value that can be updated as data is provided.

More generally, this class supports a complete set of value semantic operations, including copy construction, assignment, equality comparison, ostream printing, and bdex serialization. (A precise operational definition of when two objects have the same value can be found in the description of operator== for the class.) This class is exception neutral with no guarantee of rollback: if an exception is thrown during the invocation of a method on a pre-existing object, the class is left in a valid state, but its value is undefined. In no event is memory leaked. Finally, aliasing (e.g., using all or part of an object as both source and destination) is supported in all cases.

See bdlde_crc32

Constructor & Destructor Documentation

◆ Crc32() [1/3]

bdlde::Crc32::Crc32 ( )
inline

Construct a checksum having the value corresponding to no data having been provided (i.e., having the value 0).

◆ Crc32() [2/3]

bdlde::Crc32::Crc32 ( const void *  data,
bsl::size_t  length 
)
inline

Construct a checksum corresponding to the specified data having the specified length (in bytes). Note that if data is 0, then length also must be 0.

◆ Crc32() [3/3]

bdlde::Crc32::Crc32 ( const Crc32 original)
inline

Construct a checksum having the value of the specified original checksum.

◆ ~Crc32()

bdlde::Crc32::~Crc32 ( )
default

Member Function Documentation

◆ bdexStreamIn()

template<class STREAM >
STREAM & bdlde::Crc32::bdexStreamIn ( STREAM &  stream,
int  version 
)

Assign to this object the value read from the specified input stream using the specified version format, and return a reference to stream. If stream is initially invalid, this operation has no effect. If version is not supported, this object is unaltered and stream is invalidated but otherwise unmodified. If version is supported but stream becomes invalid during this operation, this object has an undefined, but valid, state. Note that no version is read from stream. See the bslx package-level documentation for more information on BDEX streaming of value-semantic types and containers.

◆ bdexStreamOut()

template<class STREAM >
STREAM & bdlde::Crc32::bdexStreamOut ( STREAM &  stream,
int  version 
) const

Write this value to the specified output stream using the specified version format, and return a reference to stream. If stream is initially invalid, this operation has no effect. If version is not supported, stream is invalidated but otherwise unmodified. Note that version is not written to stream. See the bslx package-level documentation for more information on BDEX streaming of value-semantic types and containers.

◆ checksum()

unsigned int bdlde::Crc32::checksum ( ) const
inline

◆ checksumAndReset()

unsigned int bdlde::Crc32::checksumAndReset ( )
inline

Return the current value of this checksum and set the value of this checksum to the value the default constructor provides.

◆ maxSupportedBdexVersion() [1/2]

int bdlde::Crc32::maxSupportedBdexVersion ( )
inlinestatic

Return the most current bdex streaming version number supported by this class. (See the package-group-level documentation for more information on bdex streaming of container types.)

◆ maxSupportedBdexVersion() [2/2]

int bdlde::Crc32::maxSupportedBdexVersion ( int  versionSelector)
inlinestatic

Return the maximum valid BDEX format version, as indicated by the specified versionSelector, to be passed to the bdexStreamOut method. Note that the versionSelector is expected to be formatted as yyyymmdd, a date representation. See the bslx package-level documentation for more information on BDEX streaming of value-semantic types and containers.

◆ operator=()

Crc32 & bdlde::Crc32::operator= ( const Crc32 rhs)
inline

Assign to this checksum the value of the specified rhs checksum, and return a reference to this modifiable checksum.

◆ print()

bsl::ostream & bdlde::Crc32::print ( bsl::ostream &  stream) const

Format this object to the specified output stream at the (absolute value of) the optionally specified indentation level and return a reference to stream. If level is specified, optionally specify spacesPerLevel, the number of spaces per indentation level for this and all of its nested objects. If level is negative, suppress indentation of the first line. If spacesPerLevel is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by level). If stream is not valid on entry, this operation has no effect.

◆ reset()

void bdlde::Crc32::reset ( )
inline

Reset the value of this checksum to the value the default constructor provides.

◆ update()

void bdlde::Crc32::update ( const void *  data,
bsl::size_t  length 
)

Update the value of this checksum to incorporate the specified data having the specified length. If the current state is the default state, the resultant value of this checksum is the application of the CRC-32 algorithm upon the currently given data of the given length. If this checksum has been previously provided data and has not been subsequently reset, the current state is not the default state and the resultant value is equivalent to applying the CRC-32 algorithm upon the concatenation of all the provided data. Note that if data is 0, then length also must be 0.

◆ view()

unsigned int bdlde::Crc32::view ( ) const
inline

Return the current value of this checksum.

Deprecated:
use method checksum instead.

Friends And Related Symbol Documentation

◆ operator==

bool operator== ( const Crc32 ,
const Crc32  
)
friend

Return true if the specified lhs and rhs checksums have the same value, and false otherwise. Two checksums have the same value if the values obtained from their checksum methods are identical.


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