srecord: output/file/ppb.h Source File

srecord 1.65.0

Loading...
Searching...
No Matches
ppb.h
Go to the documentation of this file.
1//
2// srecord - Manipulate EPROM load files
3// Copyright (C) 2011 Peter Miller
4//
5// This program is free software; you can redistribute it and/or modify it
6// 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 your
8// option) any later version.
9//
10// This program is distributed in the hope that it will be useful, but WITHOUT
11// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13// 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_PPB_H
20#define SRECORD_OUTPUT_FILE_PPB_H
21
22#include <srecord/output/file.h>
23
24namespace srecord {
25
26/**
27 * The output_file_ppb class is used to represent the processing
28 * required to write a Stag Prom Programmer binary file.
29 */
30 class output_file_ppb:
31 public output_file
32{
33public:
34 /**
35 * The destructor.
36 */
37 virtual ~output_file_ppb();
38
39 /**
40 * The create class method is used to create new dynamically
41 * allocated instances of this class.
42 *
43 * @param file_name
44 * The name of the file to be written.
45 */
46 static pointer create(const std::string &file_name);
47
48protected:
49 // See base class for documentation.
50 void write(const record &);
51
52 // See base class for documentation.
53 void line_length_set(int);
54
55 // See base class for documentation.
56 void address_length_set(int);
57
58 // See base class for documentation.
59 int preferred_block_size_get(void) const;
60
61 // See base class for documentation.
62 bool preferred_block_size_set(int nbytes);
63
64 // See base class for documentation.
65 const char *format_name(void) const;
66
67 // See base class for documentation.
68 bool is_binary(void) const;
69
70private:
71 /**
72 * The constructor. It is private on purpose, use the #create
73 * class method instead.
74 *
75 * @param file_name
76 * The name of the file to be written. The special name "-"
77 * indicates the standard output is to be used.
78 */
79 output_file_ppb(const std::string &file_name);
80
81 /**
82 * The address instance variable is used to remember the address of
83 * the next data byte to be parsed.
84 */
85 unsigned long address;
86
87 /**
88 * The buffer instance variable is used to remember the accumulated
89 * data bytes to be written to the file.
90 */
91 unsigned char buffer[8192];
92
93 /**
94 * The buffer_length instance variable is used to remember how many
95 * bytes are valid in the #buffer array.
96 */
97 unsigned buffer_length;
98
99 /**
100 * The seen_some_data instance variable is used to remember whether
101 * or not any data has been written to the file yet.
102 */
103 bool seen_some_data;
104
105 /**
106 * The buffer_flush method is used to write out the #buffer_length
107 * bytes in the #buffer instance variable.
108 */
109 void buffer_flush(void);
110
111 /**
112 * The packet method is used to write out the #buffer as an
113 * appropriately constructed packet.
114 */
115 void packet(unsigned long address, const unsigned char *data,
116 size_t data_size);
117
118 /**
119 * The put_bin_4be method is used to write out 4 binary bytes of a
120 * 32-bit value, big endian ordering.
121 */
122 void put_bin_4be(unsigned long value);
123
124 /**
125 * 8-bit checksum a 4 byte sequence.
126 */
127 unsigned char sum_ulong(unsigned long value, unsigned char sum);
128
129 /**
130 * The default constructor. Do not use.
131 */
132 output_file_ppb();
133
134 /**
135 * The copy constructor. Do not use.
136 */
137 output_file_ppb(const output_file_ppb &);
138
139 /**
140 * The assignment operator. Do not use.
141 */
142 output_file_ppb &operator=(const output_file_ppb &);
143};
144
145};
146
147// vim: set ts=8 sw=4 et :
148#endif // SRECORD_OUTPUT_FILE_PPB_H
srecord::output_file_ppb::~output_file_ppb
virtual ~output_file_ppb()
The destructor.
srecord::output_file_ppb::is_binary
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...
srecord::output_file_ppb::preferred_block_size_get
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.
srecord::output_file_ppb::address_length_set
void address_length_set(int)
The address_length_set method is used to set the minimum number of bytes to be written for addresses ...
srecord::output_file_ppb::preferred_block_size_set
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...
srecord::output_file_ppb::line_length_set
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...
srecord::output_file_ppb::write
void write(const record &)
The write method is used to write a recordonto an output.
srecord::output_file_ppb::create
static pointer create(const std::string &file_name)
The create class method is used to create new dynamically allocated instances of this class.
srecord::output_file_ppb::format_name
const char * format_name(void) const
The format_name method is used to obtain the name of this output format.
srecord::output_file::output_file
output_file()
The default constructor.
srecord::output::pointer
std::shared_ptr< output > pointer
Definition output.h:41
srecord::record
The srecord::record class is used to represent a data record read from a file.
Definition record.h:35
srecord
Definition adler16.h:25
file.h