srecord 1.65.0
 
Loading...
Searching...
No Matches
formatted_binary.h
Go to the documentation of this file.
1//
2// srecord - manipulate eprom load files
3// Copyright (C) 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_FORMATTED_BINARY_H
20#define SRECORD_INPUT_FILE_FORMATTED_BINARY_H
21
22#include <srecord/input/file.h>
23
24namespace srecord {
25
26/**
27 * The srecord::input_file_formatted_binary class is used to represent the
28 * parse state when reading a file in the Formatted Binary format.
29 */
30class input_file_formatted_binary:
31 public input_file
32{
33public:
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 file_name
44 * The name of the file to be read.
45 * @returns
46 * smart pointer to new instance
47 */
48 static pointer create(const std::string &file_name);
49
50protected:
51 // See base class for documentation.
53
54 // See base class for documentation.
55 const char *get_file_format_name(void) const;
56
57 // See base class for documentation.
58 bool is_binary(void) const;
59
60 // See base class for documentation.
61 int format_option_number(void) const;
62
63private:
64 /**
65 * The constructor.
66 *
67 * @param file_name
68 * The name of the file to be read.
69 */
70 input_file_formatted_binary(const std::string &file_name);
71
72 /**
73 * The header_seen instance variable is used to remember whether
74 * the file header has been seen yet.
75 */
76 bool header_seen;
77
78 /**
79 * The upper_bound instance variable is used to remember how long
80 * the header said the file was going to be.
81 */
82 unsigned long upper_bound;
83
84 /**
85 * The address instance variable is used to remember where we are
86 * up to in extracting the data from the file.
87 */
88 unsigned long address;
89
90 /**
91 * The trailer_seen instance variable is used to remember whether
92 * the file trailer has been seen yet.
93 */
94 bool trailer_seen;
95
96 /**
97 * The check_sum instance variable is used to remember the simple
98 * sum of the data bytes in the file.
99 */
100 unsigned short check_sum;
101
102 /**
103 * The default constructor.
104 */
105 input_file_formatted_binary();
106
107 /**
108 * The copy constructor.
109 */
110 input_file_formatted_binary(const input_file_formatted_binary &);
111
112 /**
113 * The assignment operator.
114 */
115 input_file_formatted_binary &operator=(const input_file_formatted_binary &);
116};
117
118};
119
120#endif // SRECORD_INPUT_FILE_FORMATTED_BINARY_H
121// vim: set ts=8 sw=4 et :
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 &file_name)
The create class method is used to create new dynamically allocated instances of this class.
bool read(record &record)
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...
virtual ~input_file_formatted_binary()
The destructor.
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...
input_file(const std::string &file_name)
The constructor.
std::shared_ptr< input_file > pointer
Definition file.h:39
The srecord::record class is used to represent a data record read from a file.
Definition record.h:35