|
| 1 | +// |
| 2 | +// Copyright (c) 2023 fenugrec |
| 3 | +// |
| 4 | +// srecord filter: exchanges upper and lower nibble of each byte, |
| 5 | +// e.g. "0xA6" => "0x6A" |
| 6 | +// |
| 7 | +// This program is free software; you can redistribute it and/or modify |
| 8 | +// it under the terms of the GNU Lesser General Public License as published by |
| 9 | +// the Free Software Foundation; either version 3 of the License, or (at |
| 10 | +// your option) any later version. |
| 11 | +// |
| 12 | +// This program is distributed in the hope that it will be useful, |
| 13 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | +// General Public License for more details. |
| 16 | +// |
| 17 | +// You should have received a copy of the GNU Lesser General Public License |
| 18 | +// along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | +// |
| 20 | + |
| 21 | +#ifndef SRECORD_INPUT_FILTER_NIBBLE_SWAP_H |
| 22 | +#define SRECORD_INPUT_FILTER_NIBBLE_SWAP_H |
| 23 | + |
| 24 | +#include <srecord/input/filter.h> |
| 25 | + |
| 26 | +namespace srecord { |
| 27 | + |
| 28 | +/** |
| 29 | + * The srecord::input_filter_nibble_swap class is used to represent the |
| 30 | + * input state of a filter which swaps upper/lower nibbles of each byte. |
| 31 | + */ |
| 32 | +class input_filter_nibble_swap: |
| 33 | + public input_filter |
| 34 | +{ |
| 35 | +public: |
| 36 | + /** |
| 37 | + * The destructor. |
| 38 | + */ |
| 39 | + ~input_filter_nibble_swap() override = default; |
| 40 | + |
| 41 | +private: |
| 42 | + /** |
| 43 | + * The constructor. |
| 44 | + * |
| 45 | + * @param deeper |
| 46 | + * The deeper input to be used as a data source. |
| 47 | + */ |
| 48 | + input_filter_nibble_swap(const input::pointer &deeper); |
| 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 source to be filtered |
| 57 | + */ |
| 58 | + static pointer create(const input::pointer &deeper); |
| 59 | + |
| 60 | +protected: |
| 61 | + // See base class for documentation. |
| 62 | + bool read(record &record) override; |
| 63 | + |
| 64 | +public: |
| 65 | + /** |
| 66 | + * The default constructor. |
| 67 | + */ |
| 68 | + input_filter_nibble_swap() = delete; |
| 69 | + |
| 70 | + /** |
| 71 | + * The copy constructor. |
| 72 | + */ |
| 73 | + input_filter_nibble_swap(const input_filter_nibble_swap &) = delete; |
| 74 | + |
| 75 | + /** |
| 76 | + * The assignment operator. |
| 77 | + */ |
| 78 | + input_filter_nibble_swap &operator= \ |
| 79 | + (const input_filter_nibble_swap &) = delete; |
| 80 | +}; |
| 81 | + |
| 82 | +}; |
| 83 | + |
| 84 | +#endif |
0 commit comments