BinexData Class Reference
[Binex]

#include <BinexData.hpp>

Inheritance diagram for BinexData:

Inheritance graph
[legend]
Collaboration diagram for BinexData:

Collaboration graph
[legend]
List of all members.

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 52 of file BinexData.hpp.

Public Types

enum  recordFlagsEnum { eReverseReadable = 0x10, eBigEndian = 0x20, eEnhancedCRC = 0x08 }

Public Member Functions

 BinexData ()
 Default constructor.
 BinexData (const BinexData &other)
 Copy constructor.
 BinexData (unsigned long recordID, unsigned char recordFlags=DEFAULT_RECORD_FLAGS) throw ()
 Convenience constructor.
BinexDataoperator= (const BinexData &right)
 Copies another BinexData object.
virtual ~BinexData ()
 Destructor.
virtual bool isData (void) const
 BinexData is "data" so this function always returns true.
virtual void dump (std::ostream &s) const
 A debug output function.
bool operator== (const BinexData &b) const
 Compares two BinexData objects.
unsigned char getRecordFlags () const
 Returns flags indicating endianness, reversability, and CRC-mode of the current record.
BinexDatasetRecordFlags (unsigned char flags=DEFAULT_RECORD_FLAGS)
 Sets the endianness, reversability, and CRC-mode of the record.
unsigned long getRecordID () const
 Returns the ID of this BINEX record.
BinexDatasetRecordID (unsigned long id) throw (FFStreamError)
 Sets the ID of this BINEX record.
size_t getRecordSize () const
 Returns the number of bytes required to represent the entire record (based on the record's current contents).
BinexDataclearMessage ()
 Remove all data from the record message buffer.
BinexDataensureMessageCapacity (size_t cap) throw (FFStreamError)
 Reserves a number of bytes for storage of the record message.
size_t getMessageLength () const
 Returns the length of the data in the record message buffer (which is separate from the record message buffer's capacity).
size_t getMessageCapacity () const
 Returns the capacity of the record message buffer (which is separate from the lenth of the data in the buffer).
const std::string & getMessageData () const
 Returns a pointer to the raw message data.
BinexDataupdateMessageData (size_t &offset, const UBNXI &data) throw (FFStreamError, InvalidParameter)
 Updates the message buffer with the specified UBNXI.
BinexDataupdateMessageData (size_t &offset, const MGFZI &data) throw (FFStreamError, InvalidParameter)
 Updates the message buffer with the specified MGFZI.
BinexDataupdateMessageData (size_t &offset, const std::string &data, size_t size) throw (FFStreamError, InvalidParameter)
 Updates the message buffer with the specified raw data.
BinexDataupdateMessageData (size_t &offset, const char *data, size_t size) throw (FFStreamError, InvalidParameter)
 Updates the message buffer with the specified raw data.
template<class T>
BinexDataupdateMessageData (size_t &offset, const T &data, size_t size) throw (FFStreamError, InvalidParameter)
 Updates the message buffer with the specified data.
void extractMessageData (size_t &offset, UBNXI &data) throw (FFStreamError, InvalidParameter)
 Extacts a UBNXI from the message buffer.
void extractMessageData (size_t &offset, MGFZI &data) throw (FFStreamError, InvalidParameter)
 Extacts a MGFZI from the message buffer.
void extractMessageData (size_t &offset, std::string &data, size_t size) const throw (InvalidParameter)
 Extacts raw data from the message buffer.
template<class T>
void extractMessageData (size_t &offset, T &data, size_t size) const throw (FFStreamError, InvalidParameter)
 Extacts data from the message buffer.

Static Public Attributes

const bool nativeLittleEndian = true
const unsigned long INVALID_RECORD_ID = 0xFFFFFFFF
const unsigned char DEFAULT_RECORD_FLAGS = 0x20
const unsigned char VALID_RECORD_FLAGS = 0x38

Protected Member Functions

virtual void reallyPutRecord (FFStream &s) const throw (std::exception, FFStreamError, StringUtils::StringException)
 Writes the BINEX data to the file stream formatted correctly.
virtual void reallyGetRecord (FFStream &s) throw (std::exception, FFStreamError, StringUtils::StringException)
 This function retrieves a BINEX record from the given FFStream.
void getCRC (const std::string &head, const std::string &message, std::string &crc) const
size_t getCRCLength (size_t crcDataLen) const
 Returns the number of bytes required to store the record's CRC based on the record's current contents.
bool isHeadSyncByteValid (unsigned char headSync, unsigned char &expectedTailSync) const
 Determines whether the supplied head sync byte is valid an returns an expected correosponding tail sync byte if appropriate.
bool isTailSyncByteValid (unsigned char tailSync, unsigned char &expectedHeadSync) const
 Determines whether the supplied tail sync byte is valid an returns an expected correosponding head sync byte.

Static Protected Member Functions

unsigned long long parseBuffer (const std::string &buffer, size_t offset, size_t size) throw (FFStreamError)
 Converts a raw sequence of bytes into an unsigned long long integer.
void reverseBuffer (unsigned char *buffer, size_t bufferLength)
 Reverses the order of the first bufferLength bytes in the specified buffer.
void reverseBuffer (std::string &buffer, size_t offset=0, size_t n=std::string::npos)
 Reverses the order of the first bufferLength bytes in the specified buffer.

Protected Attributes

Attributes
unsigned char syncByte
 Flags for endianness, CRC, etc.
unsigned long recID
 Record ID.
std::string msg
 Record message (opaque).


Member Enumeration Documentation

enum recordFlagsEnum
 

Enumeration values:
eReverseReadable 
eBigEndian 
eEnhancedCRC 

Definition at line 72 of file BinexData.hpp.


Constructor & Destructor Documentation

BinexData  ) 
 

Default constructor.

Definition at line 900 of file BinexData.cpp.

References BinexData::recID, and BinexData::setRecordFlags().

BinexData const BinexData other  ) 
 

Copy constructor.

Definition at line 908 of file BinexData.cpp.

BinexData unsigned long  recordID,
unsigned char  recordFlags = DEFAULT_RECORD_FLAGS
throw ()
 

Convenience constructor.

Definition at line 915 of file BinexData.cpp.

virtual ~BinexData  )  [inline, virtual]
 

Destructor.

Definition at line 499 of file BinexData.hpp.


Member Function Documentation

BinexData & clearMessage  ) 
 

Remove all data from the record message buffer.

Definition at line 1006 of file BinexData.cpp.

References BinexData::msg.

void dump std::ostream &  s  )  const [virtual]
 

A debug output function.

Reimplemented from FFData.

Definition at line 1697 of file BinexData.cpp.

References BinexData::msg, BinexData::recID, and BinexData::syncByte.

BinexData & ensureMessageCapacity size_t  cap  )  throw (FFStreamError)
 

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.

Definition at line 1015 of file BinexData.cpp.

References GPSTK_THROW.

void extractMessageData size_t &  offset,
T &  data,
size_t  size
const throw (FFStreamError, InvalidParameter) [inline]
 

Extacts 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:
offset Location within the message buffer at which to extract
data Location to store the extracted data
size Number of bytes of data to be extracted

Definition at line 813 of file BinexData.hpp.

References GPSTK_THROW, and gpstk::BinUtils::twiddle().

void extractMessageData size_t &  offset,
std::string &  data,
size_t  size
const throw (InvalidParameter)
 

Extacts 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:
offset Location within the message buffer at which to extract
data Location to store the extracted data
size Number of bytes of data to be extracted

Definition at line 1134 of file BinexData.cpp.

References GPSTK_THROW.

void extractMessageData size_t &  offset,
MGFZI data
throw (FFStreamError, InvalidParameter)
 

Extacts 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:
offset Location within the message buffer at which to extract
data Location to store the extracted data

Definition at line 1115 of file BinexData.cpp.

References BinexData::UBNXI::decode(), and GPSTK_THROW.

void extractMessageData size_t &  offset,
UBNXI data
throw (FFStreamError, InvalidParameter)
 

Extacts 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:
offset Location within the message buffer at which to extract
data Location to store the extracted data

Definition at line 1096 of file BinexData.cpp.

References BinexData::UBNXI::decode(), and GPSTK_THROW.

void getCRC const std::string &  head,
const std::string &  message,
std::string &  crc
const [protected]
 

Parameters:
bufs A NULL-terminated list of pointers to byte buffers
bufLens A list of lengths for the buffers specified by bufs
crc A pointer to the buffer in which to store the CRC
crcLen The number of bytes used to store the CRC

Definition at line 1413 of file BinexData.cpp.

References gpstk::BinUtils::computeCRC(), CRCParam::initial, BinexData::UBNXI::size, BinexData::syncByte, and gpstk::BinUtils::twiddle().

size_t 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 1517 of file BinexData.cpp.

References BinexData::syncByte.

Referenced by BinexData::getRecordSize().

size_t getMessageCapacity  )  const [inline]
 

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

Returns:
Record message capacity in bytes

Definition at line 610 of file BinexData.hpp.

const std::string& 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 622 of file BinexData.hpp.

size_t 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 598 of file BinexData.hpp.

References BinexData::MGFZI::size.

unsigned char 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 530 of file BinexData.hpp.

unsigned long getRecordID  )  const [inline]
 

Returns the ID of this BINEX record.

Definition at line 555 of file BinexData.hpp.

size_t getRecordSize  )  const
 

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

Definition at line 977 of file BinexData.cpp.

References BinexData::getCRCLength(), BinexData::UBNXI::getSize(), BinexData::msg, BinexData::recID, BinexData::UBNXI::size, and BinexData::syncByte.

virtual bool isData void   )  const [inline, virtual]
 

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

Reimplemented from FFData.

Definition at line 505 of file BinexData.hpp.

bool isHeadSyncByteValid unsigned char  headSync,
unsigned char &  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 1562 of file BinexData.cpp.

bool isTailSyncByteValid unsigned char  tailSync,
unsigned char &  expectedHeadSync
const [protected]
 

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

Definition at line 1598 of file BinexData.cpp.

BinexData & operator= const BinexData right  ) 
 

Copies another BinexData object.

Definition at line 926 of file BinexData.cpp.

References BinexData::msg, BinexData::recID, and BinexData::syncByte.

bool operator== const BinexData b  )  const
 

Compares two BinexData objects.

Parameters:
b BinexData object to compare to this object

Definition at line 935 of file BinexData.cpp.

References BinexData::msg, BinexData::recID, and BinexData::syncByte.

unsigned long long parseBuffer const std::string &  buffer,
size_t  offset,
size_t  size
throw (FFStreamError) [static, protected]
 

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

Parameters:
buffer Raw bytes to convert
offset Position at which to begin conversion
size Number of bytes to convert
Returns:
Result of converting raw bytes to an unsigned integer

Definition at line 1627 of file BinexData.cpp.

References GPSTK_THROW.

Referenced by BinexData::MGFZI::decode().

void reallyGetRecord FFStream s  )  throw (std::exception, FFStreamError, StringUtils::StringException) [protected, virtual]
 

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:
StringException when a StringUtils function fails
FFStreamError when exceptions(failbit) is set and a read or formatting error occurs. This also resets the stream to its pre-read position.

Implements FFData.

Definition at line 1244 of file BinexData.cpp.

References BinexData::UBNXI::decode(), GPSTK_RETHROW, GPSTK_THROW, BinexData::UBNXI::read(), and BinexData::UBNXI::size.

void reallyPutRecord FFStream s  )  const throw (std::exception, FFStreamError, StringUtils::StringException) [protected, virtual]
 

Writes the BINEX data to the file stream formatted correctly.

Implements FFData.

Definition at line 1154 of file BinexData.cpp.

References BinexData::UBNXI::encode(), BinexData::UBNXI::getSize(), GPSTK_THROW, and BinexData::UBNXI::size.

void reverseBuffer std::string &  buffer,
size_t  offset = 0,
size_t  n = std::string::npos
[static, protected]
 

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

Parameters:
buffer String containing bytes to reverse
offset Starting position of bytes to reverse
n Number of bytes to reverse

Definition at line 1671 of file BinexData.cpp.

References GPSTK_THROW.

void reverseBuffer unsigned char *  buffer,
size_t  bufferLength
[static, protected]
 

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

Parameters:
buffer Pointer to the bytes
bufferLength Number of bytes to reverse

Definition at line 1657 of file BinexData.cpp.

Referenced by BinexData::MGFZI::decode(), BinexData::MGFZI::encode(), BinexData::UBNXI::encode(), BinexData::MGFZI::read(), BinexData::MGFZI::write(), and BinexData::UBNXI::write().

BinexData & setRecordFlags unsigned char  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 962 of file BinexData.cpp.

References BinexData::syncByte.

Referenced by BinexData::BinexData().

BinexData & setRecordID unsigned long  id  )  throw (FFStreamError)
 

Sets the ID of this BINEX record.

Definition at line 945 of file BinexData.cpp.

References GPSTK_THROW.

BinexData& updateMessageData size_t &  offset,
const T &  data,
size_t  size
throw (FFStreamError, InvalidParameter) [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:
offset Location within the message buffer at which to update
data Data with which to update the message buffer
size Number of bytes of data to be copied

Definition at line 716 of file BinexData.hpp.

References GPSTK_THROW, and gpstk::BinUtils::twiddle().

BinexData & updateMessageData size_t &  offset,
const char *  data,
size_t  size
throw (FFStreamError, InvalidParameter)
 

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:
offset Location within the message buffer at which to update
data Raw data with which to update the message buffer
size Number of bytes of data to be copied

Definition at line 1082 of file BinexData.cpp.

BinexData & updateMessageData size_t &  offset,
const std::string &  data,
size_t  size
throw (FFStreamError, InvalidParameter)
 

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:
offset Location within the message buffer at which to update
data Raw data with which to update the message buffer
size Number of bytes of data to be copied

Definition at line 1060 of file BinexData.cpp.

References GPSTK_THROW.

BinexData & updateMessageData size_t &  offset,
const MGFZI data
throw (FFStreamError, InvalidParameter)
 

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:
offset Location within the message buffer at which to update
data Data with which to update the message buffer

Definition at line 1046 of file BinexData.cpp.

References BinexData::UBNXI::encode().

BinexData & updateMessageData size_t &  offset,
const UBNXI data
throw (FFStreamError, InvalidParameter)
 

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:
offset Location within the message buffer at which to update
data Data with which to update the message buffer

Definition at line 1032 of file BinexData.cpp.

References BinexData::UBNXI::encode().


Member Data Documentation

const unsigned char DEFAULT_RECORD_FLAGS = 0x20 [static]
 

Definition at line 65 of file BinexData.hpp.

const unsigned long INVALID_RECORD_ID = 0xFFFFFFFF [static]
 

Definition at line 63 of file BinexData.hpp.

std::string msg [protected]
 

Record message (opaque).

Definition at line 943 of file BinexData.hpp.

Referenced by BinexData::clearMessage(), BinexData::dump(), BinexData::getRecordSize(), BinexData::operator=(), and BinexData::operator==().

const bool nativeLittleEndian = true [static]
 

Definition at line 58 of file BinexData.hpp.

unsigned long recID [protected]
 

Record ID.

Definition at line 942 of file BinexData.hpp.

Referenced by BinexData::BinexData(), BinexData::dump(), BinexData::getRecordSize(), BinexData::operator=(), and BinexData::operator==().

unsigned char syncByte [protected]
 

Flags for endianness, CRC, etc.

Definition at line 941 of file BinexData.hpp.

Referenced by BinexData::dump(), BinexData::getCRC(), BinexData::getCRCLength(), BinexData::getRecordSize(), BinexData::operator=(), BinexData::operator==(), and BinexData::setRecordFlags().

const unsigned char VALID_RECORD_FLAGS = 0x38 [static]
 

Definition at line 66 of file BinexData.hpp.


The documentation for this class was generated from the following files:
Generated on Wed Feb 8 03:31:35 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1