StSRecordFile Class Reference

S-record parser. More...

`#include <StSRecordFile.h>`

Collaboration diagram for StSRecordFile:
[legend]

## Classes

struct | SRecord

## Public Types

typedef std::vector< SRecord >::const_iterator | const_iterator
| Iterator type.
typedef std::vector< SRecord >::const_iterator | const_iterator
| Iterator type.

## Public Member Functions

| StSRecordFile (std::istream &inStream)
| Constructor.
virtual | ~StSRecordFile ()
| Destructor. More...
| StSRecordFile (std::istream &inStream)
| Constructor.
virtual | ~StSRecordFile ()
| Destructor.
File name
virtual void | setName (const std::string &inName)
virtual std::string | getName () const
virtual void | setName (const std::string &inName)
virtual std::string | getName () const
Parsing
virtual bool | isSRecordFile ()
| Determine if the file is an S-record file. More...
virtual void | parse ()
| Parses the entire S-record input stream. More...
virtual bool | isSRecordFile ()
| Determine if the file is an S-record file.
virtual void | parse ()
| Parses the entire S-record input stream.
Record access
unsigned | getRecordCount () const
const_iterator | getBegin () const
const_iterator | getEnd () const
unsigned | getRecordCount () const
const_iterator | getBegin () const
const_iterator | getEnd () const
Operators
const SRecord & | operator[] (unsigned inIndex)
const SRecord & | operator[] (unsigned inIndex)

## Protected Member Functions

Parsing utilities
virtual void | parseLine (std::string &inLine)
| Parses individual S-records. More...
bool | isHexDigit (char c)
int | hexDigitToInt (char digit)
int | readHexByte (std::string &inString, int inIndex)
virtual void | parseLine (std::string &inLine)
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 S-record data.
std::vector< SRecord > | m_records
| Vector of S-records in the input data.
std::string | m_name
| File name. (optional)

## Detailed Description

S-record parser.

This class takes an input stream and parses it as an S-record 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 StSRecordFile::SRecord

Structure representing each individual line of the S-record input data.

Class Members
uint32_t | m_address | The address specified as part of the S-record.
uint8_t | m_checksum | The checksum byte present in the S-record.
unsigned | m_count | Number of character pairs (bytes) from address through checksum.
uint8_t * | m_data | Pointer to data, or NULL if no data for this record type.
unsigned | m_dataCount | Number of bytes of data.
unsigned | m_type | Record number type, such as 9 for "S9", 3 for "S3" and so on.

## Constructor & Destructor Documentation

StSRecordFile::~StSRecordFile | ( |  | ) |

virtual

Destructor.

Frees any data allocated as part of an S-record.

## Member Function Documentation

const_iterator StSRecordFile::getBegin | ( |  | ) | const

inline

Returns
  iterator for

const_iterator StSRecordFile::getBegin | ( |  | ) | const

inline

Returns
  iterator for

unsigned StSRecordFile::getRecordCount | ( |  | ) | const

inline

Returns
  the number of S-records that have been parsed from the input stream.

unsigned StSRecordFile::getRecordCount | ( |  | ) | const

inline

Returns
  the number of S-records that have been parsed from the input stream.

bool StSRecordFile::isSRecordFile | ( |  | ) |

virtual

Determine if the file is an S-record file.

Just looks for "S[0-9]" as the first two characters of the file.

void StSRecordFile::parse | ( |  | ) |

virtual

Parses the entire S-record 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. The parse() method must be called after the object has been constructed before any of the records will become accessible.

Exceptions

  StSRecordParseException | will be thrown if any error occurs while parsing the input.

void StSRecordFile::parseLine | ( | std::string & | inLine | ) |

protectedvirtual

Parses individual S-records.

Takes a single S-record line as input and appends a new SRecord struct to the m_records vector.

Exceptions

  StSRecordParseException | will be thrown if any error occurs while parsing inLine.

int StSRecordFile::readHexByte | ( | std::string & | inString,
|  | int | inIndex
| ) |  |

protected

Exceptions

  StSRecordParseException | is thrown if either of the nibble characters is not a valid hex digit.

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

- apps/elftosb/common/StSRecordFile.h
- apps/elftosb/common/StSRecordFile.cpp