srecord  1.65.0
ti_txt.h
Go to the documentation of this file.
1 //
2 // srecord - manipulate eprom load files
3 // Copyright (C) 2007, 2008, 2010 Peter Miller
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this program. If not, see
17 // <http://www.gnu.org/licenses/>.
18 //
19 
20 #ifndef SRECORD_OUTPUT_FILE_ti_txt_H
21 #define SRECORD_OUTPUT_FILE_ti_txt_H
22 
23 #include <srecord/output/file.h>
24 
25 namespace srecord
26 {
27 
28 /**
29  * The srecord::output_file_ti_txt class is used to write a file in
30  * ti_txt (MSP430) format.
31  */
33  public output_file
34 {
35 public:
36  /**
37  * The destrutcor.
38  */
40 
41 private:
42  /**
43  * The constructor. It is private on purpose, use the #create
44  * class method instead.
45  *
46  * @param file_name
47  * The name of the file to be written. The special name "-"
48  * indicates the standard output is to be used.
49  */
50  output_file_ti_txt(const std::string &file_name);
51 
52 public:
53  /**
54  * The create class method is used to create new dynamically
55  * allocated instances of this class.
56  *
57  * @param file_name
58  * The name of the file to be written.
59  */
60  static pointer create(const std::string &file_name);
61 
62 protected:
63  // See base class for documentation.
64  void write(const record &);
65 
66  // See base class for documentation.
67  void line_length_set(int);
68 
69  // See base class for documentation.
70  void address_length_set(int);
71 
72  // See base class for documentation.
74 
75  // See base class for documentation.
76  bool preferred_block_size_set(int nbytes);
77 
78  // See base class for documentation.
79  const char *format_name() const;
80 
81 private:
82  /**
83  * The address instance variable is used to remember where we
84  * are up to in the output. Used to limit the number of @ lines
85  * emitted.
86  */
87  unsigned long address;
88 
89  /**
90  * The address_set instance variable is used to remember whether or
91  * not we have emitted the first address line. The first address,
92  * even if it is zero, is not optional.
93  */
94  bool address_set;
95 
96  /**
97  * The address_length instance variable is used to remember how
98  * many bytes of address to emit. Range: 2 to 4. Default: 2.
99  */
100  int address_length;
101 
102  /**
103  * The pref_block_size instance variable is used to remember the
104  * number of bytes in the preferred block size.
105  *
106  * The format definition says it must be exactly 16. We will allow
107  * some leeway.
108  */
109  int pref_block_size;
110 
111  /**
112  * The column instance variable is used to remember which column
113  * we are up to in the output. Used to limit the length of lines
114  * in the output.
115  */
116  int column;
117 
118  /**
119  * The line_length instance variable is used to remember how many
120  * columns wide the line is allowed to be.
121  *
122  * The format defintion says exactly 16 bytes per line (implying a
123  * line length 47 characters). We will allow some leeway.
124  */
125  int line_length;
126 
127  /**
128  * The put_byte_wrap method is used to write all data bytes to
129  * the file. It calls the put_byte method to do all the work,
130  * but first it checks to see if this byte will fit on the line,
131  * considering the line_length and throwing a newline if necessary.
132  * The address is advanced by one. The column is adjusted, too.
133  */
134  void put_byte_wrap(unsigned char c);
135 
136  /**
137  * The default constructor. Do not use.
138  */
140 
141  /**
142  * The copy constructor. Do not use.
143  */
145 
146  /**
147  * The assignment operator. Do not use.
148  */
149  output_file_ti_txt &operator=(const output_file_ti_txt &);
150 };
151 
152 };
153 
154 #endif // SRECORD_OUTPUT_FILE_ti_txt_H
The srecord::output_file_ti_txt class is used to write a file in ti_txt (MSP430) format.
Definition: ti_txt.h:34
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 address_length_set(int)
The address_length_set method is used to set the minimum number of bytes to be written for addresses ...
void write(const record &)
The write method is used to write a recordonto an output.
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.
static pointer create(const std::string &file_name)
The create class method is used to create new dynamically allocated instances of this class.
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...
virtual ~output_file_ti_txt()
The destrutcor.
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