srecord  1.65.0
trs80.h
Go to the documentation of this file.
1 //
2 // srecord - manipulate eprom load files
3 // Copyright (C) 2012 Peter Miller
4 //
5 // Code contribution by Eric Smith <eric@brouhaha.com>
6 // Copyright assigned to Peter Miller 15-Mar-2012.
7 //
8 // This program is free software; you can redistribute it and/or modify it
9 // under the terms of the GNU Lesser General Public License as published by
10 // the Free Software Foundation; either version 3 of the License, or (at your
11 // option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful, but WITHOUT
14 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16 // for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public License
19 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 //
21 
22 #ifndef SRECORD_OUTPUT_FILE_TRS80_H
23 #define SRECORD_OUTPUT_FILE_TRS80_H
24 
25 #include <srecord/output/file.h>
26 
27 namespace srecord
28 {
29 
30 /**
31  * The srecord::output_file_trs80 class is used to write a TRS-80 binary
32  * file.
33  */
35  public output_file
36 {
37 public:
38  /**
39  * The destructor.
40  */
41  virtual ~output_file_trs80();
42 
43 private:
44  /**
45  * A constructor. The input will be read from the named file (or
46  * the standard input if the file name is "-"). It is private on
47  * purpose, use the create class method intead.
48  *
49  * @param file_name
50  * The name of the file to be written.
51  */
52  output_file_trs80(const std::string &file_name);
53 
54 public:
55  /**
56  * The create class method is used to create new dynamically
57  * allocated instances of this class. The input will be read from
58  * the named file (or the standard input if the file name is "-").
59  *
60  * @param file_name
61  * The name of the file to be written.
62  */
63  static pointer create(const std::string &file_name);
64 
65 protected:
66  // See base class for documentation.
67  void write(const record &);
68 
69  // See base class for documentation.
71 
72  // See base class for documentation.
73  bool preferred_block_size_set(int nbytes);
74 
75  // See base class for documentation.
76  void line_length_set(int);
77 
78  // See base class for documentation.
79  void address_length_set(int);
80 
81  // See base class for documentation.
82  const char *format_name() const;
83 
84  // See base class for documentation.
85  bool is_binary(void) const;
86 
87 private:
88  /**
89  * The termination_seen instance variable is used to remember
90  * whether or not a termination record has been seen yet.
91  */
92  bool termination_seen;
93 
94  /**
95  * See base class for documentation. We are over-riding it because
96  * we use raw binary, so we call the put_char() method. This
97  * method also tracks the byte_offset, so that we can align to
98  * specific boundaries. Calls the checksum_add() method.
99  */
100  void put_byte(unsigned char);
101 
102  /**
103  * The byte_offset instance variable is used to track the location
104  * in the output file. Maintained by the put_byte() method.
105  */
106  unsigned long byte_offset;
107 
108  /**
109  * The pref_block_size is used to remember the preferred
110  * block size. Set by the constructor. Read by the
111  * preferred_block_size_get() method.
112  */
113  int pref_block_size;
114 
115  /**
116  * The preferred_block_size_calculate method is used to determine
117  * the best block size to pack into 512 byte blocks.
118  */
119  static int preferred_block_size_calculate();
120 
121  /**
122  * The default constructor. Do not use.
123  */
125 
126  /**
127  * The copy constructor. Do not use.
128  */
130 
131  /**
132  * The assignment operator. Do not use.
133  */
134  output_file_trs80 &operator=(const output_file_trs80 &);
135 };
136 
137 };
138 
139 // vim: set ts=8 sw=4 et :
140 #endif // SRECORD_OUTPUT_FILE_TRS80_H
The srecord::output_file_trs80 class is used to write a TRS-80 binary file.
Definition: trs80.h:36
bool is_binary(void) const
The is_binary method is used to to determine whether or not a file format is binary (true) of text (f...
int preferred_block_size_get() const
The preferred_block_size_get method is used to get the proferred block size of the output fformat.
const char * format_name() const
The format_name method is used to obtain the name of this output format.
void address_length_set(int)
The address_length_set method is used to set the minimum number of bytes to be written for addresses ...
void line_length_set(int)
The set_line_length method is used to set the maximum length of an output line, for those formats for...
static pointer create(const std::string &file_name)
The create class method is used to create new dynamically allocated instances of this class.
virtual ~output_file_trs80()
The destructor.
bool preferred_block_size_set(int nbytes)
The preferred_block_size_set method is is to set a precific number of bytes for the preferred block s...
void write(const record &)
The write method is used to write a recordonto an output.
The srecord::output_file class is used to represent a generic output file.
Definition: file.h:35
std::shared_ptr< output > pointer
Definition: output.h:41
The srecord::record class is used to represent a data record read from a file.
Definition: record.h:35