C++ bindings for cgul_crc16
More...
#include <cgul_crc16_cxx.h>
|
| cgul_crc16_cxx (unsigned short g, unsigned short init, unsigned short final_xor, int reflected) |
|
| cgul_crc16_cxx (unsigned short g, unsigned short init, unsigned short final_xor, int reflected, size_t size_xor) |
|
virtual | ~cgul_crc16_cxx () |
|
virtual void | assign (cgul_crc16_cxx *rhs) |
|
virtual unsigned short | crc () |
|
virtual unsigned short | crc_block (const void *block, size_t length) |
|
virtual unsigned short | crc_range_of_block (const void *block, size_t offset, size_t length) |
|
virtual unsigned long | crc_file (FILE *f) |
|
virtual unsigned long | crc_fname (const char *fname) |
|
virtual void | update_byte (unsigned char c) |
|
virtual void | update_block (const void *block, size_t length) |
|
virtual void | update_range_of_block (const void *block, size_t offset, size_t length) |
|
virtual void | update_file (FILE *f) |
|
virtual void | update_fname (const char *fname) |
|
virtual void | reset () |
|
virtual char * | get_table_as_string () const |
|
virtual cgul_crc16_t | get_obj () const |
|
virtual cgul_crc16_t | take_obj () |
|
virtual void | set_obj (cgul_crc16_t rhs) |
|
This class provides the C++ bindings for C cgul_crc16
objects. The main purpose of this class is to convert the C-style function calls and exception handling in cgul_crc16
into C++-style function calls and exception handling.
§ cgul_crc16_cxx() [1/2]
cgul_crc16_cxx::cgul_crc16_cxx |
( |
unsigned short |
g, |
|
|
unsigned short |
init, |
|
|
unsigned short |
final_xor, |
|
|
int |
reflected |
|
) |
| |
|
inline |
Create a new cgul_crc16_cxx
object. Objects created with this constructor do not append the size to the data stream that is CRCed. If memory cannot be allocated, an exception is thrown.
- Parameters
-
[in] | g | generator polynomial |
[in] | init | initial value loaded into the accumulator |
[in] | final_xor | value to xor with the calculated crc |
[in] | reflected | whether to use the reflected algorithm |
References cgul_crc16__new().
§ cgul_crc16_cxx() [2/2]
cgul_crc16_cxx::cgul_crc16_cxx |
( |
unsigned short |
g, |
|
|
unsigned short |
init, |
|
|
unsigned short |
final_xor, |
|
|
int |
reflected, |
|
|
size_t |
size_xor |
|
) |
| |
|
inline |
Create a new cgul_crc16
object. Objects created with this constructor append the size to the data stream that is CRCed. If memory cannot be allocated, an exception is thrown.
- Parameters
-
[in] | g | polynomial |
[in] | init | initial value loaded into the accumulator |
[in] | final_xor | value to xor with the calculated crc |
[in] | reflected | whether to use the reflected algorithm |
[in] | size_xor | value to xor with the size before appending |
References cgul_crc16__new_appends_size().
§ ~cgul_crc16_cxx()
virtual cgul_crc16_cxx::~cgul_crc16_cxx |
( |
| ) |
|
|
inlinevirtual |
§ assign()
Assign the current accumulator and size of rhs
to this object. This operation probably only makes sense if this object and rhs
have been constructed identically. If an error occurs, an exception is thrown.
- Parameters
-
References cgul_crc16__assign().
§ crc()
virtual unsigned short cgul_crc16_cxx::crc |
( |
| ) |
|
|
inlinevirtual |
This method completes the CRC calculation by performing the size XOR and the final XOR. You will generally call one of the update() methods before calling this method. When this method returns, the internal state of the object is reset so that it is ready to calculate the next CRC. The return value is the final value for the CRC.
- Returns
- final crc value
References cgul_crc16__crc().
§ crc_block()
virtual unsigned short cgul_crc16_cxx::crc_block |
( |
const void * |
block, |
|
|
size_t |
length |
|
) |
| |
|
inlinevirtual |
This is the method to call when you only have one block for which you want to calculate a CRC. You can also call this if you have called one of the update() methods before, and you know that block
is your last block. When this method returns, the internal state of the object is reset so that it is ready to calculate the next CRC. length
is the number of bytes inside of block
that you want to add to the CRC calculation. The return value is the final value for the CRC.
- Parameters
-
[in] | block | block of data to add to the crc |
[in] | length | length of block |
- Returns
- final crc value
References cgul_crc16__crc_block().
§ crc_range_of_block()
virtual unsigned short cgul_crc16_cxx::crc_range_of_block |
( |
const void * |
block, |
|
|
size_t |
offset, |
|
|
size_t |
length |
|
) |
| |
|
inlinevirtual |
This is the method to call when you want to calculate the CRC from a range of bytes from one block. You can also call this if you have called one of the update() methods before, and you know that block
is your last block. When this method returns, the internal state of the object is reset so that it is ready to calculate the next CRC. offset
is the index into block
where you want to add length
bytes to the CRC calculation. The return value is the final value for the CRC.
- Parameters
-
[in] | block | block of data to add to the crc |
[in] | offset | offset into block |
[in] | length | length of block |
- Returns
- final crc value
References cgul_crc16__crc_range_of_block().
§ crc_file()
virtual unsigned long cgul_crc16_cxx::crc_file |
( |
FILE * |
f | ) |
|
|
inlinevirtual |
This is the method to call when you only have one file for which you want to calculate a CRC. You can also call this if you have called one of the update() methods before (like cgul_crc16_cxx::update_file()
), and you know that f
is your last file. When this method returns, the internal state of the object is reset so that it is ready to calculate the next CRC. The return value is the final value for the CRC.
- Parameters
-
- Returns
- final crc value
References cgul_crc16__crc_file().
§ crc_fname()
virtual unsigned long cgul_crc16_cxx::crc_fname |
( |
const char * |
fname | ) |
|
|
inlinevirtual |
This is the method to call when you only have one file for which you want to calculate a CRC. You can also call this if you have called one of the update() methods before (like cgul_crc16_cxx::update_fname()
), and you know that fname
is your last file. When this method returns, the internal state of the object is reset so that it is ready to calculate the next CRC. The return value is the final value for the CRC.
- Parameters
-
- Returns
- final crc value
References cgul_crc16__crc_fname().
§ update_byte()
virtual void cgul_crc16_cxx::update_byte |
( |
unsigned char |
c | ) |
|
|
inlinevirtual |
§ update_block()
virtual void cgul_crc16_cxx::update_block |
( |
const void * |
block, |
|
|
size_t |
length |
|
) |
| |
|
inlinevirtual |
This method updates the CRC by adding all the bytes in block
to the calculation.
- Parameters
-
[in] | block | block of data to add to the crc |
[in] | length | length of block |
References cgul_crc16__update_block().
§ update_range_of_block()
virtual void cgul_crc16_cxx::update_range_of_block |
( |
const void * |
block, |
|
|
size_t |
offset, |
|
|
size_t |
length |
|
) |
| |
|
inlinevirtual |
This method updates the CRC by adding a range of bytes in block
to the calculation. The range starts at offset
and extends length
bytes.
- Parameters
-
[in] | block | block of data to add to the crc |
[in] | offset | offset into block |
[in] | length | length of block |
References cgul_crc16__update_range_of_block().
§ update_file()
virtual void cgul_crc16_cxx::update_file |
( |
FILE * |
f | ) |
|
|
inlinevirtual |
This method updates the CRC by adding all the bytes (starting at the current offset) in the file f
to the calculation. If an error occurs, an exception is thrown.
- Parameters
-
References cgul_crc16__update_file().
§ update_fname()
virtual void cgul_crc16_cxx::update_fname |
( |
const char * |
fname | ) |
|
|
inlinevirtual |
This method updates the CRC by adding all the bytes in the file with name fname
to the calculation. If an error occurs, an exception is thrown.
- Parameters
-
References cgul_crc16__update_fname().
§ reset()
virtual void cgul_crc16_cxx::reset |
( |
| ) |
|
|
inlinevirtual |
§ get_table_as_string()
virtual char* cgul_crc16_cxx::get_table_as_string |
( |
| ) |
const |
|
inlinevirtual |
You can use this method to see the CRC lookup table that is being used. The returned value is the CRC lookup table for this object as a string. The caller is responsible for calling free() on the string that is returned.
- Returns
- crc lookup table as a string
References cgul_crc16__get_table_as_string().
§ get_obj()
Get the underlying cgul_crc16
object.
- Returns
- underlying object
§ take_obj()
Take the underlying cgul_crc16
object. This means the underlying object will not be deleted when the wrapper goes out of scope. Also, because you have taken the underlying object, no other methods should be called on this wrapper's instance. Lastly, after taking the underlying object, it is the caller's responsibility to delete the underlying object by calling cgul_crc16__delete()
.
- Returns
- underlying object
§ set_obj()
Set the new underlying object to rhs
. This causes the old underlying object to be deleted which invalidates any outstanding pointers to or iterators for the old underlying object.
This instance takes ownership of rhs
which means rhs
will be automatically deleted when the C++ wrapper is deleted. To prevent automatic deletion of rhs
, call take_obj()
when the C++ wrapper is no longer needed.
- Parameters
-
References cgul_crc16__delete().
The documentation for this class was generated from the following file: