srecord: srecord::output_file Class Reference

srecord 1.65.0

Loading...
Searching...
No Matches
srecord::output_file Class Reference

The srecord::output_file class is used to represent a generic output file. More...

`#include <file.h>`

Inheritance diagram for srecord::output_file:
[legend]
Collaboration diagram for srecord::output_file:
[legend]

## Public Member Functions
virtual | ~output_file ()
| The destructor.
| output_file ()
| The default constructor.
| output_file (const std::string &file_name)
| The constructor.
virtual const std::string | filename (void) const
| The filename method is used to determine the name of the output file.
Public Member Functions inherited from srecord::output
virtual | ~output ()
| The destructor.
virtual void | write (const record &rec)=0
| The write method is used to write a recordonto an output.
virtual void | write_header (const record *=0)
| The write_header method is used to write a header record to the output.
virtual void | write_data (unsigned long, const void *, size_t)
| The write_data method is used to write data to the output.
virtual void | write_execution_start_address (const record *=0)
| The write_execution_start_address method is used to write an execution start address record to the output.
virtual void | line_length_set (int cols)=0
| The set_line_length method is used to set the maximum length of an output line, for those formats for which this is a meaningful concept, and the line length is at all controllable.
virtual void | address_length_set (int nbytes)=0
| The address_length_set method is used to set the minimum number of bytes to be written for addresses in the output, for those formats for which this is a meaningful concept, and the address length is at all controllable.
virtual int | preferred_block_size_get (void) const =0
| The preferred_block_size_get method is used to get the proferred block size of the output fformat.
virtual bool | preferred_block_size_set (int nbytes)=0
| The preferred_block_size_set method is is to set a precific number of bytes for the preferred block size.
virtual void | fatal_error (const char *fmt,...) const FORMAT_PRINTF(2
| The fatal_error method is used to report fatal errors.
virtual void virtual void | fatal_error_v (const char *fmt, va_list ap) const
| The fatal_error_v method is used to report fatal errors.
virtual void | fatal_error_errno (const char *fmt,...) const FORMAT_PRINTF(2
| The fatal_error_errno method is used to report fatal errors, and append the string equivalent of errno.
virtual void virtual void | fatal_error_errno_v (const char *fmt, va_list ap) const
| The fatal_error_errno_v method is used to report fatal errors.
virtual void | warning (const char *fmt,...) const FORMAT_PRINTF(2
| The warning method is used to likely but non-fatal errors.
virtual void virtual void | warning_v (const char *fmt, va_list ap) const
| The warning_v method is used to report likely but non-fatal errors.
virtual const char * | format_name (void) const =0
| The format_name method is used to obtain the name of this output format.
virtual void | notify_upper_bound (unsigned long addr)
| The notify_upper_bound method is used to notify the output class of the upper bound (highest address plus one) of the output to come.
virtual void | command_line (arglex_tool *cmdln)
| The command_line method is used by arglex_srec::get_output when parsing the command line, to give the format an opportunity to grab extra arguments off the command line.

## Static Public Member Functions
static void | enable_header (bool yesno)
| The enable_header class method is used to enable or disable the writing of header records into output file, if the format supports optional header records.
static void | enable_data_count (bool yesno)
| The enable_data_count class method is used to enable or disable the writing of data record count records into output file, if the format supports optional data record count records.
static void | enable_goto_addr (bool yesno)
| The enable_goto_addr class method is used to enable or disable the writing of execution start address records into output file, if the format supports optional execution start address records.
static void | enable_footer (bool yesno)
| The enable_footer class method is used to enable or disable the writing of footer records into output file, if the format supports optional footer records.
static bool | enable_by_name (const std::string &name, bool yesno)
| The enable_by_name class method is used to enable or disable the writing of various records into output file.
static bool | line_termination_by_name (const std::string &name)
| The line_termination_by_name method is used to force line termination to a particular style, rather than the current operating system's native text format.

## Protected Types
enum | line_termination_t { line_termination_native , line_termination_crlf , line_termination_nl , line_termination_binary = line_termination_nl , line_termination_cr , line_termination_primos }

## Protected Member Functions
virtual void | put_char (int c)
| The put_char method is used to send a character to the output.
void | put_nibble (int value)
| The put_nibble method is used to send a hexadecimal digit (0..9, A..F) to the output.
virtual void | put_byte (unsigned char value)
| The put_byte method is used to send a byte value to the output.
virtual void | put_word_be (int value)
| The put_word_be method is used to send a 16-bit value to the output.
virtual void | put_word_le (int value)
| The put_word_le method is used to send a 16-bit value to the output.
virtual void | put_3bytes_be (unsigned long value)
| The put_3bytes_be method is used to send a 24-bit value to the output.
virtual void | put_3bytes_le (unsigned long value)
| The put_3bytes_le method is used to send a 24-bit value to the output.
virtual void | put_4bytes_be (unsigned long value)
| The put_4bytes_be method is used to send a 32-bit value to the output.
virtual void | put_4bytes_le (unsigned long value)
| The put_4bytes_le method is used to send a 32-bit value to the output.
void | checksum_reset (void)
| The checksum_reset method is used to set the running checksum to zero.
virtual void | checksum_add (unsigned char n)
| The checksum_add method is used to add another 8-bit value to the running checksum.
int | checksum_get (void)
| The checksum_get method is used to get the current value of the running checksum (added to by the checksum_add method, usually called by the put_byte method).
int | checksum_get16 (void)
| The checksum_get16 method is used to get the current value of the running checksum (added to by the checksum_add method, usually called by the put_byte method).
void | seek_to (unsigned long)
| The seek_to method is used to move the output position to the specified location in the output file.
void | put_string (const char *text)
| The put_string method is used to send a nul-terminated C string to the output.
void | put_string (const std::string &text)
| The put_string method is used to send C++ string to the output.
void | put_stringf (const char *,...) FORMAT_PRINTF(2
| The put_stringf method is used to send a formatted string to the output.
void | fatal_alignment_error (int alignment)
| The fatal_alignment_error method is used to report problems with unaligned data in formats that require aligned data.
void | fatal_hole_error (unsigned long lo, unsigned long hi)
| The fatal_hole_error method is used to report problems with holes in the data, for formats that cannot cope with them.
void | data_address_too_large (const record &record, unsigned nbits) const
| The data_address_too_large method is used to report fatal problems with data records, in the case where some or all of the address span of a record falls outside the format's ability to represent addresses.
Protected Member Functions inherited from srecord::output
| output ()
| The default constructor.

## Static Protected Member Functions
static void | enable_optional_address (bool yesno)
| The enable_footer class method is used to enable or disable emitting optional address records.
static line_termination_t | line_termination_guess (void)
| The line_termination_guess class method is used to figure out the line termination style of the host environment.

## Protected Attributes
int | checksum
| The checksum instance variable is used record the running checksum.

## Static Protected Attributes
void static bool | enable_header_flag
| The enable_header_flag class variable is set by the enable_header method, to remember whether or not header records are to be emitted (if the format supports optional header records).
static bool | enable_data_count_flag
| The enable_data_count_flag class variable is set by the enable_data_count method, to remember whether or not data record count records are to be emitted (if the format supports optional data record count records).
static bool | enable_goto_addr_flag
| The enable_goto_addr_flag class variable is set by the enable_goto_addr method, to remember whether or not execution start address records are to be emitted (if the format supports optional execution start address records).
static bool | enable_footer_flag
| The enable_footer_flag class variable is set by the enable_footer method, to remember whether or not footer records (end-of-file record) are to be emitted (if the format supports optional footer records).
static bool | enable_optional_address_flag
| The enable_optional_address_records class variable is used to remember whether or not to emit optional address records.
static line_termination_t | line_termination
| The line_termination class variable is used to remember the desired line termination style.

## Additional Inherited Members
Public Types inherited from srecord::output
typedef std::shared_ptr< output > | pointer

## Detailed Description

The srecord::output_file class is used to represent a generic output file.

It provides a numnber of services useful to many output file formats.

Definition at line 33 of file file.h.

## Member Enumeration Documentation

## ◆ line_termination_t

enum srecord::output_file::line_termination_t
| protected

Enumerator
line_termination_native |
line_termination_crlf |
line_termination_nl |
line_termination_binary |
line_termination_cr |
line_termination_primos |

Definition at line 313 of file file.h.

## Constructor & Destructor Documentation

## ◆ ~output_file()

virtual srecord::output_file::~output_file | ( |  | ) |
| virtual

The destructor.

## ◆ output_file() [1/2]

srecord::output_file::output_file | ( |  | ) |

The default constructor.

Output will be sent to the standard output.

Referenced by data_address_too_large(), srecord::output_file_ti_tagged::format_name(), and srecord::output_file_ti_tagged_16::format_name().

## ◆ output_file() [2/2]

srecord::output_file::output_file | ( | const std::string & | file_name | ) |

The constructor.

The output will be sent to the named file (or the standard output if the file name is "-").

Parameters

  file_name | The name of the file to be written.

## Member Function Documentation

## ◆ filename()

virtual const std::string srecord::output_file::filename | ( | void |  | ) | const
| virtual

The filename method is used to determine the name of the output file.

It is used for the various error messages. Derived classes must implement this method.

Implements srecord::output.

## ◆ enable_header()

void srecord::output_file::enable_header | ( | bool | yesno | ) |
| static

The enable_header class method is used to enable or disable the writing of header records into output file, if the format supports optional header records.

Parameters

  yesno | true if header records should be written, false if not

## ◆ enable_data_count()

void srecord::output_file::enable_data_count | ( | bool | yesno | ) |
| static

The enable_data_count class method is used to enable or disable the writing of data record count records into output file, if the format supports optional data record count records.

Parameters

  yesno | true if data record count records should be written, false if not

## ◆ enable_goto_addr()

void srecord::output_file::enable_goto_addr | ( | bool | yesno | ) |
| static

The enable_goto_addr class method is used to enable or disable the writing of execution start address records into output file, if the format supports optional execution start address records.

Parameters

  yesno | true if execution start address records should be written, false if not

## ◆ enable_footer()

void srecord::output_file::enable_footer | ( | bool | yesno | ) |
| static

The enable_footer class method is used to enable or disable the writing of footer records into output file, if the format supports optional footer records.

Parameters

  yesno | true if footer records should be written, false if not

## ◆ enable_by_name()

bool srecord::output_file::enable_by_name | ( | const std::string & | name,
|  | bool | yesno )
| static

The enable_by_name class method is used to enable or disable the writing of various records into output file.

Parameters

  name | the name of the record type to enable or disable
  yesno | true if should be enable, false if sjould be disabled

Returns
  true if name understood, false if not (to trigger diagnostic error message)

## ◆ line_termination_by_name()

bool srecord::output_file::line_termination_by_name | ( | const std::string & | name | ) |
| static

The line_termination_by_name method is used to force line termination to a particular style, rather than the current operating system's native text format.

Parameters

  name | The name of the line termination style to be used, e.g. "crlf" or "nl".

Returns
  true if successful, false if name unknown

## ◆ put_char()

virtual void srecord::output_file::put_char | ( | int | c | ) |
| protectedvirtual

The put_char method is used to send a character to the output.

Usually, this is sufficient, however derived classes may over-ride it if they have a special case. Over-ride with caution, as it affects many other methods.

Reimplemented in srecord::output_file_ti_tagged, and srecord::output_file_ti_tagged_16.

## ◆ put_nibble()

void srecord::output_file::put_nibble | ( | int | value | ) |
| protected

The put_nibble method is used to send a hexadecimal digit (0..9, A..F) to the output.

It calls put_char to send the output.

## ◆ put_byte()

virtual void srecord::output_file::put_byte | ( | unsigned char | value | ) |
| protectedvirtual

The put_byte method is used to send a byte value to the output.

The default implementation is to call the put_nibble method twice, big-endian (most significant nibble first).

The value of the byte will be added to the running checksum, via the checksum_add method.

Usually, this put_byte method implemention is sufficient for most output classes, however derived classes may over-ride it if they have a special case. Over-ride with caution, as it affects many other methods.

Reimplemented in srecord::output_file_stewie, srecord::output_file_tektronix, and srecord::output_file_wilson.

## ◆ put_word_be()

virtual void srecord::output_file::put_word_be | ( | int | value | ) |
| protectedvirtual

The put_word_be method is used to send a 16-bit value to the output.

The put_byte method is called twice, and the two byte values are sent big-endian (most significant byte first).

## ◆ put_word_le()

virtual void srecord::output_file::put_word_le | ( | int | value | ) |
| protectedvirtual

The put_word_le method is used to send a 16-bit value to the output.

The put_byte method is called twice, and the two byte values are sent little-endian (least significant byte first).

## ◆ put_3bytes_be()

virtual void srecord::output_file::put_3bytes_be | ( | unsigned long | value | ) |
| protectedvirtual

The put_3bytes_be method is used to send a 24-bit value to the output.

The put_byte method is called three times, and the three byte values are sent big-endian (most significant byte first).

## ◆ put_3bytes_le()

virtual void srecord::output_file::put_3bytes_le | ( | unsigned long | value | ) |
| protectedvirtual

The put_3bytes_le method is used to send a 24-bit value to the output.

The put_byte method is called three times, and the three byte values are sent little-endian (least significant byte first).

## ◆ put_4bytes_be()

virtual void srecord::output_file::put_4bytes_be | ( | unsigned long | value | ) |
| protectedvirtual

The put_4bytes_be method is used to send a 32-bit value to the output.

The put_byte method is called four times, and the four byte values are sent big-endian (most significant byte first).

## ◆ put_4bytes_le()

virtual void srecord::output_file::put_4bytes_le | ( | unsigned long | value | ) |
| protectedvirtual

The put_4bytes_le method is used to send a 32-bit value to the output.

The put_byte method is called four times, and the four byte values are sent little-endian (least significant byte first).

## ◆ checksum_reset()

void srecord::output_file::checksum_reset | ( | void |  | ) |
| protected

The checksum_reset method is used to set the running checksum to zero.

## ◆ checksum_add()

virtual void srecord::output_file::checksum_add | ( | unsigned char | n | ) |
| protectedvirtual

The checksum_add method is used to add another 8-bit value to the running checksum.

The default implementation uses a simple addition. Derived classesmay override if they need to. Do this with caution, as it affects other methods.

Reimplemented in srecord::output_file_signetics.

## ◆ checksum_get()

int srecord::output_file::checksum_get | ( | void |  | ) |
| protected

The checksum_get method is used to get the current value of the running checksum (added to by the checksum_add method, usually called by the put_byte method).

Only the lower 8 bits of the sum are returned.

## ◆ checksum_get16()

int srecord::output_file::checksum_get16 | ( | void |  | ) |
| protected

The checksum_get16 method is used to get the current value of the running checksum (added to by the checksum_add method, usually called by the put_byte method).

Only the lower 16 bits of the sum are returned.

## ◆ seek_to()

void srecord::output_file::seek_to | ( | unsigned long |  | ) |
| protected

The seek_to method is used to move the output position to the specified location in the output file.

## ◆ put_string() [1/2]

void srecord::output_file::put_string | ( | const char * | text | ) |
| protected

The put_string method is used to send a nul-terminated C string to the output.

Multiple calls to put_char are made.

## ◆ put_string() [2/2]

void srecord::output_file::put_string | ( | const std::string & | text | ) |
| protected

The put_string method is used to send C++ string to the output.

Multiple calls to put_char are made.

Parameters

  text | The string to print.

## ◆ put_stringf()

void srecord::output_file::put_stringf | ( | const char * | ,
|  |  | ... )
| protected

The put_stringf method is used to send a formatted string to the output.

The format and operation ios similar to the standard printf function. Multiple calls to put_char are made.

References FORMAT_PRINTF.

## ◆ enable_optional_address()

void srecord::output_file::enable_optional_address | ( | bool | yesno | ) |
| staticprotected

The enable_footer class method is used to enable or disable emitting optional address records.

Parameters

  yesno | true if records should be written, false if not

References enable_optional_address().

Referenced by enable_optional_address().

## ◆ line_termination_guess()

line_termination_t srecord::output_file::line_termination_guess | ( | void |  | ) |
| staticprotected

The line_termination_guess class method is used to figure out the line termination style of the host environment.

## ◆ fatal_alignment_error()

void srecord::output_file::fatal_alignment_error | ( | int | alignment | ) |
| protected

The fatal_alignment_error method is used to report problems with unaligned data in formats that require aligned data.

It suggests a fill to fix the problem.

Parameters

  alignment | The necessary byte alignment

## ◆ fatal_hole_error()

void srecord::output_file::fatal_hole_error | ( | unsigned long | lo,
|  | unsigned long | hi )
| protected

The fatal_hole_error method is used to report problems with holes in the data, for formats that cannot cope with them.

## ◆ data_address_too_large()

void srecord::output_file::data_address_too_large | ( | const record & | record,
|  | unsigned | nbits ) const
| protected

The data_address_too_large method is used to report fatal problems with data records, in the case where some or all of the address span of a record falls outside the format's ability to represent addresses.

Parameters

  record | The offending data record.
  nbits | The number of bits in the available address range

References output_file().

## Member Data Documentation

## ◆ enable_header_flag

void static bool srecord::output_file::enable_header_flag
| staticprotected

The enable_header_flag class variable is set by the enable_header method, to remember whether or not header records are to be emitted (if the format supports optional header records).

Definition at line 271 of file file.h.

## ◆ enable_data_count_flag

bool srecord::output_file::enable_data_count_flag
| staticprotected

The enable_data_count_flag class variable is set by the enable_data_count method, to remember whether or not data record count records are to be emitted (if the format supports optional data record count records).

Definition at line 279 of file file.h.

## ◆ enable_goto_addr_flag

bool srecord::output_file::enable_goto_addr_flag
| staticprotected

The enable_goto_addr_flag class variable is set by the enable_goto_addr method, to remember whether or not execution start address records are to be emitted (if the format supports optional execution start address records).

Definition at line 287 of file file.h.

## ◆ enable_footer_flag

bool srecord::output_file::enable_footer_flag
| staticprotected

The enable_footer_flag class variable is set by the enable_footer method, to remember whether or not footer records (end-of-file record) are to be emitted (if the format supports optional footer records).

Definition at line 295 of file file.h.

## ◆ enable_optional_address_flag

bool srecord::output_file::enable_optional_address_flag
| staticprotected

The enable_optional_address_records class variable is used to remember whether or not to emit optional address records.

Defaults to true. Set by the enable_by_name method.

Definition at line 302 of file file.h.

## ◆ line_termination

line_termination_t srecord::output_file::line_termination
| staticprotected

The line_termination class variable is used to remember the desired line termination style.

Defaults to the native style of the current operating system.

Definition at line 328 of file file.h.

## ◆ checksum

int srecord::output_file::checksum
| protected

The checksum instance variable is used record the running checksum.

NEVER access this variable directly. Always use the checksum_reset method to set it mack to its initial state. Always use the checksum_add method to add a byte to it. Always use the checksum_get or checksum_get16 methods to read its value.

Definition at line 369 of file file.h.

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

- output/file.h