| Remote Access Control |

# hexfile.h

Go to the documentation of this file.

    00001 // This file has been prepared for Doxygen automatic documentation generation.
    00045 #ifndef HEXFILE_H
    00046 #define HEXFILE_H
    00047
    00048 #include <vector>
    00049 #include <iostream>
    00050
    00051
    00052
    00054 typedef unsigned short byte; // Cannot use 'char' since that is interpreted as a character.
    00055
    00056
    00057
    00059 class HEXRecord
    00060 {
    00061 private:
    00062         unsigned long m_address;
    00063         std::vector< byte > m_data;
    00064
    00065 public:
    00067         HEXRecord() : m_address( 0 ) {}
    00069         explicit HEXRecord( unsigned long address ) : m_address( address ) {}
    00070         ~HEXRecord() {}
    00071
    00073         void Add( byte data );
    00075         void Add( std::vector< byte > data );
    00077         void SetAddress( unsigned long address ) { m_address = address; }
    00079         size_t GetByteCount() const { return m_data.size(); }
    00081         void Print( std::ostream & os ) const;
    00082 };
    00083
    00084
    00085
    00087 HEXRecord & operator<<( HEXRecord & record, byte data );
    00089 HEXRecord & operator<<( HEXRecord & record, std::vector< byte > data );
    00091 std::ostream & operator<<( std::ostream & os, const HEXRecord & record );
    00092
    00093
    00094
    00096 class HEXFile
    00097 {
    00098 private:
    00099         std::vector< HEXRecord > m_records;
    00100         unsigned long m_nextAddress;
    00101
    00102 public:
    00104         HEXFile() : m_nextAddress( 0 ) {}
    00105         ~HEXFile() {}
    00106
    00108         void Add( const HEXRecord & record ) {
    00109                 m_records.push_back( record );
    00110                 m_records.back().SetAddress( m_nextAddress );
    00111                 m_nextAddress += record.GetByteCount();
    00112         }
    00114         void Add( const HEXRecord & record, size_t copies ) {
    00115                 while( copies-- ) {
    00116                         Add( record );
    00117                 }
    00118         }
    00120         void Print( std::ostream & os ) const;
    00121 };
    00122
    00123
    00124
    00126 HEXFile & operator<<( HEXFile & file, const HEXRecord & record );
    00128 std::ostream & operator<<( std::ostream & os, const HEXFile & file );
    00129
    00130
    00131
    00132 #endif
    00133

@DOC_TITLE@