srecord  1.65.0
srecord::record Class Reference

The srecord::record class is used to represent a data record read from a file. More...

#include <record.h>

Public Types

enum  type_t {
  type_unknown , type_header , type_data , type_data_count ,
  type_execution_start_address
}
 The type of the various record types. More...
 
enum  { max_data_length = 255 }
 
typedef uint32_t address_t
 The type of record addresses. More...
 
typedef uint8_t data_t
 The type of record data values. More...
 

Public Member Functions

 ~record ()
 The destructor. More...
 
 record ()
 The default constructor. More...
 
 record (const record &)
 The copy constructor. More...
 
 record (type_t)
 A constructor. More...
 
 record (type_t, address_t)
 A constructor. More...
 
 record (type_t the_type, address_t the_address, const data_t *the_data, size_t the_data_length)
 A constructor. More...
 
recordoperator= (const record &)
 The assignment operator. More...
 
address_t get_address (void) const
 The get_address method is used to get the address of the record. More...
 
address_t get_address_end (void) const
 The get_address_end method is used to get the address "off the end" of this record. More...
 
bool address_range_fits_into_n_bits (unsigned nbits) const
 The address_range_fits_into_n_bits method is used to test whether or not this record's address range fits within the given number of bits. More...
 
void set_address (address_t arg)
 The set_address method is used to set the address of the record. More...
 
size_t get_length (void) const
 The get_length method is used to get the length (number of bytes) of the record data. More...
 
void set_length (size_t arg)
 The set_length method is used to set the number of data bytes in the record data. More...
 
const data_tget_data (void) const
 The get_data method is used to get a ponter to the baseof the record data. More...
 
int get_data (size_t n) const
 The get_data method is used to fetch the nth data value. More...
 
bool is_all_zero (void) const
 The is_all_zero method is used to determin if the record contains data bytes which are all zero. More...
 
void set_data (size_t n, data_t d)
 The set_data method is used to set values in the data array. More...
 
void set_data_extend (size_t n, data_t d)
 The set_data_extend method is used to set values in the data array. More...
 
type_t get_type (void) const
 The get_type method is used to get the type of the record. More...
 
void set_type (type_t arg)
 The set_type method is used to set the type of the record. More...
 

Static Public Member Functions

static size_t maximum_data_length (address_t addr)
 The maximum_data_length method is used to determine the maximum data length possible within a record, for a given address. More...
 
static address_t decode_big_endian (const data_t *data, size_t len)
 The decode_big_endian method is used to extract 'len' bytes from the given 'data' and assemble a big-endian value (most significant byte first). More...
 
static address_t decode_little_endian (const data_t *data, size_t len)
 The decode_little_endian method is used to extract 'len' bytes from the given 'data' and assemble a little-endian value (least significant byte first). More...
 
static address_t decode (const data_t *data, size_t len, endian_t end)
 The decode method is used to extract 'len' bytes from the given 'data' and assemble a valu. More...
 
static void encode_big_endian (data_t *data, address_t val, size_t len)
 The encode_big_endian method is used to break down 'val' into 'len' bytes of 'data' orderdd big-endian (most significan byte first). More...
 
static void encode_little_endian (data_t *data, address_t val, size_t len)
 The encode_little_endian method is used to break down 'val' into 'len' bytes of 'data' orderdd big-endian (least significan byte first). More...
 
static void encode (data_t *data, address_t val, size_t len, endian_t end)
 The encode method is used to break down 'val' into 'len' bytes of 'data'. More...
 

Detailed Description

The srecord::record class is used to represent a data record read from a file.

(It is not limited to any particular file format.) The records may be of various types.

Definition at line 34 of file record.h.

Member Typedef Documentation

◆ address_t

typedef uint32_t srecord::record::address_t

The type of record addresses.

Definition at line 58 of file record.h.

◆ data_t

typedef uint8_t srecord::record::data_t

The type of record data values.

Definition at line 63 of file record.h.

Member Enumeration Documentation

◆ type_t

The type of the various record types.

Enumerator
type_unknown 
type_header 
type_data 
type_data_count 
type_execution_start_address 

Definition at line 46 of file record.h.

◆ anonymous enum

anonymous enum
Enumerator
max_data_length 

The max_data_length is the largest number of data bytes which any record can hold.

Definition at line 343 of file record.h.

Constructor & Destructor Documentation

◆ ~record()

srecord::record::~record ( )

The destructor.

It isn't virtual, so don't derive anything from this class.

◆ record() [1/5]

srecord::record::record ( )

The default constructor.

The record will have an indeterminate type, zero address, and no data.

◆ record() [2/5]

srecord::record::record ( const record )

The copy constructor.

◆ record() [3/5]

srecord::record::record ( type_t  )

A constructor.

The record will have the given type, a zero address and no data.

◆ record() [4/5]

srecord::record::record ( type_t  ,
address_t   
)

A constructor.

The record will have the given type, the given address and no data.

◆ record() [5/5]

srecord::record::record ( type_t  the_type,
address_t  the_address,
const data_t the_data,
size_t  the_data_length 
)

A constructor.

The record will have the given type, the given address and a copy of the given data.

Parameters
the_typeWhat kind of record this is
the_addressThe memory address of the first byte of data, the rest increase by one each.
the_dataThe bytes of data for the record.
the_data_lengthHow long the data is. assert(the_data_length < max_data_length);

Member Function Documentation

◆ operator=()

record& srecord::record::operator= ( const record )

The assignment operator.

◆ get_address()

address_t srecord::record::get_address ( void  ) const
inline

The get_address method is used to get the address of the record.

Definition at line 115 of file record.h.

◆ get_address_end()

address_t srecord::record::get_address_end ( void  ) const
inline

The get_address_end method is used to get the address "off the end" of this record.

Definition at line 121 of file record.h.

◆ address_range_fits_into_n_bits()

bool srecord::record::address_range_fits_into_n_bits ( unsigned  nbits) const

The address_range_fits_into_n_bits method is used to test whether or not this record's address range fits within the given number of bits.

Parameters
nbitsThe number of bits, e.g. 16
Returns
true if the address range will fit, or false if it will not fit

◆ set_address()

void srecord::record::set_address ( address_t  arg)
inline

The set_address method is used to set the address of the record.

Definition at line 138 of file record.h.

◆ get_length()

size_t srecord::record::get_length ( void  ) const
inline

The get_length method is used to get the length (number of bytes) of the record data.

Definition at line 144 of file record.h.

◆ set_length()

void srecord::record::set_length ( size_t  arg)
inline

The set_length method is used to set the number of data bytes in the record data.

Parameters
argThe new record length. Note that you can reduce the length, but you can't increase it.

Definition at line 155 of file record.h.

◆ get_data() [1/2]

const data_t* srecord::record::get_data ( void  ) const
inline

The get_data method is used to get a ponter to the baseof the record data.

Note: Accessing beyond get_length() bytes will give an undefined value.

Definition at line 168 of file record.h.

◆ get_data() [2/2]

int srecord::record::get_data ( size_t  n) const
inline

The get_data method is used to fetch the nth data value.

Note: For perfoemance reasons, no range checking is performed. Accessing beyond get_length() bytes will give an undefined value.

Parameters
nThe index into the data array, zero based. Values when n is in excess of length are undefined.

Definition at line 181 of file record.h.

◆ is_all_zero()

bool srecord::record::is_all_zero ( void  ) const

The is_all_zero method is used to determin if the record contains data bytes which are all zero.

◆ set_data()

void srecord::record::set_data ( size_t  n,
data_t  d 
)
inline

The set_data method is used to set values in the data array.

No range checking is performed. The record length is not consulted or adjusted.

Parameters
nThe index into the data array, zero based. Results when n is in excess of length are undefined.
dThe new data value.

Definition at line 200 of file record.h.

◆ set_data_extend()

void srecord::record::set_data_extend ( size_t  n,
data_t  d 
)

The set_data_extend method is used to set values in the data array.

The record length is adjusted if necessary.

Parameters
nThe index into the data array, zero based. If this is beyond length, then length will be extended. assert(n < max_data_length);
dThe new data value.

◆ get_type()

type_t srecord::record::get_type ( void  ) const
inline

The get_type method is used to get the type of the record.

Definition at line 218 of file record.h.

◆ set_type()

void srecord::record::set_type ( type_t  arg)
inline

The set_type method is used to set the type of the record.

Definition at line 223 of file record.h.

◆ maximum_data_length()

static size_t srecord::record::maximum_data_length ( address_t  addr)
static

The maximum_data_length method is used to determine the maximum data length possible within a record, for a given address.

Parameters
addrThe address of the record. Some formats trade data size of address size, for a constant maximum line length.

◆ decode_big_endian()

static address_t srecord::record::decode_big_endian ( const data_t data,
size_t  len 
)
static

The decode_big_endian method is used to extract 'len' bytes from the given 'data' and assemble a big-endian value (most significant byte first).

Parameters
dataThe data to be decodes
lenLength of the data, in bytes
Returns
the decoded value

Referenced by decode().

◆ decode_little_endian()

static address_t srecord::record::decode_little_endian ( const data_t data,
size_t  len 
)
static

The decode_little_endian method is used to extract 'len' bytes from the given 'data' and assemble a little-endian value (least significant byte first).

Parameters
dataThe data to be decodes
lenLength of the data, in bytes
Returns
the decoded value

Referenced by decode().

◆ decode()

static address_t srecord::record::decode ( const data_t data,
size_t  len,
endian_t  end 
)
inlinestatic

The decode method is used to extract 'len' bytes from the given 'data' and assemble a valu.

Parameters
dataThe data to be decodes
lenLength of the data, in bytes
endThe byte order of the data.
Returns
the decoded value

Definition at line 278 of file record.h.

References decode_big_endian(), decode_little_endian(), and srecord::endian_big.

◆ encode_big_endian()

static void srecord::record::encode_big_endian ( data_t data,
address_t  val,
size_t  len 
)
static

The encode_big_endian method is used to break down 'val' into 'len' bytes of 'data' orderdd big-endian (most significan byte first).

Parameters
dataWhere to place the encoded data
valThe value to be encoded
lenThe number of bytes to use to encode the data. Bits above the 8*len resolution will be discarded.

Referenced by encode().

◆ encode_little_endian()

static void srecord::record::encode_little_endian ( data_t data,
address_t  val,
size_t  len 
)
static

The encode_little_endian method is used to break down 'val' into 'len' bytes of 'data' orderdd big-endian (least significan byte first).

Parameters
dataWhere to place the encoded data
valThe value to be encoded
lenThe number of bytes to use to encode the data. Bits above the 8*len resolution will be discarded.

Referenced by encode().

◆ encode()

static void srecord::record::encode ( data_t data,
address_t  val,
size_t  len,
endian_t  end 
)
inlinestatic

The encode method is used to break down 'val' into 'len' bytes of 'data'.

Parameters
dataWhere to place the encoded data
valThe value to be encoded
lenThe number of bytes to use to encode the data. Bits above the 8*len resolution will be discarded.
endThe byte order

Definition at line 335 of file record.h.

References encode_big_endian(), encode_little_endian(), and srecord::endian_big.


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