|
| 1 | +#include <odr/internal/oldms/structs/fib.hpp> |
| 2 | + |
| 3 | +#include <odr/internal/oldms/structs/fib_rg_fc_lcb.hpp> |
| 4 | +#include <odr/internal/util/byte_stream_util.hpp> |
| 5 | +#include <odr/internal/util/stream_util.hpp> |
| 6 | + |
| 7 | +namespace odr::internal { |
| 8 | + |
| 9 | +void oldms::read(std::istream &in, Fib &fib) { |
| 10 | + read(in, fib.base); |
| 11 | + |
| 12 | + util::byte_stream::read(in, fib.csw); |
| 13 | + if (fib.csw * 2 < sizeof(fib.fibRgW)) { |
| 14 | + throw std::runtime_error("Unexpected Fib.csw value: " + |
| 15 | + std::to_string(fib.csw)); |
| 16 | + } |
| 17 | + |
| 18 | + const std::streampos offsetFibRgW = in.tellg(); |
| 19 | + util::byte_stream::read(in, fib.fibRgW); |
| 20 | + in.seekg(offsetFibRgW + static_cast<std::streamoff>(fib.csw * 2)); |
| 21 | + |
| 22 | + util::byte_stream::read(in, fib.cslw); |
| 23 | + if (fib.cslw * 4 < sizeof(fib.fibRgLw)) { |
| 24 | + throw std::runtime_error("Unexpected Fib.cslw value: " + |
| 25 | + std::to_string(fib.cslw)); |
| 26 | + } |
| 27 | + |
| 28 | + const std::streampos offsetFibRgLw = in.tellg(); |
| 29 | + util::byte_stream::read(in, fib.fibRgLw); |
| 30 | + in.seekg(offsetFibRgLw + static_cast<std::streamoff>(fib.cslw * 4)); |
| 31 | + |
| 32 | + util::byte_stream::read(in, fib.cbRgFcLcb); |
| 33 | + |
| 34 | + const std::streampos offsetFibRgFcLcb = in.tellg(); |
| 35 | + in.seekg(offsetFibRgFcLcb + static_cast<std::streamoff>(fib.cbRgFcLcb * 8)); |
| 36 | + |
| 37 | + util::byte_stream::read(in, fib.cswNew); |
| 38 | + |
| 39 | + const std::streampos offsetFibRgCswNew = in.tellg(); |
| 40 | + read(in, fib.fibRgCswNew); |
| 41 | + in.seekg(offsetFibRgCswNew + static_cast<std::streamoff>(fib.cswNew * 2)); |
| 42 | + |
| 43 | + const std::uint16_t nFib = |
| 44 | + (fib.cswNew != 0) ? fib.fibRgCswNew.nFibNew : fib.base.nFib; |
| 45 | + |
| 46 | + in.seekg(offsetFibRgFcLcb); |
| 47 | + fib.fibRgFcLcb = read_fib_rg_fc_lcb(in, nFib); |
| 48 | +} |
| 49 | + |
| 50 | +} // namespace odr::internal |
0 commit comments