Stop using inline constructor initialiser list things for tuples, as

it's a recent feature and old compilers don't support them.
This commit is contained in:
David Given
2019-02-15 13:44:44 +01:00
parent 5366a5c9be
commit 6384b92bed
5 changed files with 13 additions and 11 deletions

View File

@@ -40,7 +40,7 @@ void readSectorsFromFile(SectorSet& sectors, const Geometry& geometry,
inputFile.seekg(track*trackSize + head*headSize + sectorId*geometry.sectorSize, std::ios::beg);
inputFile.read((char*) &data[0], geometry.sectorSize);
sectors[{track, head, sectorId}].reset(
sectors.get(track, head, sectorId).reset(
new Sector(Sector::OK, track, head, sectorId, data));
}
}
@@ -63,7 +63,7 @@ void writeSectorsToFile(const SectorSet& sectors, const Geometry& geometry,
std::cout << fmt::format("{}.{:2} ", head, sectorId);
for (int track = 0; track < geometry.tracks; track++)
{
auto sector = sectors[{track, head, sectorId}];
auto sector = sectors.get(track, head, sectorId);
if (!sector)
{
std::cout << 'X';
@@ -116,7 +116,7 @@ void writeSectorsToFile(const SectorSet& sectors, const Geometry& geometry,
{
for (int sectorId = 0; sectorId < geometry.sectors; sectorId++)
{
auto sector = sectors[{track, head, sectorId}];
auto sector = sectors.get(track, head, sectorId);
if (sector)
{
outputFile.seekp(sector->track*trackSize + sector->side*headSize + sector->sector*geometry.sectorSize, std::ios::beg);

View File

@@ -192,7 +192,7 @@ void readDiskCommand(
}
size += sector->data.size();
allSectors[{sector->track, sector->side, sector->sector}] = std::move(sector);
allSectors.get(sector->track, sector->side, sector->sector) = std::move(sector);
}
}
std::cout << size << " bytes decoded." << std::endl;
@@ -202,4 +202,4 @@ void readDiskCommand(
writeSectorsToFile(allSectors, geometry, outputFilename);
if (failures)
std::cerr << "Warning: some sectors could not be decoded." << std::endl;
}
}

View File

@@ -3,13 +3,15 @@
#include "sector.h"
#include "sectorset.h"
std::unique_ptr<Sector>& SectorSet::operator[](const key_t& key)
std::unique_ptr<Sector>& SectorSet::get(int track, int head, int sector)
{
key_t key(track, head, sector);
return _data[key];
}
Sector* SectorSet::operator[](const key_t& key) const
Sector* SectorSet::get(int track, int head, int sector) const
{
key_t key(track, head, sector);
auto i = _data.find(key);
if (i == _data.end())
return NULL;

View File

@@ -5,7 +5,7 @@ class Sector;
class SectorSet
{
public:
private:
typedef std::tuple<int, int, int> key_t;
public:
@@ -14,8 +14,8 @@ public:
SectorSet() {};
std::unique_ptr<Sector>& operator[](const key_t& key);
Sector* operator[](const key_t& key) const;
std::unique_ptr<Sector>& get(int track, int head, int sector);
Sector* get(int track, int head, int sector) const;
void calculateSize(int& numTracks, int& numHeads, int& numSectors,
int& sectorSize) const;

View File

@@ -81,7 +81,7 @@ int main(int argc, const char* argv[])
double dataMs = headerMs + postHeaderSpacingMs;
unsigned dataCursor = dataMs*1e3 / clockRateUs;
auto& sectorData = allSectors[SectorSet::key_t {track, 0, sectorId}];
auto& sectorData = allSectors.get(track, 0, sectorId);
fillBitmapTo(bits, cursor, headerCursor, { true, false });
writeBrotherSectorHeader(bits, cursor, track, sectorId);