📄 binexdata.hpp
字号:
* 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. * * @param offset Location within the message buffer at which to update * @param data Data with which to update the message buffer */ BinexData& updateMessageData( size_t& offset, const MGFZI& data) 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. * * @param offset Location within the message buffer at which to update * @param data Raw data with which to update the message buffer * @param size Number of bytes of data to be copied */ 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. * * @param offset Location within the message buffer at which to update * @param data Raw data with which to update the message buffer * @param size Number of bytes of data to be copied */ BinexData& updateMessageData( size_t& offset, const char *data, size_t size) throw(FFStreamError, InvalidParameter); /** * 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. * * @param offset Location within the message buffer at which to update * @param data Data with which to update the message buffer * @param size Number of bytes of data to be copied */ template<class T> BinexData& updateMessageData( size_t& offset, const T& data, size_t size) throw(FFStreamError, InvalidParameter) { if (size > sizeof(T) ) { std::ostringstream errStrm; errStrm << "Invalid data size: " << size; InvalidParameter ip(errStrm.str() ); GPSTK_THROW(ip); } bool littleEndian = ( (syncByte & eBigEndian) == 0) ? true : false; if (littleEndian == nativeLittleEndian) { msg.replace(offset, size, reinterpret_cast<const char*>(&data), size); } else { T tmpData(data); BinUtils::twiddle(tmpData); msg.replace(offset, size, reinterpret_cast<const char*>(&tmpData), size); } offset += size; return *this; } // BinexData::updateMessageData() /** * 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. * * @param offset Location within the message buffer at which to extract * @param data Location to store the extracted data */ void extractMessageData( size_t& offset, UBNXI& 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. * * @param offset Location within the message buffer at which to extract * @param data Location to store the extracted data */ void extractMessageData( size_t& offset, MGFZI& data) throw(FFStreamError, 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. * * @param offset Location within the message buffer at which to extract * @param data Location to store the extracted data * @param size Number of bytes of data to be extracted */ void extractMessageData( size_t& offset, std::string& data, size_t size) const throw(InvalidParameter); /** * 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. * * @param offset Location within the message buffer at which to extract * @param data Location to store the extracted data * @param size Number of bytes of data to be extracted */ template<class T> void extractMessageData( size_t& offset, T& data, size_t size) const throw(FFStreamError, InvalidParameter) { if (size > sizeof(T) ) { std::ostringstream errStrm; errStrm << "Data size invalid: " << size; InvalidParameter ip(errStrm.str() ); GPSTK_THROW(ip); } if (offset + size > msg.size() ) { std::ostringstream errStrm; errStrm << "Message buffer offset invalid: " << offset; InvalidParameter ip(errStrm.str() ); GPSTK_THROW(ip); } bool littleEndian = ( (syncByte & eBigEndian) == 0) ? true : false; msg.copy(reinterpret_cast<char*>(&data), size, offset); if (littleEndian != nativeLittleEndian) { BinUtils::twiddle(data); } offset += size; } // BinexData::extractMessageData() protected: /** * Writes the BINEX data to the file stream formatted correctly. */ virtual void reallyPutRecord(FFStream& s) const throw(std::exception, FFStreamError, StringUtils::StringException); /** * 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. * @throws StringException when a StringUtils function fails * @throws FFStreamError when exceptions(failbit) is set and * a read or formatting error occurs. This also resets the * stream to its pre-read position. */ virtual void reallyGetRecord(FFStream& s) throw(std::exception, FFStreamError, StringUtils::StringException); /** * @param bufs A NULL-terminated list of pointers to byte buffers * @param bufLens A list of lengths for the buffers specified by bufs * @param crc A pointer to the buffer in which to store the CRC * @param crcLen The number of bytes used to store the CRC */ void getCRC(const std::string& head, const std::string& message, std::string& crc) const; /** * Returns the number of bytes required to store the record's CRC * based on the record's current contents. */ size_t getCRCLength(size_t crcDataLen) const; /** * Determines whether the supplied head sync byte is valid an returns * an expected correosponding tail sync byte if appropriate. */ bool isHeadSyncByteValid(unsigned char headSync, unsigned char& expectedTailSync) const; /** * Determines whether the supplied tail sync byte is valid an returns * an expected correosponding head sync byte. */ bool isTailSyncByteValid(unsigned char tailSync, unsigned char& expectedHeadSync) const; /** * Converts a raw sequence of bytes into an unsigned long long integer. * * @param buffer Raw bytes to convert * @param offset Position at which to begin conversion * @param size Number of bytes to convert * @return Result of converting raw bytes to an unsigned integer */ static unsigned long long parseBuffer(const std::string& buffer, size_t offset, size_t size) throw(FFStreamError); /** * Reverses the order of the first bufferLength bytes in the * specified buffer. * * @param buffer Pointer to the bytes * @param bufferLength Number of bytes to reverse */ static void reverseBuffer(unsigned char *buffer, size_t bufferLength); /** * Reverses the order of the first bufferLength bytes in the * specified buffer. * * @param buffer String containing bytes to reverse * @param offset Starting position of bytes to reverse * @param n Number of bytes to reverse */ static void reverseBuffer(std::string& buffer, size_t offset = 0, size_t n = std::string::npos); /** @name Attributes */ //@{ unsigned char syncByte; ///< Flags for endianness, CRC, etc. unsigned long recID; ///< Record ID std::string msg; ///< Record message (opaque) //@} private: }; // class BinexData //@}} // namespace gpstk#endif // GPSTK_BINEXDATA_HPP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -