srecord 1.65.0
 
Loading...
Searching...
No Matches
mem.h
Go to the documentation of this file.
1//
2// srecord - Manipulate EPROM load files
3// Copyright (C) 2009-2012 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 (at
8// 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 GNU
13// 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 <http://www.gnu.org/licenses/>.
17//
18
19#ifndef SRECORD_OUTPUT_FILE_MEM_H
20#define SRECORD_OUTPUT_FILE_MEM_H
21
22#include <srecord/output/file.h>
23
24namespace srecord
25{
26
27/**
28 * The srecord::output_file_mem class is used to represent the output state
29 * of a file in Memory Initialization File Format (.mem Lattice).
30 */
31class output_file_mem:
32 public output_file
33{
34public:
35 /**
36 * The destructor.
37 */
39
40private:
41 /**
42 * The constructor. It is private on purpose, use the #create
43 * class method instead.
44 *
45 * @param file_name
46 * The name of the file to be written. The special name "-"
47 * indicates the standard output is to be used.
48 */
49 output_file_mem(const std::string &file_name);
50
51public:
52 /**
53 * The create class method is used to create new dynamically
54 * allocated instances of this class.
55 *
56 * @param file_name
57 * The name of the file to be written.
58 */
59 static pointer create(const std::string &file_name);
60
61protected:
62 // See base class for documentation
63 void write(const record &);
64
65 // See base class for documentation
66 void line_length_set(int);
67
68 // See base class for documentation
70
71 // See base class for documentation
72 int preferred_block_size_get(void) const;
73
74 // See base class for documentation.
75 bool preferred_block_size_set(int nbytes);
76
77 // See base class for documentation
79
80 // See base class for documentation.
81 const char *format_name(void) const;
82
83 // See base class for documentation.
84 void notify_upper_bound(unsigned long addr);
85
86private:
87 /**
88 * The address instance variable is used to remember the next
89 * memory address to be written. This is also used to detect holes
90 * in the input data.
91 */
92 unsigned long address;
93
94 /**
95 * The column instance variable i sused to remember the output text
96 * column. This is used to know when ti wrap lines.
97 */
98 int column;
99
100 /**
101 * The depth instance variable is used to remember how many bytes
102 * of data there is. Kind of broken, because we don't know this
103 * when the header is actually printed.
104 */
105 unsigned long depth;
106
107 /**
108 * The width instance variable is used to remember how many bits
109 * there are per data item. Default to 8 (traditional bytes).
110 */
111 unsigned width;
112
113 /**
114 * The width_in_bytes instance variable is used to remember how
115 * many bytes there are per data item. Defaults to 1.
116 */
117 unsigned width_in_bytes;
118
119 /**
120 * The actual_depth instance variable is used to remember how many
121 * bytes of data there were. This is printed in the footer.
122 */
123 unsigned long actual_depth;
124
125 /**
126 * The header_done instance variable is used to remember whether
127 * the emit_header method has already been called.
128 */
129 bool header_done;
130
131 /**
132 * The pref_blk_sz instance variable is used to remember the
133 * preferred block size, in bytes.
134 */
135 int pref_blk_sz;
136
137 /**
138 * The emit_header method is used to emit the file header,
139 * if necessary.
140 */
141 void emit_header(void);
142
143 /**
144 * The default constructor. Do not use.
145 */
146 output_file_mem();
147
148 /**
149 * The copy constructor. Do not use.
150 */
151 output_file_mem(const output_file_mem &);
152
153 /**
154 * The assignment operator. Do not use.
155 */
156 output_file_mem &operator=(const output_file_mem &);
157};
158
159};
160
161// vim: set ts=8 sw=4 et :
162#endif // SRECORD_OUTPUT_FILE_MEM_H
The srecord::arglex_tool is used to parse command line with srec-specific arguments.
Definition tool.h:41
static pointer create(const std::string &file_name)
The create class method is used to create new dynamically allocated instances of this class.
int preferred_block_size_get(void) const
The preferred_block_size_get method is used to get the proferred block size of the output fformat.
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 ...
const char * format_name(void) const
The format_name method is used to obtain the name of this output format.
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.
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...
void command_line(arglex_tool *cmdln)
The command_line method is used by arglex_srec::get_output when parsing the command line,...
virtual ~output_file_mem()
The destructor.
output_file()
The default constructor.
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