blob: 01233954834c1b35f7e0c8632e53a6b8ff21555b [file] [log] [blame]
Ben Tynerf5210bb2021-01-05 12:58:10 -06001#include "primary_src.hpp"
2
3namespace attn
4{
5namespace pel
6{
7
8PrimarySrc::PrimarySrc(Stream& pel)
9{
10 unflatten(pel);
11}
12
13void 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
26void 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
39void PrimarySrc::setSrcWords(std::array<uint32_t, numSrcWords> srcWords)
40{
41 _srcWords = srcWords;
42}
43
44void PrimarySrc::setAsciiString(std::array<char, asciiStringSize> asciiString)
45{
46 _asciiString = asciiString;
47}
48
49} // namespace pel
50} // namespace attn