Ben Tyner | f5210bb | 2021-01-05 12:58:10 -0600 | [diff] [blame] | 1 | #include "primary_src.hpp" |
| 2 | |
| 3 | namespace attn |
| 4 | { |
| 5 | namespace pel |
| 6 | { |
| 7 | |
| 8 | PrimarySrc::PrimarySrc(Stream& pel) |
| 9 | { |
| 10 | unflatten(pel); |
| 11 | } |
| 12 | |
| 13 | void PrimarySrc::flatten(Stream& stream) const |
| 14 | { |
| 15 | stream << _header << _version << _flags << _reserved1B << _wordCount |
| 16 | << _reserved2B << _size; |
| 17 | |
| 18 | for (auto& word : _srcWords) |
| 19 | { |
| 20 | stream << word; |
| 21 | } |
| 22 | |
| 23 | stream.write(_asciiString.data(), _asciiString.size()); |
| 24 | } |
| 25 | |
| 26 | void PrimarySrc::unflatten(Stream& stream) |
| 27 | { |
| 28 | stream >> _header >> _version >> _flags >> _reserved1B >> _wordCount >> |
| 29 | _reserved2B >> _size; |
| 30 | |
| 31 | for (auto& word : _srcWords) |
| 32 | { |
| 33 | stream >> word; |
| 34 | } |
| 35 | |
| 36 | stream.read(_asciiString.data(), _asciiString.size()); |
| 37 | } |
| 38 | |
| 39 | void PrimarySrc::setSrcWords(std::array<uint32_t, numSrcWords> srcWords) |
| 40 | { |
| 41 | _srcWords = srcWords; |
| 42 | } |
| 43 | |
| 44 | void PrimarySrc::setAsciiString(std::array<char, asciiStringSize> asciiString) |
| 45 | { |
| 46 | _asciiString = asciiString; |
| 47 | } |
| 48 | |
| 49 | } // namespace pel |
| 50 | } // namespace attn |