LibCppBinary
Modern cross-platform C++ binary parsing library
Loading...
Searching...
No Matches
Binary::DataStructure Struct Referenceabstract

Abstract base struct representing data structure in binary file. More...

#include <DataStructure.h>

Inheritance diagram for Binary::DataStructure:
Binary::ChunkHeader

Public Member Functions

virtual std::vector< DataField * > Fields ()=0
 Provides a vector of raw pointers to the structure's fields.
virtual std::vector< const DataField * > Fields () const =0
 Provides a vector of read-only raw pointers to the fields.
virtual size_t Size () const =0
 Gets the total size of all fields in the structure.

Detailed Description

Abstract base struct representing data structure in binary file.

Structs that represent a data structure in a binary file should derive from this struct. The Binary::Stream class accepts pointers to instances of DataStructure for reading and writing data structures to binary data sources. By properly inheriting from this struct, the Binary::Stream class and its derivatives will automatically support reading and writing your derived type.

This provides an interface for a binary data structures. It is recommended that the derived implementations follow these guidelines:

1) Make fields available as public struct members for general access. 2) Fields() should return a vector of pointers to the struct members in the order that they should be read from and written to files. 3) Size() should sum all of the field sizes.

Member Function Documentation

◆ Fields() [1/2]

virtual std::vector< const DataField * > Binary::DataStructure::Fields ( ) const
pure virtual

Provides a vector of read-only raw pointers to the fields.

This method is primarily intended for use by Binary::Stream and its derivatives for reading the fields from and to those streams. Access the fields directly rather than via this method.

Returns
A vector containing read-only raw pointers to fields owned by this structure.
Postcondition
Returned pointers remain valid while this structure exists.

Implemented in Binary::ChunkHeader.

◆ Fields() [2/2]

virtual std::vector< DataField * > Binary::DataStructure::Fields ( )
pure virtual

Provides a vector of raw pointers to the structure's fields.

This method is primarily intended for use by Binary::Stream and its derivatives for reading the fields from and to those streams. Access the fields directly rather than via this method.

Returns
A vector containing raw pointers to fields owned by this structure.
Postcondition
Returned pointers remain valid while this structure exists.

Implemented in Binary::ChunkHeader.

◆ Size()

virtual size_t Binary::DataStructure::Size ( ) const
pure virtual

Gets the total size of all fields in the structure.

Returns
The total size of the structure.

Implemented in Binary::ChunkHeader.


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