srecord  1.65.0
four_packed_code.h
Go to the documentation of this file.
1 //
2 // srecord - manipulate eprom load files
3 // Copyright (C) 2001-2003, 2006-2008, 2010, 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 Lesser General Public
13 // 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_INPUT_FILE_FOUR_PACKED_CODE_H
20 #define SRECORD_INPUT_FILE_FOUR_PACKED_CODE_H
21 
22 #include <srecord/input/file.h>
23 
24 namespace srecord {
25 
26 /**
27  * The srecord::input_file_four_packed_code represents an input file in
28  * the four packed code (FPC) format. For extra points: who invented
29  * this format? Where is it used?
30  */
32  public input_file
33 {
34 public:
35  /**
36  * The destructor.
37  */
39 
40  /**
41  * The create class method is used to create new dynamically
42  * allocated instances of this class.
43  *
44  * @param file_name
45  * The name of the file to be read.
46  * @returns
47  * smart pointer to new instance
48  */
49  static pointer create(const std::string &file_name);
50 
51 protected:
52  // See base class for documentation.
53  bool read(record &record);
54 
55  // See base class for documentation.
56  const char *get_file_format_name(void) const;
57 
58  // See base class for documentation.
59  int format_option_number(void) const;
60 
61 private:
62  /**
63  * The constructor. The input will be read from the named file
64  * (or the standard input if the name is "-").
65  *
66  * @param file_name
67  * The name of the file to be read.
68  */
69  input_file_four_packed_code(const std::string &file_name);
70 
71  /**
72  * The read_inner method is used to read a record (one line)
73  * from the input file. Lines which don't start with "$"
74  * will be ignored.
75  */
76  bool read_inner(record &);
77 
78  /**
79  * See base class for documentation. We override the default
80  * implementation because we have to decode 5 characters (four
81  * bytes) at a time. The usual get_word (etc) continue to work
82  * without additional modifications.
83  */
84  int get_byte(void);
85 
86  /**
87  * The get_digit method is used to fetch one base85 digit from
88  * the input.
89  */
90  int get_digit(void);
91 
92  /**
93  * The get_byte_pos instance variable is used by the get_byte
94  * method to track where were are positioned within the
95  * 5-character (4-byte) input multiple. (Only the get_byte
96  * method may use this instance variable.)
97  */
98  unsigned get_byte_pos;
99 
100  /**
101  * The get_byte_value instance variable is used by the bet_byte
102  * method to method to hold the value of a 5-character (4-byte)
103  * input multiple. (Only the get_byte method may use this
104  * instance variable.)
105  */
106  unsigned long get_byte_value;
107 
108  /**
109  * The garbage_waring instance variable is used by the read
110  * method to record whether or not a warning about non-format
111  * lines has been issued (only one warning is issued per file).
112  */
113  bool garbage_warning;
114 
115  /**
116  * The seen_some_input instance variable is used by the read
117  * and read_inner methods to record whether or not any valid
118  * input has been seen.
119  */
120  bool seen_some_input;
121 
122  /**
123  * The running_address instance variable method is used by the
124  * read_inner method to record the current address. This is
125  * so that record types 1 and 2 can be processed accurately.
126  */
127  unsigned long running_address;
128 
129  /**
130  * The default constructor. Do not use.
131  */
133 
134  /**
135  * The copy constructor. Do not use.
136  */
138 
139  /**
140  * The assignment operator. Do not use.
141  */
143 };
144 
145 };
146 
147 #endif // SRECORD_INPUT_FILE_FOUR_PACKED_CODE_H
148 // vim: set ts=8 sw=4 et :
The srecord::input_file_four_packed_code represents an input file in the four packed code (FPC) forma...
bool read(record &record)
The read method is used to read one record from the input.
static pointer create(const std::string &file_name)
The create class method is used to create new dynamically allocated instances of this class.
virtual ~input_file_four_packed_code()
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.
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
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