📄 binexdata.hpp
字号:
operator!=(const MGFZI& other) const { return (value != other.value); }; /** * Returns whether this MGFZI is less than the other. */ inline bool operator<(const MGFZI& other) const { return (value < other.value); }; /** * Returns whether this MGFZI is less than or equal to the other. */ inline bool operator<=(const MGFZI& other) const { return (value <= other.value); }; /** * Returns whether this MGFZI is greater than the other. */ inline bool operator>(const MGFZI& other) const { return (value > other.value); }; /** * Returns whether this MGFZI is greater than or equal to the other. */ inline bool operator>=(const MGFZI& other) const { return (value >= other.value); }; /** * Returns the value of the MGFZI as a long long. */ inline operator long long() const { return value; }; /** * Returns the number of bytes required to represent the MGFZI. * A size of 0 indicates an invalid or uninitialized MGFZI. */ inline size_t getSize() const { return size; }; /** * Attempts to decode a valid MGFZI from the contents of inBuffer. * The contents of inBuffer are assumed to be in normal order * (i.e. not reversed) but may be either big or little endian. * @param inBuffer Sequence of bytes to decode * @param offset Offset into inBuffer at which to decode * @param littleEndian Byte order of the encoded bytes * @return Number of bytes decoded */ size_t decode(const std::string& inBuffer, size_t offset = 0, bool littleEndian = false) throw(FFStreamError); /** * Converts the MGFZI to a series of bytes placed in outBuffer. * The bytes are output in normal order (i.e. not reversed) but * may encode in either big or little endian format. * @param outBuffer Sequence of encoded bytes * @param offset Offset into outBuffer at which to encode * @param littleEndian Byte order of the encoded bytes * @return Number of bytes used to encode */ size_t encode(std::string& outBuffer, size_t offset = 0, bool littleEndian = false) const; /** * Attempts to read a valid MGFZI from the specified input stream. * The stream can be in reverse order and can be * big or little endian. If the method succeeds, the number * of bytes used to contruct the MGFZI can be determined * by calling the getSize() method. * @param strm Stream from which to read * @param outBuffer Optional buffer to receive copy of raw input * @param reverseBytes Optional flag indicating whether * the input bytes are reversed * @param littleEndian Optional flag indicating byte order of input */ size_t read(std::istream& strm, std::string *outBuffer = NULL, size_t offset = 0, bool reverseBytes = false, bool littleEndian = false) throw(FFStreamError); /** * Attempts to write the MGFZI to the specified output stream. * The stream can be output in reverse order and can be * big or little endian. The method fails if the entire * MGFZI cannot be written to the stream. * @param strm Stream in which to write * @param outBuffer Optional buffer to receive copy of raw ouput * @param reverseBytes Optional flag indicating whether * the ouput bytes should be reversed * @param littleEndian Optional flag indicating byte order of output */ size_t write(std::ostream& strm, std::string *outBuffer = NULL, size_t offset = 0, bool reverseBytes = false, bool littleEndian = false) const throw(FFStreamError); protected: long long value; size_t size; }; //@} /** * Default constructor */ BinexData(); /** * Copy constructor */ BinexData(const BinexData& other); /** * Convenience constructor */ BinexData(unsigned long recordID, unsigned char recordFlags = DEFAULT_RECORD_FLAGS) throw(); /** * Copies another BinexData object. */ BinexData& operator=(const BinexData& right); /** * Destructor */ virtual ~BinexData() {}; /** * BinexData is "data" so this function always returns true. */ virtual bool isData(void) const { return true; } /** * A debug output function. */ virtual void dump(std::ostream& s) const; /** * Compares two BinexData objects. * * @param b BinexData object to compare to this object */ bool operator==(const BinexData& b) const; /** * 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. */ inline unsigned char getRecordFlags() const { // Return only essential, valid flag bits listed in recordFlagMask return syncByte & VALID_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. */ BinexData& setRecordFlags(unsigned char flags = DEFAULT_RECORD_FLAGS); /** * Returns the ID of this BINEX record. */ inline unsigned long getRecordID() const { return recID; }; /** * Sets the ID of this BINEX record. */ BinexData& setRecordID(unsigned long id) throw(FFStreamError); /** * Returns the number of bytes required to represent the entire record * (based on the record's current contents). */ size_t getRecordSize() const; /** * Remove all data from the record message buffer. */ BinexData& clearMessage(); /** * 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. */ BinexData& ensureMessageCapacity(size_t cap) throw(FFStreamError); /** * Returns the length of the data in the record message buffer * (which is separate from the record message buffer's capacity). * * @return Record message data length in bytes */ inline size_t getMessageLength() const { return msg.size(); }; /** * Returns the capacity of the record message buffer (which is * separate from the lenth of the data in the buffer). * * @return Record message capacity in bytes */ inline size_t getMessageCapacity() const { return msg.capacity(); }; /** * 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. */ //inline const char* inline const std::string& getMessageData() const { //return msg.data(); return msg; }; /** * 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. * * @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 UBNXI& data) throw(FFStreamError, InvalidParameter); /** * Updates the message buffer with the specified MGFZI. The location
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -