srecord  1.65.0
hexdump.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_HEXDUMP_H
20 #define SRECORD_INPUT_FILE_HEXDUMP_H
21 
22 #include <srecord/input/file.h>
23 
24 namespace srecord {
25 
26 /**
27  * The input_file_hexdump class is used to represent the processing
28  * required to read in a hexadecimal dump.
29  */
31  public input_file
32 {
33 public:
34  /**
35  * The destructor.
36  */
38 
39  /**
40  * The create class method is used to create new dynamically
41  * allocated instances of this class.
42  *
43  * @param filename
44  * The name of the file to be read.
45  */
46  static pointer create(const std::string &filename);
47 
48 protected:
49  // See base class for documentation.
50  bool read(class record &rec);
51 
52  // See base class for documentation.
53  const char *get_file_format_name(void) const;
54 
55  // See base class for documentation.
56  int format_option_number(void) const;
57 
58 private:
59  /**
60  * The constructor.
61  *
62  * @param filename
63  * The name of the file to be read.
64  */
65  input_file_hexdump(const std::string &filename);
66 
67  enum token_t
68  {
69  token_eof,
70  token_byte,
71  token_colon,
72  token_eoln,
73  token_junk
74  };
75 
76  /**
77  * The get_next_token method is used to read the next lexical token
78  * from the input.
79  *
80  * It will set the #current_token_value instance variable for token_byte
81  */
82  token_t get_next_token(void);
83 
84  /**
85  * The discard_rest_of_line method is used to
86  * discard all characters until the next end of line character.
87  */
88  bool discard_rest_of_line(void);
89 
90  /**
91  * The address instance variable is used to remember the current
92  * address of the next data record. This is set and advanced by
93  * the #read method.
94  */
95  unsigned long address;
96 
97  /**
98  * The data_seen instance variable is used to remember whether or
99  * not any data has been seen in the file. This is used to issue
100  * an error when there is aparrently no data in the file, and this
101  * helps #guess to figure out the file is notof this type.
102  */
103  bool data_seen;
104 
105  /**
106  * The current_token_value instance variable is used to remember
107  * the value of the most recent token_byte seen.
108  */
109  unsigned current_token_value;
110 
111  /**
112  * The default constructor. Do not use.
113  */
115 
116  /**
117  * The copy constructor. Do not use.
118  */
120 
121  /**
122  * The assignment operator. Do not use.
123  */
124  input_file_hexdump &operator=(const input_file_hexdump &);
125 };
126 
127 };
128 
129 // vim: set ts=8 sw=4 et :
130 #endif // SRECORD_INPUT_FILE_HEXDUMP_H
The input_file_hexdump class is used to represent the processing required to read in a hexadecimal du...
Definition: hexdump.h:32
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...
bool read(class record &rec)
The read method is used to read one record from the input.
static pointer create(const std::string &filename)
The create class method is used to create new dynamically allocated instances of this class.
virtual ~input_file_hexdump()
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.
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