srecord  1.65.0
ppx.h
Go to the documentation of this file.
1 //
2 // srecord - Manipulate EPROM load files
3 // Copyright (C) 2011, 2013 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_INPUT_FILE_PPX_H
20 #define SRECORD_INPUT_FILE_PPX_H
21 
22 #include <srecord/input/file.h>
23 #include <srecord/record.h>
24 
25 namespace srecord {
26 
27 /**
28  * The input_file_hexdump class is used to represent the processing
29  * required to read in a Stag Prog Programmer hexadecimal file.
30  */
32  public input_file
33 {
34 public:
35  /**
36  * The destructor.
37  */
38  virtual ~input_file_ppx();
39 
40  /**
41  * The create class method is used to create new dynamically
42  * allocated instances of this class.
43  *
44  * @param filename
45  * The name of the file to be read.
46  */
47  static pointer create(const std::string &filename);
48 
49 protected:
50  // See base class for documentation.
51  bool read(class record &rec);
52 
53  // See base class for documentation.
54  const char *get_file_format_name(void) const;
55 
56  // See base class for documentation.
57  int format_option_number(void) const;
58 
59 private:
60  /**
61  * The constructor.
62  *
63  * @param filename
64  * The name of the file to be read.
65  */
66  input_file_ppx(const std::string &filename);
67 
68  /**
69  * The state instance variable is used to remember the current
70  * processing state as the file is progressively parsed. The parse
71  * is, of course, interrupted to return data records when they are seen.
72  */
73  int state;
74 
75  enum token_t
76  {
77  token_eof,
78  token_star,
79  token_address,
80  token_byte,
81  token_end,
82  token_sum,
83  };
84 
85  /**
86  * The token instance variable is used to remember the kind of the
87  * most recent token seen. Set by the #get_next_token method.
88  */
89  token_t token;
90 
91  /**
92  * The token_value instance variable is used to remember the value
93  * of the most recent token_byte or token_address seen.
94  * Set by the #get_next_token method.
95  */
96  unsigned token_value;
97 
98  /**
99  * The get_next_token method is used to read the next lexical token
100  * from the input.
101  * It will set #token with the kind of token seen.
102  * It will set the #token_value instance variable for token_byte
103  * and token_address
104  */
105  void get_next_token(void);
106 
107  /**
108  * The address instance variable is used to remember the current
109  * address of the next data record. This is set and advanced by
110  * the #read method.
111  */
112  record::address_t address;
113 
114  /**
115  * The data_seen instance variable is used to remember whether or
116  * not any data has been seen in the file. This is used to issue
117  * an error when there is aparrently no data in the file, and this
118  * helps #guess to figure out the file is notof this type.
119  */
120  bool data_seen;
121 
122  /**
123  * The syntax_error method is a convenience wrapper around
124  * #fatal_error to complain about syntax errors.
125  */
126  void syntax_error(void);
127 
128  /**
129  * The dsum instance variable is used to remember the simple sum of
130  * the data bytes, and the data bytes alone.
131  */
132  unsigned short dsum;
133 
134  /**
135  * The buffer instance variable is used to remember the most recent
136  * #buffer_length data bytes read from the file.
137  */
139 
140  /**
141  * The buffer_length instance variable is used to remember the
142  * number of data bytes in the #buffer array.
143  */
144  size_t buffer_length;
145 
146  /**
147  * The default constructor. Do not use.
148  */
149  input_file_ppx();
150 
151  /**
152  * The copy constructor. Do not use.
153  */
155 
156  /**
157  * The assignment operator. Do not use.
158  */
159  input_file_ppx &operator=(const input_file_ppx &);
160 };
161 
162 };
163 
164 // vim: set ts=8 sw=4 et :
165 #endif // SRECORD_INPUT_FILE_PPX_H
The input_file_hexdump class is used to represent the processing required to read in a Stag Prog Prog...
Definition: ppx.h:33
virtual ~input_file_ppx()
The destructor.
const char * get_file_format_name(void) const
The get_file_format_name method is used to find out the name of the file format being read.
static pointer create(const std::string &filename)
The create class method is used to create new dynamically allocated instances of this class.
bool read(class record &rec)
The read method is used to read one record from the input.
int format_option_number(void) const
The format_option_number method is used to obtain the option number, which can then be turned into te...
The srecord::input_file class is used to represent an generic input file.
Definition: file.h:37
virtual std::string filename(void) const
The filename method is used to get the name of the input file being processed.
std::shared_ptr< input > pointer
Definition: input.h:41
The srecord::record class is used to represent a data record read from a file.
Definition: record.h:35
@ max_data_length
The max_data_length is the largest number of data bytes which any record can hold.
Definition: record.h:348
uint8_t data_t
The type of record data values.
Definition: record.h:63
uint32_t address_t
The type of record addresses.
Definition: record.h:58