16 return readHeaderCode;
18 std::vector<std::pair<unsigned int, int> > entries;
24 std::istringstream lineStream(
line);
25 std::pair<unsigned int, int>
entry;
26 while (lineStream >>
entry.first >>
entry.second) {
29 entries.push_back(
entry);
31 maxAddress =
entry.first;
34 std::sort(entries.begin(), entries.end());
35 if (entries.empty()) {
40 if (std::adjacent_find(entries.begin(), entries.end(), [](
auto const&
a,
auto const&
b) {
41 return a.first ==
b.first;
42 }) != entries.end()) {
46 if (entries.front().first != 0 ||
47 std::adjacent_find(entries.begin(), entries.end(), [](
auto const&
a,
auto const&
b) {
48 return a.first + 1 !=
b.first;
49 }) != entries.end()) {
55 data_.resize(maxAddress + 1, 0);
61 std::transform(entries.begin(), entries.end(),
data_.begin(), [](
auto const& x) {
return x.second; });
66 stream <<
"#<header> V1 " << nrBitsAddress_ <<
" " << nrBitsData_ <<
" </header> " << std::endl;
67 for (
unsigned int address = 0; address < data_.size(); address++) {
68 stream << (address & addressMask_) <<
" " <<
data(address) << std::endl;
73 int startPos =
stream.tellg();
76 if (
line.find(
"#<header>") == 0) {
77 std::istringstream lineStream(
line);
81 if (lineStream >> headerField >>
version >> nrBitsAddress_ >> nrBitsData_) {
82 addressMask_ = nrBitsAddress_ != 32 ? (0x1 << nrBitsAddress_) - 1 : ~0x0;
83 dataMask_ = (0x1 << nrBitsData_) - 1;
92 addressMask_ = (0x1 << nrBitsAddress_) - 1;
93 dataMask_ = (0x1 << nrBitsData_) - 1;