Kinetis Bootloader Host  2.0.0
Host Tools for Kinetis devices
StIntelHexFile Class Reference

Intel Hex parser. More...

#include <StIntelHexFile.h>

+ Collaboration diagram for StIntelHexFile:

Classes

struct  IntelHex
 

Public Types

typedef std::vector< IntelHex >::const_iterator const_iterator
 Iterator type.
 

Public Member Functions

 StIntelHexFile (std::istream &inStream)
 Constructor.
 
virtual ~StIntelHexFile ()
 Destructor. More...
 
File name
virtual void setName (const std::string &inName)
 
virtual std::string getName () const
 
Parsing
virtual bool isIntelHexFile ()
 Determine if the file is a Intel Hex file. More...
 
virtual void parse ()
 Parse the entire IntelHex input stream. More...
 
Record access
unsigned getRecordCount () const
 
const_iterator getBegin () const
 
const_iterator getEnd () const
 
Operators
const IntelHexoperator[] (unsigned inIndex)
 

Protected Member Functions

Parsing utilities
virtual void parseLine (std::string &inLine)
 Parses individual Intel Hex. More...
 
bool isHexDigit (char c)
 
int hexDigitToInt (char digit)
 
int readHexByte (std::string &inString, int inIndex)
 

Protected Attributes

std::istream & m_stream
 The input stream for the Intel Hex data.
 
std::vector< IntelHexm_records
 Vector of Intel Hex in the input data.
 
std::string m_name
 File name. (optional)
 

Detailed Description

Intel Hex parser.

This class takes an input stream and parses it as a Intel Hex file. While the individual records that comprise the file are available for access, the class also provides a higher-level view of the contents. It processes the individual records and builds an image of what the memory touched by the file looks like. Then you can access the contiguous sections of memory.


Class Documentation

struct StIntelHexFile::IntelHex

Structure representing each individual line of the Intel Hex input data.

Class Members
uint32_t m_address The address offset of the data.
uint8_t m_checksum The checksum byte used to verify the record.
uint8_t * m_data Pointer to data, or NULL if no data for this record.
unsigned m_dataCount The number of bytes in the data field.
unsigned m_type

Type of the data field. 00: Data 01: End of File 02: Extended Segment Address 03: Start Segment Address 04: Extended Linear Address 05: Start Linear Address

Constructor & Destructor Documentation

StIntelHexFile::~StIntelHexFile ( )
virtual

Destructor.

Frees any data allocated as part of an Intel Hex.

Member Function Documentation

const_iterator StIntelHexFile::getBegin ( ) const
inline
Returns
iterator for
unsigned StIntelHexFile::getRecordCount ( ) const
inline
Returns
the number of Intel Hex that have been parsed from the input stream.
bool StIntelHexFile::isIntelHexFile ( )
virtual

Determine if the file is a Intel Hex file.

Just looks for ":" as the first characters of the file followed by two digit characters.

void StIntelHexFile::parse ( )
virtual

Parse the entire IntelHex input stream.

Extract records one line at a time and hand them to the parseLine() method. Either CR, LF, or CRLF line endings are supported. The input stream is read until EOF or an file end record detected. The parse() method must be called after the object has been constructed before any of the records will become accessible.

Exceptions
StIntelHexParseExceptionwill be thrown if any error occurs while parsing the input.
void StIntelHexFile::parseLine ( std::string &  inLine)
protectedvirtual

Parses individual Intel Hex.

Takes a single Intel Hex line as input and appends a new IntelHex struct to the m_records vector.

Exceptions
StIntelHexParseExceptionwill be thrown if any error occurs while parsing inLine.
int StIntelHexFile::readHexByte ( std::string &  inString,
int  inIndex 
)
protected
Exceptions
StIntelHexParseExceptionis thrown if either of the nibble characters is not a valid hex digit.

The documentation for this class was generated from the following files: