Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Static Private Member Functions | Private Attributes | List of all members
gnsstk::BinexData Class Reference

Detailed Description

This class stores, reads, and writes BINEX records.

See also
binex_read_write.cpp for an example.
binex_test.cpp for an example.
BinexStream.

Definition at line 65 of file BinexData.hpp.

#include <BinexData.hpp>

Inheritance diagram for gnsstk::BinexData:
Inheritance graph
[legend]

Classes

class  MGFZI
 
class  UBNXI
 

Public Types

enum  recordFlagsEnum { eReverseReadable = 0x10, eBigEndian = 0x20, eEnhancedCRC = 0x08 }
 0x38 More...
 
typedef uint32_t RecordID
 Record ID type. More...
 
typedef uint8_t SyncByte
 Synchronization byte (record flags) More...
 

Public Member Functions

 BinexData ()
 
 BinexData (const BinexData &other)
 
 BinexData (RecordID recordID, SyncByte recordFlags=DEFAULT_RECORD_FLAGS) noexcept
 
BinexDataclearMessage ()
 
virtual void dump (std::ostream &s) const
 
BinexDataensureMessageCapacity (size_t cap)
 
void extractMessageData (size_t &offset, MGFZI &data)
 
void extractMessageData (size_t &offset, std::string &data, size_t size) const
 
template<class T >
void extractMessageData (size_t &offset, T &data, size_t size) const
 
void extractMessageData (size_t &offset, UBNXI &data)
 
size_t getHeadLength () const
 
const std::string & getMessageData () const
 
size_t getMessageLength () const
 
virtual size_t getRecord (std::istream &s)
 
SyncByte getRecordFlags () const
 
RecordID getRecordID () const
 
size_t getRecordSize () const
 
size_t getTailLength () const
 
virtual bool isData (void) const
 
BinexDataoperator= (const BinexData &right)
 
bool operator== (const BinexData &b) const
 
virtual void putRecord (std::ostream &s) const
 
BinexDatasetRecordFlags (SyncByte flags=DEFAULT_RECORD_FLAGS)
 
BinexDatasetRecordID (RecordID id)
 
BinexDataupdateMessageData (size_t &offset, const char *data, size_t size)
 
BinexDataupdateMessageData (size_t &offset, const MGFZI &data)
 
BinexDataupdateMessageData (size_t &offset, const std::string &data, size_t size)
 
template<class T >
BinexDataupdateMessageData (size_t &offset, const T &data, size_t size)
 
BinexDataupdateMessageData (size_t &offset, const UBNXI &data)
 
virtual ~BinexData ()
 
- Public Member Functions inherited from gnsstk::FFData
void getRecord (FFStream &s)
 
virtual bool isHeader () const
 
void putRecord (FFStream &s) const
 
virtual ~FFData (void)
 virtual desctuctor More...
 

Static Public Attributes

static const GNSSTK_EXPORT SyncByte DEFAULT_RECORD_FLAGS = 0x20
 0xFFFFFFFF More...
 
static const GNSSTK_EXPORT RecordID INVALID_RECORD_ID = 0xFFFFFFFF
 
static const GNSSTK_EXPORT bool nativeLittleEndian = true
 
static const GNSSTK_EXPORT SyncByte VALID_RECORD_FLAGS = 0x38
 0x20 More...
 

Protected Member Functions

void getCRC (const std::string &head, const std::string &message, std::string &crc) const
 
size_t getCRCLength (size_t crcDataLen) const
 
bool isHeadSyncByteValid (SyncByte headSync, SyncByte &expectedTailSync) const
 
bool isTailSyncByteValid (SyncByte tailSync, SyncByte &expectedHeadSync) const
 
virtual void reallyGetRecord (FFStream &s)
 
virtual void reallyPutRecord (FFStream &s) const
 

Static Protected Member Functions

static unsigned long long parseBuffer (const std::string &buffer, size_t offset, size_t size)
 

Static Private Member Functions

static void reverseBuffer (std::string &buffer, size_t offset=0, size_t n=std::string::npos)
 
template<class T >
static void reverseBytes (T &val)
 

Private Attributes

std::string msg
 Record message (opaque) More...
 
RecordID recID
 Record ID. More...
 
SyncByte syncByte
 Flags for endianness, CRC, etc. More...
 

Member Typedef Documentation

◆ RecordID

typedef uint32_t gnsstk::BinexData::RecordID

Record ID type.

Definition at line 72 of file BinexData.hpp.

◆ SyncByte

typedef uint8_t gnsstk::BinexData::SyncByte

Synchronization byte (record flags)

Definition at line 73 of file BinexData.hpp.

Member Enumeration Documentation

◆ recordFlagsEnum

0x38

Enumerator
eReverseReadable 
eBigEndian 
eEnhancedCRC 

Definition at line 84 of file BinexData.hpp.

Constructor & Destructor Documentation

◆ BinexData() [1/3]

gnsstk::BinexData::BinexData ( )

Default constructor

Definition at line 913 of file BinexData.cpp.

◆ BinexData() [2/3]

gnsstk::BinexData::BinexData ( const BinexData other)

Copy constructor

Definition at line 921 of file BinexData.cpp.

◆ BinexData() [3/3]

gnsstk::BinexData::BinexData ( RecordID  recordID,
SyncByte  recordFlags = DEFAULT_RECORD_FLAGS 
)
noexcept

Convenience constructor

Definition at line 928 of file BinexData.cpp.

◆ ~BinexData()

virtual gnsstk::BinexData::~BinexData ( )
inlinevirtual

Destructor

Definition at line 505 of file BinexData.hpp.

Member Function Documentation

◆ clearMessage()

BinexData & gnsstk::BinexData::clearMessage ( )

Remove all data from the record message buffer.

Definition at line 1012 of file BinexData.cpp.

◆ dump()

void gnsstk::BinexData::dump ( std::ostream &  s) const
virtual

A debug output function.

Reimplemented from gnsstk::FFData.

Definition at line 1712 of file BinexData.cpp.

◆ ensureMessageCapacity()

BinexData & gnsstk::BinexData::ensureMessageCapacity ( size_t  cap)

Reserves a number of bytes for storage of the record message. This number can grow as data is added to the message, but an adequate initial number results in greater efficiency. The actual length of the data in the message buffer is a separate and strictly smaller amount.

Exceptions
InvalidParameter

Definition at line 1021 of file BinexData.cpp.

◆ extractMessageData() [1/4]

void gnsstk::BinexData::extractMessageData ( size_t &  offset,
MGFZI data 
)

Extracts a MGFZI from the message buffer. The location within the message buffer is set by the offset parameter. After extracting the MGFZI from the message buffer, the value of the offset parameter is updated by the MGFZI's size to reference the next available byte in the message buffer.

Parameters
offsetLocation within the message buffer at which to extract
dataLocation to store the extracted data
Exceptions
FFStreamError
InvalidParameter

Definition at line 1129 of file BinexData.cpp.

◆ extractMessageData() [2/4]

void gnsstk::BinexData::extractMessageData ( size_t &  offset,
std::string &  data,
size_t  size 
) const

Extracts raw data from the message buffer. The location within the message buffer is set by the offset parameter, and the size of the data to extract is set by the size parameter. This method checks to ensure that all data is extracted from within the message buffer. After extracting data from the message buffer, the value of the offset parameter is updated by size to reference the next available byte in the message buffer.

Parameters
offsetLocation within the message buffer at which to extract
dataLocation to store the extracted data
sizeNumber of bytes of data to be extracted
Exceptions
InvalidParameter

Definition at line 1147 of file BinexData.cpp.

◆ extractMessageData() [3/4]

template<class T >
void gnsstk::BinexData::extractMessageData ( size_t &  offset,
T &  data,
size_t  size 
) const
inline

Extracts data from the message buffer. The location within the message buffer is set by the offset parameter, and the size of the data to extract is set by the size parameter. This method checks to ensure that the value of the size parameter does not exceed sizeof(T) and that all data is extracted from within the message buffer. After extracting data from the message buffer, the value of the offset parameter is updated by size to reference the next available byte in the message buffer.

Parameters
offsetLocation within the message buffer at which to extract
dataLocation to store the extracted data
sizeNumber of bytes of data to be extracted
Exceptions
FFStreamError
InvalidParameter

Definition at line 836 of file BinexData.hpp.

◆ extractMessageData() [4/4]

void gnsstk::BinexData::extractMessageData ( size_t &  offset,
UBNXI data 
)

Extracts a UBNXI from the message buffer. The location within the message buffer is set by the offset parameter. After extracting the UBNXI from the message buffer, the value of the offset parameter is updated by the UBNXI's size to reference the next available byte in the message buffer.

Parameters
offsetLocation within the message buffer at which to extract
dataLocation to store the extracted data
Exceptions
FFStreamError
InvalidParameter

Definition at line 1111 of file BinexData.cpp.

◆ getCRC()

void gnsstk::BinexData::getCRC ( const std::string &  head,
const std::string &  message,
std::string &  crc 
) const
protected
Parameters
bufsA NULL-terminated list of pointers to byte buffers
bufLensA list of lengths for the buffers specified by bufs
crcA pointer to the buffer in which to store the CRC
crcLenThe number of bytes used to store the CRC

Definition at line 1428 of file BinexData.cpp.

◆ getCRCLength()

size_t gnsstk::BinexData::getCRCLength ( size_t  crcDataLen) const
protected

Returns the number of bytes required to store the record's CRC based on the record's current contents.

Definition at line 1530 of file BinexData.cpp.

◆ getHeadLength()

size_t gnsstk::BinexData::getHeadLength ( ) const

Returns the current length of the record head, i.e. the combined length of the synchronization byte, the record ID, and the message length. In other words, the returned length is the offset of the message data from the start of the record.

Returns
Record head length in bytes

Definition at line 1037 of file BinexData.cpp.

◆ getMessageData()

const std::string& gnsstk::BinexData::getMessageData ( ) const
inline

Returns a pointer to the raw message data. Note that the format of the data is dependent upon the record flags at the time the data was added to the message.

Definition at line 640 of file BinexData.hpp.

◆ getMessageLength()

size_t gnsstk::BinexData::getMessageLength ( ) const
inline

Returns the length of the data in the record message buffer (which is separate from the record message buffer's capacity).

Returns
Record message data length in bytes

Definition at line 615 of file BinexData.hpp.

◆ getRecord()

size_t gnsstk::BinexData::getRecord ( std::istream &  s)
virtual

Retrieves a BINEX record from the specified generic input stream.

Returns
the number of bytes parsed in the stream.
Exceptions
std::exception
FFStreamError
StringUtils::StringException

Definition at line 1267 of file BinexData.cpp.

◆ getRecordFlags()

SyncByte gnsstk::BinexData::getRecordFlags ( ) const
inline

Returns flags indicating endianness, reversability, and CRC-mode of the current record. The individual flags can be extracted from the returned value by AND-ing with values from recordFlagsEnum.

Definition at line 536 of file BinexData.hpp.

◆ getRecordID()

RecordID gnsstk::BinexData::getRecordID ( ) const
inline

Returns the ID of this BINEX record.

Definition at line 561 of file BinexData.hpp.

◆ getRecordSize()

size_t gnsstk::BinexData::getRecordSize ( ) const

Returns the number of bytes required to represent the entire record (based on the record's current contents).

Definition at line 989 of file BinexData.cpp.

◆ getTailLength()

size_t gnsstk::BinexData::getTailLength ( ) const
inline

Returns the current length of the record tail, i.e. the combined length of the CRC, the optional reverse length, and the optional synchronization byte. In other words, the returned length is the number of bytes in the record following the message data.

Returns
Record tail length in bytes

Definition at line 629 of file BinexData.hpp.

◆ isData()

virtual bool gnsstk::BinexData::isData ( void  ) const
inlinevirtual

BinexData is "data" so this function always returns true.

Reimplemented from gnsstk::FFData.

Definition at line 511 of file BinexData.hpp.

◆ isHeadSyncByteValid()

bool gnsstk::BinexData::isHeadSyncByteValid ( SyncByte  headSync,
SyncByte expectedTailSync 
) const
protected

Determines whether the supplied head sync byte is valid an returns an expected correosponding tail sync byte if appropriate.

Definition at line 1575 of file BinexData.cpp.

◆ isTailSyncByteValid()

bool gnsstk::BinexData::isTailSyncByteValid ( SyncByte  tailSync,
SyncByte expectedHeadSync 
) const
protected

Determines whether the supplied tail sync byte is valid an returns an expected correosponding head sync byte.

Definition at line 1611 of file BinexData.cpp.

◆ operator=()

BinexData & gnsstk::BinexData::operator= ( const BinexData right)

Copies another BinexData object.

Definition at line 939 of file BinexData.cpp.

◆ operator==()

bool gnsstk::BinexData::operator== ( const BinexData b) const

Compares two BinexData objects.

Parameters
bBinexData object to compare to this object

Definition at line 948 of file BinexData.cpp.

◆ parseBuffer()

unsigned long long gnsstk::BinexData::parseBuffer ( const std::string &  buffer,
size_t  offset,
size_t  size 
)
staticprotected

Converts a raw sequence of bytes into an unsigned long long integer.

Parameters
bufferRaw bytes to convert
offsetPosition at which to begin conversion
sizeNumber of bytes to convert
Returns
Result of converting raw bytes to an unsigned integer
Exceptions
FFStreamError

Definition at line 1640 of file BinexData.cpp.

◆ putRecord()

void gnsstk::BinexData::putRecord ( std::ostream &  s) const
virtual

Writes the BINEX data to the specified generic output stream.

Exceptions
std::exception
FFStreamError
StringUtils::StringException

Definition at line 1179 of file BinexData.cpp.

◆ reallyGetRecord()

void gnsstk::BinexData::reallyGetRecord ( FFStream s)
protectedvirtual

This function retrieves a BINEX record from the given FFStream. If an error is encountered in reading from the stream, the stream is returned to its original position and its fail-bit is set.

Exceptions
std::exception
StringUtils::StringExceptionwhen a StringUtils function fails
FFStreamErrorwhen exceptions(failbit) is set and a read or formatting error occurs. This also resets the stream to its pre-read position.

Implements gnsstk::FFData.

Definition at line 1255 of file BinexData.cpp.

◆ reallyPutRecord()

void gnsstk::BinexData::reallyPutRecord ( FFStream s) const
protectedvirtual

Writes the BINEX data to the file stream formatted correctly.

Exceptions
std::exception
FFStreamError
StringUtils::StringException

Implements gnsstk::FFData.

Definition at line 1166 of file BinexData.cpp.

◆ reverseBuffer()

void gnsstk::BinexData::reverseBuffer ( std::string &  buffer,
size_t  offset = 0,
size_t  n = std::string::npos 
)
staticprivate

Reverses the order of the first bufferLength bytes in the specified buffer.

Parameters
bufferString containing bytes to reverse
offsetStarting position of bytes to reverse
nNumber of bytes to reverse

Definition at line 1683 of file BinexData.cpp.

◆ reverseBytes()

template<class T >
void gnsstk::BinexData::reverseBytes ( T &  val)
staticprivate

Definition at line 1670 of file BinexData.cpp.

◆ setRecordFlags()

BinexData & gnsstk::BinexData::setRecordFlags ( SyncByte  flags = DEFAULT_RECORD_FLAGS)

Sets the endianness, reversability, and CRC-mode of the record. The "flags" paramater should be set by OR-ing together values from recordFlagsEnum enumeration. Invalid bits in "flag" are silently ignored.

WARNING: Since the record flags determine how data is stored in the record message buffer, altering the record flags after data has been placed in the message buffer could result in misinterpretation of that data. Doing so is therefore highly discouraged.

Definition at line 974 of file BinexData.cpp.

◆ setRecordID()

BinexData & gnsstk::BinexData::setRecordID ( RecordID  id)

Sets the ID of this BINEX record.

Exceptions
FFStreamError

Definition at line 958 of file BinexData.cpp.

◆ updateMessageData() [1/5]

BinexData & gnsstk::BinexData::updateMessageData ( size_t &  offset,
const char *  data,
size_t  size 
)

Updates the message buffer with the specified raw data. The location within the message buffer is set by the offset parameter, and the size of the data to copy is set by the size parameter. After updating the message buffer, the value of the offset parameter is updated by size to reference the next available byte in the message buffer.

Parameters
offsetLocation within the message buffer at which to update
dataRaw data with which to update the message buffer
sizeNumber of bytes of data to be copied
Exceptions
FFStreamError
InvalidParameter

Definition at line 1098 of file BinexData.cpp.

◆ updateMessageData() [2/5]

BinexData & gnsstk::BinexData::updateMessageData ( size_t &  offset,
const MGFZI data 
)

Updates the message buffer with the specified MGFZI. The location within the message buffer is set by the offset parameter. This method checks to ensure that all data fits within the message buffer. After updating the message buffer, the value of the offset parameter is updated by size to reference the next available byte in the message buffer.

Parameters
offsetLocation within the message buffer at which to update
dataData with which to update the message buffer
Exceptions
FFStreamError
InvalidParameter

Definition at line 1064 of file BinexData.cpp.

◆ updateMessageData() [3/5]

BinexData & gnsstk::BinexData::updateMessageData ( size_t &  offset,
const std::string &  data,
size_t  size 
)

Updates the message buffer with the specified raw data. The location within the message buffer is set by the offset parameter, and the size of the data to copy is set by the size parameter. After updating the message buffer, the value of the offset parameter is updated by size to reference the next available byte in the message buffer.

Parameters
offsetLocation within the message buffer at which to update
dataRaw data with which to update the message buffer
sizeNumber of bytes of data to be copied
Exceptions
FFStreamError
InvalidParameter

Definition at line 1077 of file BinexData.cpp.

◆ updateMessageData() [4/5]

template<class T >
BinexData& gnsstk::BinexData::updateMessageData ( size_t &  offset,
const T &  data,
size_t  size 
)
inline

Updates the message buffer with the specified data. The location within the message buffer is set by the offset parameter, and the size of the data to copy is set by the size parameter. This method checks to ensure that the value of the size parameter does not exceed sizeof(T) and that all data fits within the message buffer. After updating the message buffer, the value of the offset parameter is updated by size to reference the next available byte in the message buffer.

Parameters
offsetLocation within the message buffer at which to update
dataData with which to update the message buffer
sizeNumber of bytes of data to be copied
Exceptions
FFStreamError
InvalidParameter

Definition at line 739 of file BinexData.hpp.

◆ updateMessageData() [5/5]

BinexData & gnsstk::BinexData::updateMessageData ( size_t &  offset,
const UBNXI data 
)

Updates the message buffer with the specified UBNXI. The location within the message buffer is set by the offset parameter. This method checks to ensure that all data fits within the message buffer. After updating the message buffer, the value of the offset parameter is updated by size to reference the next available byte in the message buffer.

Parameters
offsetLocation within the message buffer at which to update
dataData with which to update the message buffer
Exceptions
FFStreamError
InvalidParameter

Definition at line 1051 of file BinexData.cpp.

Member Data Documentation

◆ DEFAULT_RECORD_FLAGS

const BinexData::SyncByte gnsstk::BinexData::DEFAULT_RECORD_FLAGS = 0x20
static

0xFFFFFFFF

Definition at line 77 of file BinexData.hpp.

◆ INVALID_RECORD_ID

const BinexData::RecordID gnsstk::BinexData::INVALID_RECORD_ID = 0xFFFFFFFF
static

Definition at line 75 of file BinexData.hpp.

◆ msg

std::string gnsstk::BinexData::msg
private

Record message (opaque)

Definition at line 975 of file BinexData.hpp.

◆ nativeLittleEndian

const bool gnsstk::BinexData::nativeLittleEndian = true
static

Definition at line 70 of file BinexData.hpp.

◆ recID

RecordID gnsstk::BinexData::recID
private

Record ID.

Definition at line 974 of file BinexData.hpp.

◆ syncByte

SyncByte gnsstk::BinexData::syncByte
private

Flags for endianness, CRC, etc.

Definition at line 973 of file BinexData.hpp.

◆ VALID_RECORD_FLAGS

const BinexData::SyncByte gnsstk::BinexData::VALID_RECORD_FLAGS = 0x38
static

0x20

Definition at line 78 of file BinexData.hpp.


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


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:44