Skip to content

Commit

Permalink
Dedpulicate EoF sanitization code
Browse files Browse the repository at this point in the history
  • Loading branch information
Werni2A committed Dec 30, 2023
1 parent 55e1fc6 commit 91db9e2
Show file tree
Hide file tree
Showing 21 changed files with 21 additions and 84 deletions.
5 changes: 1 addition & 4 deletions src/Misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,7 @@ void Container::readTitleBlockSymbol()
}
}

if(!ds.isEoF())
{
throw std::runtime_error("Expected EoF but did not reach it!");
}
ds.sanitizeEoF();

spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset()));
}
5 changes: 1 addition & 4 deletions src/Streams/StreamAdminData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ void StreamAdminData::read(FileFormatVersion /* aVersion */)
ds.assumeData({0x00, 0x00, 0x00, 0x00, 0x00},
fmt::format("{}: Found actually useful data!", getMethodName(this, __func__)));

if(!ds.isEoF())
{
throw std::runtime_error("Expected EoF but did not reach it!");
}
ds.sanitizeEoF();

mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset()));
mCtx.mLogger.info(to_string());
Expand Down
5 changes: 1 addition & 4 deletions src/Streams/StreamCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,7 @@ void StreamCache::read(FileFormatVersion /* aVersion */)
}
}

if(!ds.isEoF())
{
throw std::runtime_error("Expected EoF but did not reach it!");
}
ds.sanitizeEoF();

mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset()));
mCtx.mLogger.info(to_string());
Expand Down
5 changes: 1 addition & 4 deletions src/Streams/StreamCellsDirectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ void StreamCellsDirectory::read(FileFormatVersion /* aVersion */)
items.push_back(item);
}

if(!ds.isEoF())
{
throw std::runtime_error("Expected EoF but did not reach it!");
}
ds.sanitizeEoF();

mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset()));
mCtx.mLogger.info(to_string());
Expand Down
5 changes: 1 addition & 4 deletions src/Streams/StreamDsnStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ void StreamDsnStream::read(FileFormatVersion /* aVersion */)
// @todo Add checkpoint sanitization
// localFutureLst.sanitizeCheckpoints();

if(!ds.isEoF())
{
throw std::runtime_error("Expected EoF but did not reach it!");
}
ds.sanitizeEoF();

mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset()));
mCtx.mLogger.info(to_string());
Expand Down
5 changes: 1 addition & 4 deletions src/Streams/StreamERC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ void StreamERC::read(FileFormatVersion /* aVersion */)

ercSymbol = dynamic_pointer_cast<StructERCSymbol>(parser.readStructure());

if(!ds.isEoF())
{
throw std::runtime_error("Expected EoF but did not reach it!");
}
ds.sanitizeEoF();

mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset()));
mCtx.mLogger.info(to_string());
Expand Down
5 changes: 1 addition & 4 deletions src/Streams/StreamExportBlocksDirectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@ void StreamExportBlocksDirectory::read(FileFormatVersion /* aVersion */)
items.push_back(item);
}

if(!ds.isEoF())
{
throw std::runtime_error("Expected EoF but did not reach it!");
}
ds.sanitizeEoF();

mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset()));
mCtx.mLogger.info(to_string());
Expand Down
5 changes: 1 addition & 4 deletions src/Streams/StreamGraphicsDirectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ void StreamGraphicsDirectory::read(FileFormatVersion /* aVersion */)
items.push_back(item);
}

if(!ds.isEoF())
{
throw std::runtime_error("Expected EoF but did not reach it!");
}
ds.sanitizeEoF();

mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset()));
mCtx.mLogger.info(to_string());
Expand Down
5 changes: 1 addition & 4 deletions src/Streams/StreamHSObjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ void StreamHSObjects::read(FileFormatVersion /* aVersion */)
ds.assumeData({0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, fmt::format("{}: - 0", __func__));
ds.assumeData({0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, fmt::format("{}: - 1", __func__));

if(!ds.isEoF())
{
throw std::runtime_error("Expected EoF but did not reach it!");
}
ds.sanitizeEoF();

mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset()));
mCtx.mLogger.info(to_string());
Expand Down
5 changes: 1 addition & 4 deletions src/Streams/StreamHierarchy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,7 @@ void StreamHierarchy::read(FileFormatVersion aVersion)
ds.printUnknownData(10, getMethodName(this, __func__) + ": 5");
}

if(!ds.isEoF())
{
throw std::runtime_error("Expected EoF but did not reach it!");
}
ds.sanitizeEoF();

mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset()));
mCtx.mLogger.info(to_string());
Expand Down
5 changes: 1 addition & 4 deletions src/Streams/StreamLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,7 @@ void StreamLibrary::read(FileFormatVersion aVersion)
mCtx.mLogger.trace("schematicName = {}", schematicName);
}

if(!ds.isEoF())
{
throw std::runtime_error("Expected EoF but did not reach it!");
}
ds.sanitizeEoF();

mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset()));
mCtx.mLogger.info(to_string());
Expand Down
5 changes: 1 addition & 4 deletions src/Streams/StreamNetBundleMapData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ void StreamNetBundleMapData::read(FileFormatVersion /* aVersion */)
}
}

if(!ds.isEoF())
{
throw std::runtime_error("Expected EoF but did not reach it!");
}
ds.sanitizeEoF();

mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset()));
mCtx.mLogger.info(to_string());
Expand Down
5 changes: 1 addition & 4 deletions src/Streams/StreamPackage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ void StreamPackage::read(FileFormatVersion /* aVersion */)

t0x1f = dynamic_pointer_cast<StructT0x1f>(parser.readStructure());

if(!ds.isEoF())
{
throw std::runtime_error("Expected EoF but did not reach it!");
}
ds.sanitizeEoF();

mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset()));
mCtx.mLogger.info(to_string());
Expand Down
5 changes: 1 addition & 4 deletions src/Streams/StreamPackagesDirectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ void StreamPackagesDirectory::read(FileFormatVersion /* aVersion */)
items.push_back(item);
}

if(!ds.isEoF())
{
throw std::runtime_error("Expected EoF but did not reach it!");
}
ds.sanitizeEoF();

mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset()));
mCtx.mLogger.info(to_string());
Expand Down
5 changes: 1 addition & 4 deletions src/Streams/StreamPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,7 @@ void StreamPage::read(FileFormatVersion /* aVersion */)

localFutureLst.sanitizeCheckpoints();

if(!ds.isEoF())
{
throw std::runtime_error("Expected EoF but did not reach it!");
}
ds.sanitizeEoF();

mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset()));
mCtx.mLogger.info(to_string());
Expand Down
5 changes: 1 addition & 4 deletions src/Streams/StreamPartsDirectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@ void StreamPartsDirectory::read(FileFormatVersion /* aVersion */)
items.push_back(item);
}

if(!ds.isEoF())
{
throw std::runtime_error("Expected EoF but did not reach it!");
}
ds.sanitizeEoF();

mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset()));
mCtx.mLogger.info(to_string());
Expand Down
5 changes: 1 addition & 4 deletions src/Streams/StreamSchematic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@ void StreamSchematic::read(FileFormatVersion /* aVersion */)

ds.printUnknownData(4, getMethodName(this, __func__) + ": 3");

if(!ds.isEoF())
{
throw std::runtime_error("Expected EoF but did not reach it!");
}
ds.sanitizeEoF();

mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset()));
mCtx.mLogger.info(to_string());
Expand Down
5 changes: 1 addition & 4 deletions src/Streams/StreamSymbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ void StreamSymbol::read(FileFormatVersion /* aVersion */)

symbol = dynamic_pointer_cast<StructSymbol>(parser.readStructure());

if(!ds.isEoF())
{
throw std::runtime_error("Expected EoF but did not reach it!");
}
ds.sanitizeEoF();

mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset()));
mCtx.mLogger.info(to_string());
Expand Down
5 changes: 1 addition & 4 deletions src/Streams/StreamSymbolsDirectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,7 @@ void StreamSymbolsDirectory::read(FileFormatVersion /* aVersion */)
items.push_back(item);
}

if(!ds.isEoF())
{
throw std::runtime_error("Expected EoF but did not reach it!");
}
ds.sanitizeEoF();

mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset()));
mCtx.mLogger.info(to_string());
Expand Down
5 changes: 1 addition & 4 deletions src/Streams/StreamType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ void StreamType::read(FileFormatVersion /* aVersion */)
types.push_back(type);
}

if(!ds.isEoF())
{
throw std::runtime_error("Expected EoF but did not reach it!");
}
ds.sanitizeEoF();

mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset()));
mCtx.mLogger.info(to_string());
Expand Down
5 changes: 1 addition & 4 deletions src/Streams/StreamViewsDirectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@ void StreamViewsDirectory::read(FileFormatVersion /* aVersion */)
items.push_back(item);
}

if(!ds.isEoF())
{
throw std::runtime_error("Expected EoF but did not reach it!");
}
ds.sanitizeEoF();

mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset()));
mCtx.mLogger.info(to_string());
Expand Down

0 comments on commit 91db9e2

Please sign in to comment.