AVR Z-LINKŪ


hexfile.h

Go to the documentation of this file.
00001 // This file has been prepared for Doxygen automatic documentation generation.
00044 #ifndef HEXFILE_H
00045 #define HEXFILE_H
00046 
00047 #include <vector>
00048 #include <iostream>
00049 
00050 
00051 
00053 typedef unsigned short byte; // Cannot use 'char' since that is interpreted as a character.
00054 
00055 
00056 
00058 class HEXRecord
00059 {
00060 private:
00061         unsigned long m_address; 
00062         std::vector< byte > m_data; 
00063 
00064 public:
00066         HEXRecord() : m_address( 0 ) {}
00068         explicit HEXRecord( unsigned long address ) : m_address( address ) {}
00069         ~HEXRecord() {}
00070 
00072         void Add( byte data );
00074         void Add( std::vector< byte > data );
00076         void SetAddress( unsigned long address ) { m_address = address; }
00078         size_t GetByteCount() const { return m_data.size(); }
00080         void Print( std::ostream & os ) const;
00081 };
00082 
00083 
00084 
00086 HEXRecord & operator<<( HEXRecord & record, byte data );
00088 HEXRecord & operator<<( HEXRecord & record, std::vector< byte > data );
00090 std::ostream & operator<<( std::ostream & os, const HEXRecord & record );
00091 
00092 
00093 
00095 class HEXFile
00096 {
00097 private:
00098         std::vector< HEXRecord > m_records; 
00099         unsigned long m_nextAddress; 
00100 
00101 public:
00103         HEXFile() : m_nextAddress( 0 ) {}
00104         ~HEXFile() {}
00105 
00107         void Add( const HEXRecord & record ) {
00108                 m_records.push_back( record );
00109                 m_records.back().SetAddress( m_nextAddress );
00110                 m_nextAddress += record.GetByteCount();
00111         }
00113         void Add( const HEXRecord & record, size_t copies ) {
00114                 while( copies-- ) {
00115                         Add( record );
00116                 }
00117         }
00119         void Print( std::ostream & os ) const;
00120 };
00121 
00122 
00123 
00125 HEXFile & operator<<( HEXFile & file, const HEXRecord & record );
00127 std::ostream & operator<<( std::ostream & os, const HEXFile & file );
00128 
00129 
00130 
00131 #endif
00132 
@DOC_TITLE@
Generated on Sun Oct 29 18:12:00 2006 for AVR414 User's Guide - ATAVRRZ502 - Accessory Kit (PC Tools - HEXMaker) by doxygen 1.4.7