|
LibCppBinary
Modern cross-platform C++ binary parsing library
|
Abstract base class representing a data field in a binary file. More...
#include <DataField.h>
Public Member Functions | |
| virtual | ~DataField ()=default |
| Default destructor; properly destroys the instance. | |
| virtual size_t | Size () const =0 |
| Gets the size of the data in the field. | |
| virtual char * | RawData ()=0 |
| Provides access to the field's raw data via pointer. | |
| virtual const char * | RawData () const =0 |
| Provides access to the field's raw data via const pointer. | |
| virtual void | CopyRawDataTo (DataField *other) |
| Copies the raw data to another DataField. | |
| virtual std::string | ToString () const =0 |
| Converts the field's data to a string representation. | |
| virtual std::string | ToString (StringFormat format) const =0 |
| Converts the field's data to a string representation. | |
Abstract base class representing a data field in a binary file.
Classes that represent a data field in a binary file should derive from this class. The Binary::Stream class accepts pointers to instances of DataField for reading and writing data fields to binary data sources. By properly inheriting from this class, the Binary::Stream class and its derivatives will automatically support reading and writing your derived type.
|
virtualdefault |
Default destructor; properly destroys the instance.
|
virtual |
Copies the raw data to another DataField.
This method copies the raw data to another DataField, truncating the data if the other field is smaller than this one.
| other | A pointer to the other DataField to copy the data to. |
| std::invalid_argument | if other is null. |
|
pure virtual |
Provides access to the field's raw data via const pointer.
Provides read-only access to the raw data stored in the field. Note that this class should manage the lifecycle of the data, so do not attempt to deallocate the memory behind the pointer manually.
Implemented in Binary::RawField.
|
pure virtual |
Provides access to the field's raw data via pointer.
Provides access to the raw data stored in the field. Note that this class should manage the lifecycle of the data, so do not attempt to deallocate the memory behind the pointer manually.
Implemented in Binary::RawField.
|
pure virtual |
Gets the size of the data in the field.
Implemented in Binary::RawField.
|
pure virtual |
Converts the field's data to a string representation.
Implemented in Binary::IntField< IntType, IntSize >, Binary::IntField< int16_t, 2 >, Binary::IntField< int32_t, 3 >, Binary::IntField< int32_t, 4 >, Binary::IntField< int64_t, 8 >, Binary::IntField< int8_t, 1 >, Binary::IntField< uint16_t, 2 >, Binary::IntField< uint32_t, 3 >, Binary::IntField< uint32_t, 4 >, Binary::IntField< uint64_t, 8 >, Binary::IntField< uint8_t, 1 >, Binary::RawField, and Binary::StringField.
|
pure virtual |
Converts the field's data to a string representation.
| format | The format to use for the string conversion. |
Implemented in Binary::IntField< IntType, IntSize >, Binary::IntField< int16_t, 2 >, Binary::IntField< int32_t, 3 >, Binary::IntField< int32_t, 4 >, Binary::IntField< int64_t, 8 >, Binary::IntField< int8_t, 1 >, Binary::IntField< uint16_t, 2 >, Binary::IntField< uint32_t, 3 >, Binary::IntField< uint32_t, 4 >, Binary::IntField< uint64_t, 8 >, Binary::IntField< uint8_t, 1 >, Binary::RawField, and Binary::StringField.