srecord  1.65.0
byte_swap.h
Go to the documentation of this file.
1 //
2 // srecord - manipulate eprom load files
3 // Copyright (C) 2000-2002, 2005-2010 Peter Miller
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it 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
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public 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
17 // <http://www.gnu.org/licenses/>.
18 //
19 
20 #ifndef SRECORD_INPUT_FILTER_BYTE_SWAP_H
21 #define SRECORD_INPUT_FILTER_BYTE_SWAP_H
22 
23 #include <srecord/input/filter.h>
24 #include <srecord/record.h>
25 
26 namespace srecord {
27 
28 /**
29  * The srecord::input_filter_byte_swap class is used to reverse the
30  * even-addressed and odd-addressed bytes in an input source.
31  */
33  public input_filter
34 {
35 public:
36  /**
37  * The destructor.
38  */
40 
41 private:
42  /**
43  * The constructor.
44  *
45  * @param deeper
46  * The incoming data sourec to be byte-swapped.
47  */
49 
50 public:
51  /**
52  * The create class method is used to create new dynamically
53  * allocated instances of this class.
54  *
55  * @param deeper
56  * The incoming data sourec to be byte-swapped.
57  */
58  static pointer create(const input::pointer &deeper);
59 
60 protected:
61  // See base class for documentation.
62  bool read(record &record);
63 
64  // See base class for documentation.
65  void command_line(arglex_tool *cmdln);
66 
67 private:
68  /**
69  * The buffer instance variable is used to remember the data
70  * fetched from the deeper data source.
71  */
72  record buffer;
73 
74  /**
75  * The buffer_pos instance variable is used to remeber the byte
76  * position within the buffer instance variable.
77  */
78  size_t buffer_pos;
79 
80  /**
81  * The mask instance variable is used to remember the bit mask to
82  * be xor-ed with the address to form the byte-swapped address.
83  * It defaults to 1, but can be altered by command line option.
84  */
85  record::address_t mask;
86 
87  /**
88  * The default constructor. Do not use.
89  */
91 
92  /**
93  * The copy constructor. Do not use.
94  */
96 
97  /**
98  * The assignment operator. Do not use.
99  */
101 };
102 
103 };
104 
105 #endif // SRECORD_INPUT_FILTER_BYTE_SWAP_H
The srecord::arglex_tool is used to parse command line with srec-specific arguments.
Definition: tool.h:41
The srecord::input_filter_byte_swap class is used to reverse the even-addressed and odd-addressed byt...
Definition: byte_swap.h:34
void command_line(arglex_tool *cmdln)
The command_line method is used by arglex_srec::get_input when parsing the command line,...
virtual ~input_filter_byte_swap()
The destructor.
bool read(record &record)
The read method is used to read one record from the input.
static pointer create(const input::pointer &deeper)
The create class method is used to create new dynamically allocated instances of this class.
The srecord::input_filter class is an abstract interface for all of the various filters that can be a...
Definition: filter.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
uint32_t address_t
The type of record addresses.
Definition: record.h:58