diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 2fa7344..5d89206 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -25,26 +25,18 @@ set(SOURCES ${LIB_SRC_DIR}/StreamFactory.cpp ${LIB_SRC_DIR}/Streams/StreamAdminData.cpp ${LIB_SRC_DIR}/Streams/StreamCache.cpp - ${LIB_SRC_DIR}/Streams/StreamCellsDirectory.cpp - ${LIB_SRC_DIR}/Streams/StreamCellsDirectory.hpp + ${LIB_SRC_DIR}/Streams/StreamDirectoryStruct.cpp ${LIB_SRC_DIR}/Streams/StreamDsnStream.cpp ${LIB_SRC_DIR}/Streams/StreamERC.cpp - ${LIB_SRC_DIR}/Streams/StreamExportBlocksDirectory.cpp - ${LIB_SRC_DIR}/Streams/StreamExportBlocksDirectory.hpp - ${LIB_SRC_DIR}/Streams/StreamGraphicsDirectory.cpp ${LIB_SRC_DIR}/Streams/StreamHierarchy.cpp ${LIB_SRC_DIR}/Streams/StreamHSObjects.cpp ${LIB_SRC_DIR}/Streams/StreamLibrary.cpp ${LIB_SRC_DIR}/Streams/StreamNetBundleMapData.cpp ${LIB_SRC_DIR}/Streams/StreamPackage.cpp - ${LIB_SRC_DIR}/Streams/StreamPackagesDirectory.cpp ${LIB_SRC_DIR}/Streams/StreamPage.cpp - ${LIB_SRC_DIR}/Streams/StreamPartsDirectory.cpp ${LIB_SRC_DIR}/Streams/StreamSchematic.cpp ${LIB_SRC_DIR}/Streams/StreamSymbol.cpp - ${LIB_SRC_DIR}/Streams/StreamSymbolsDirectory.cpp ${LIB_SRC_DIR}/Streams/StreamType.cpp - ${LIB_SRC_DIR}/Streams/StreamViewsDirectory.cpp ${LIB_SRC_DIR}/Structures/StructAlias.cpp ${LIB_SRC_DIR}/Structures/StructBookMarkSymbolInst.cpp ${LIB_SRC_DIR}/Structures/StructBusEntry.cpp @@ -136,20 +128,15 @@ set(HEADERS ${LIB_INCLUDE_DIR}/Streams/StreamDirectoryStruct.hpp ${LIB_INCLUDE_DIR}/Streams/StreamDsnStream.hpp ${LIB_INCLUDE_DIR}/Streams/StreamERC.hpp - ${LIB_INCLUDE_DIR}/Streams/StreamGraphicsDirectory.hpp ${LIB_INCLUDE_DIR}/Streams/StreamHierarchy.hpp ${LIB_INCLUDE_DIR}/Streams/StreamHSObjects.hpp ${LIB_INCLUDE_DIR}/Streams/StreamLibrary.hpp ${LIB_INCLUDE_DIR}/Streams/StreamNetBundleMapData.hpp ${LIB_INCLUDE_DIR}/Streams/StreamPackage.hpp - ${LIB_INCLUDE_DIR}/Streams/StreamPackagesDirectory.hpp ${LIB_INCLUDE_DIR}/Streams/StreamPage.hpp - ${LIB_INCLUDE_DIR}/Streams/StreamPartsDirectory.hpp ${LIB_INCLUDE_DIR}/Streams/StreamSchematic.hpp ${LIB_INCLUDE_DIR}/Streams/StreamSymbol.hpp - ${LIB_INCLUDE_DIR}/Streams/StreamSymbolsDirectory.hpp ${LIB_INCLUDE_DIR}/Streams/StreamType.hpp - ${LIB_INCLUDE_DIR}/Streams/StreamViewsDirectory.hpp ${LIB_INCLUDE_DIR}/Structures/StructAlias.hpp ${LIB_INCLUDE_DIR}/Structures/StructBookMarkSymbolInst.hpp ${LIB_INCLUDE_DIR}/Structures/StructBusEntry.hpp diff --git a/src/StreamFactory.cpp b/src/StreamFactory.cpp index c0e41ad..860a112 100644 --- a/src/StreamFactory.cpp +++ b/src/StreamFactory.cpp @@ -12,23 +12,17 @@ #include "StreamFactory.hpp" #include "Streams/StreamAdminData.hpp" #include "Streams/StreamCache.hpp" -#include "Streams/StreamCellsDirectory.hpp" +#include "Streams/StreamDirectoryStruct.hpp" #include "Streams/StreamDsnStream.hpp" -#include "Streams/StreamExportBlocksDirectory.hpp" -#include "Streams/StreamGraphicsDirectory.hpp" #include "Streams/StreamHierarchy.hpp" #include "Streams/StreamHSObjects.hpp" #include "Streams/StreamLibrary.hpp" #include "Streams/StreamNetBundleMapData.hpp" #include "Streams/StreamPackage.hpp" -#include "Streams/StreamPackagesDirectory.hpp" #include "Streams/StreamPage.hpp" -#include "Streams/StreamPartsDirectory.hpp" #include "Streams/StreamSchematic.hpp" #include "Streams/StreamSymbol.hpp" -#include "Streams/StreamSymbolsDirectory.hpp" #include "Streams/StreamType.hpp" -#include "Streams/StreamViewsDirectory.hpp" std::unique_ptr StreamFactory::build(ContainerContext& aCtx, const fs::path& aInputStream) @@ -88,7 +82,7 @@ std::unique_ptr StreamFactory::build(ContainerContext& aCtx, const fs::p pattern = {"Cells Directory"}; if(streamLoc.matches_pattern(pattern)) { - return std::make_unique(aCtx, aInputStream); + return std::make_unique(aCtx, aInputStream); } // Match `/CIS/CISSchematicStore/CISSchematicStream` @@ -174,7 +168,7 @@ std::unique_ptr StreamFactory::build(ContainerContext& aCtx, const fs::p pattern = {"ExportBlocks Directory"}; if(streamLoc.matches_pattern(pattern)) { - return std::make_unique(aCtx, aInputStream); + return std::make_unique(aCtx, aInputStream); } // Match `/Graphics/$Types$` @@ -196,7 +190,7 @@ std::unique_ptr StreamFactory::build(ContainerContext& aCtx, const fs::p pattern = {"Graphics Directory"}; if(streamLoc.matches_pattern(pattern)) { - return std::make_unique(aCtx, aInputStream); + return std::make_unique(aCtx, aInputStream); } // Match `/HSObjects` @@ -239,7 +233,7 @@ std::unique_ptr StreamFactory::build(ContainerContext& aCtx, const fs::p pattern = {"Packages Directory"}; if(streamLoc.matches_pattern(pattern)) { - return std::make_unique(aCtx, aInputStream); + return std::make_unique(aCtx, aInputStream); } // Match `/Parts/*` @@ -254,7 +248,7 @@ std::unique_ptr StreamFactory::build(ContainerContext& aCtx, const fs::p pattern = {"Parts Directory"}; if(streamLoc.matches_pattern(pattern)) { - return std::make_unique(aCtx, aInputStream); + return std::make_unique(aCtx, aInputStream); } // Match `/Symbols/$Types$` @@ -292,7 +286,7 @@ std::unique_ptr StreamFactory::build(ContainerContext& aCtx, const fs::p pattern = {"Symbols Directory"}; if(streamLoc.matches_pattern(pattern)) { - return std::make_unique(aCtx, aInputStream); + return std::make_unique(aCtx, aInputStream); } // Match `/Views/*/Hierarchy/Hierarchy` @@ -320,7 +314,7 @@ std::unique_ptr StreamFactory::build(ContainerContext& aCtx, const fs::p pattern = {"Views Directory"}; if(streamLoc.matches_pattern(pattern)) { - return std::make_unique(aCtx, aInputStream); + return std::make_unique(aCtx, aInputStream); } const std::string errMsg = fmt::format( diff --git a/src/Streams/StreamCellsDirectory.hpp b/src/Streams/StreamCellsDirectory.hpp deleted file mode 100644 index 09c2c97..0000000 --- a/src/Streams/StreamCellsDirectory.hpp +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef STREAMCELLSDIRECTORY_HPP -#define STREAMCELLSDIRECTORY_HPP - - -#include -#include - -#include -#include - -#include "General.hpp" -#include "StreamDirectoryStruct.hpp" - - -class StreamCellsDirectory : public StreamDirectoryStruct -{ -public: - - StreamCellsDirectory(ContainerContext& aCtx, const fs::path& aInputStream) : StreamDirectoryStruct{aCtx, aInputStream} - { } - - std::string to_string() const override; - - void read(FileFormatVersion aVersion = FileFormatVersion::Unknown) override; - - void accept(Visitor& aVisitor) const override - { - aVisitor.visit(*this); - } -}; - - -[[maybe_unused]] -static std::string to_string(const StreamCellsDirectory& /* aObj */) -{ - // return dynamic_cast(&aObj)->to_string(); - return ""; -} - - -inline std::string StreamCellsDirectory::to_string() const -{ - return ::to_string(*this); -} - - -[[maybe_unused]] -static std::ostream& operator<<(std::ostream& aOs, const StreamCellsDirectory& aObj) -{ - aOs << to_string(aObj); - - return aOs; -} - - -#endif // STREAMCELLSDIRECTORY_HPP \ No newline at end of file diff --git a/src/Streams/StreamCellsDirectory.cpp b/src/Streams/StreamDirectoryStruct.cpp similarity index 82% rename from src/Streams/StreamCellsDirectory.cpp rename to src/Streams/StreamDirectoryStruct.cpp index f51dd49..8efcd7e 100644 --- a/src/Streams/StreamCellsDirectory.cpp +++ b/src/Streams/StreamDirectoryStruct.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -5,19 +6,20 @@ #include #include "General.hpp" -#include "Streams/StreamCellsDirectory.hpp" #include "Streams/StreamDirectoryStruct.hpp" -void StreamCellsDirectory::read(FileFormatVersion /* aVersion */) +void StreamDirectoryStruct::read(FileFormatVersion /* aVersion */) { auto& ds = mCtx.mDs; mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); lastModifiedDate = static_cast(ds.readUint32()); + mCtx.mLogger.trace("lastModifiedDate = {}", DateTimeToStr(lastModifiedDate)); const uint16_t size = ds.readUint16(); + mCtx.mLogger.trace("size = {}", size); for(size_t i = 0u; i < size; ++i) { @@ -31,16 +33,11 @@ void StreamCellsDirectory::read(FileFormatVersion /* aVersion */) mCtx.mLogger.trace("componentType = {}", ::to_string(item.componentType)); - if(item.componentType != ComponentType::Cell) - { - mCtx.mLogger.warn("{}: Unexpected ComponentType `{}`", __func__, ::to_string(item.componentType)); - } - // @todo This changes with the version of the file format, so maybe it contains // more details for the format? Or some hash of the specified stream? ds.printUnknownData(14, fmt::format("item[{:>3}] - 0", i)); - // @todo Just a guess that this is the version but's highly likely + // @todo Just a guess that this is the version but it's highly likely item.fileFormatVersion = ds.readUint16(); mCtx.mLogger.trace("fileFormatVersion = {}", item.fileFormatVersion); @@ -49,7 +46,7 @@ void StreamCellsDirectory::read(FileFormatVersion /* aVersion */) // 471 in 17.4-2019 S012 (3898062) [10/18/202] // 472 in 17.4-2019 S019 (3959056) [7/8/2021] std::vector knownFileVersions{ - 445, 446, 447, 448, 449, + 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472 diff --git a/src/Streams/StreamDirectoryStruct.hpp b/src/Streams/StreamDirectoryStruct.hpp index 6c2fd17..2fc7a18 100644 --- a/src/Streams/StreamDirectoryStruct.hpp +++ b/src/Streams/StreamDirectoryStruct.hpp @@ -64,6 +64,14 @@ static std::ostream& operator<<(std::ostream& aOs, const DirItemType& aVal) } +// Used to parse +// - `Cells Directory` +// - `ExportBlocks Directory` +// - `Graphics Directory` +// - `Packages Directory` +// - `Parts Directory` +// - `Symbols Directory` +// - `Views Directory` class StreamDirectoryStruct : public Stream { public: @@ -74,9 +82,12 @@ class StreamDirectoryStruct : public Stream std::string to_string() const; - // @todo This is more a workaround to get inheritance working for e.g. StreamExportBlocksDirectory - void read(FileFormatVersion /* aVersion */ = FileFormatVersion::Unknown) override - { } + void read(FileFormatVersion /* aVersion */ = FileFormatVersion::Unknown); + + void accept(Visitor& aVisitor) const override + { + aVisitor.visit(*this); + } time_t lastModifiedDate; diff --git a/src/Streams/StreamExportBlocksDirectory.cpp b/src/Streams/StreamExportBlocksDirectory.cpp deleted file mode 100644 index 175e23e..0000000 --- a/src/Streams/StreamExportBlocksDirectory.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include -#include - -#include -#include - -#include "General.hpp" -#include "Streams/StreamExportBlocksDirectory.hpp" - - -void StreamExportBlocksDirectory::read(FileFormatVersion /* aVersion */) -{ - auto& ds = mCtx.mDs; - - mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - - lastModifiedDate = static_cast(ds.readUint32()); - - const uint16_t size = ds.readUint16(); - - if(size > 0U) - { - mCtx.mLogger.warn("{}: Check it out. First time that we have some elements here!", - getMethodName(this, __func__)); - } - - for(size_t i = 0u; i < size; ++i) - { - DirItemType item; - - item.name = ds.readStringLenZeroTerm(); - - item.componentType = ToComponentType(ds.readUint16()); - - // @todo This changes with the version of the file format, so maybe it contains - // more details for the format? Or some hash of the specified stream? - ds.printUnknownData(14, fmt::format("item[{:>3}] - 0", i)); - - // @todo Just a guess that this is the version but's highly likely - item.fileFormatVersion = ds.readUint16(); - - mCtx.mLogger.trace("fileFormatVersion = {}", item.fileFormatVersion); - - // Known versions that I obsereved in different files - // 471 in 17.4-2019 S012 (3898062) [10/18/202] - // 472 in 17.4-2019 S019 (3959056) [7/8/2021] - std::vector knownFileVersions{ - 445, 446, 447, 448, 449, - 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, - 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, - 470, 471, 472 - }; - - if(!std::any_of(knownFileVersions.begin(), knownFileVersions.end(), [&](unsigned version){ return version == item.fileFormatVersion; })) - { - mCtx.mLogger.warn("Unexpected File Version {}", item.fileFormatVersion); - } - - item.timezone = ds.readInt16(); - - ds.printUnknownData(2, fmt::format("item[{:>3}] - 1", i)); - - items.push_back(item); - } - - ds.sanitizeEoF(); - - mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - mCtx.mLogger.info(to_string()); -} \ No newline at end of file diff --git a/src/Streams/StreamExportBlocksDirectory.hpp b/src/Streams/StreamExportBlocksDirectory.hpp deleted file mode 100644 index 1c4d41e..0000000 --- a/src/Streams/StreamExportBlocksDirectory.hpp +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef STREAMEXPORTBLOCKSDIRECTORY_HPP -#define STREAMEXPORTBLOCKSDIRECTORY_HPP - - -#include -#include - -#include -#include - -#include "General.hpp" -#include "StreamDirectoryStruct.hpp" - - -class StreamExportBlocksDirectory : public StreamDirectoryStruct -{ -public: - - StreamExportBlocksDirectory(ContainerContext& aCtx, const fs::path& aInputStream) : StreamDirectoryStruct{aCtx, aInputStream} - { } - - std::string to_string() const override; - - void read(FileFormatVersion aVersion = FileFormatVersion::Unknown) override; - - void accept(Visitor& aVisitor) const override - { - aVisitor.visit(*this); - } -}; - - -[[maybe_unused]] -static std::string to_string(const StreamExportBlocksDirectory& /* aObj */) -{ - // return dynamic_cast(&aObj)->to_string(); - return ""; -} - - -inline std::string StreamExportBlocksDirectory::to_string() const -{ - return ::to_string(*this); -} - - -[[maybe_unused]] -static std::ostream& operator<<(std::ostream& aOs, const StreamExportBlocksDirectory& aObj) -{ - aOs << to_string(aObj); - - return aOs; -} - - -#endif // STREAMEXPORTBLOCKSDIRECTORY_HPP \ No newline at end of file diff --git a/src/Streams/StreamGraphicsDirectory.cpp b/src/Streams/StreamGraphicsDirectory.cpp deleted file mode 100644 index 8452c2f..0000000 --- a/src/Streams/StreamGraphicsDirectory.cpp +++ /dev/null @@ -1,75 +0,0 @@ -#include -#include - -#include -#include - -#include "General.hpp" -#include "Streams/StreamDirectoryStruct.hpp" -#include "Streams/StreamGraphicsDirectory.hpp" - - -void StreamGraphicsDirectory::read(FileFormatVersion /* aVersion */) -{ - auto& ds = mCtx.mDs; - - mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - - lastModifiedDate = static_cast(ds.readUint32()); - - const uint16_t size = ds.readUint16(); - - if(size > 0U) - { - // mCtx.mLogger.warn("{} contains Graphic. Check it out!", mInputCfbfFile.string()); - } - - for(size_t i = 0u; i < size; ++i) - { - DirItemType item; - - item.name = ds.readStringLenZeroTerm(); - - item.componentType = ToComponentType(ds.readUint16()); - - if(item.componentType != ComponentType::Graphic) - { - mCtx.mLogger.warn("{}: Unexpected ComponentType `{}`", __func__, ::to_string(item.componentType)); - } - - // @todo This changes with the version of the file format, so maybe it contains - // more details for the format? Or some hash of the specified stream? - ds.printUnknownData(14, fmt::format("item[{:>3}] - 0", i)); - - // @todo Just a guess that this is the version but's highly likely - item.fileFormatVersion = ds.readUint16(); - - mCtx.mLogger.trace("fileFormatVersion = {}", item.fileFormatVersion); - - // Known versions that I obsereved in different files - // 471 in 17.4-2019 S012 (3898062) [10/18/202] - // 472 in 17.4-2019 S019 (3959056) [7/8/2021] - std::vector knownFileVersions{ - 445, 446, 447, 448, 449, - 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, - 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, - 470, 471, 472 - }; - - if(!std::any_of(knownFileVersions.begin(), knownFileVersions.end(), [&](unsigned version){ return version == item.fileFormatVersion; })) - { - mCtx.mLogger.warn("Unexpected File Version {}", item.fileFormatVersion); - } - - item.timezone = ds.readInt16(); - - ds.printUnknownData(2, fmt::format("item[{:>3}] - 1", i)); - - items.push_back(item); - } - - ds.sanitizeEoF(); - - mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - mCtx.mLogger.info(to_string()); -} \ No newline at end of file diff --git a/src/Streams/StreamGraphicsDirectory.hpp b/src/Streams/StreamGraphicsDirectory.hpp deleted file mode 100644 index 09524ce..0000000 --- a/src/Streams/StreamGraphicsDirectory.hpp +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef STREAMGRAPHICSDIRECTORY_HPP -#define STREAMGRAPHICSDIRECTORY_HPP - - -#include -#include - -#include -#include - -#include "General.hpp" -#include "StreamDirectoryStruct.hpp" - - -class StreamGraphicsDirectory : public StreamDirectoryStruct -{ -public: - - StreamGraphicsDirectory(ContainerContext& aCtx, const fs::path& aInputStream) : StreamDirectoryStruct{aCtx, aInputStream} - { } - - std::string to_string() const override; - - void read(FileFormatVersion aVersion = FileFormatVersion::Unknown) override; - - void accept(Visitor& aVisitor) const override - { - aVisitor.visit(*this); - } -}; - - -[[maybe_unused]] -static std::string to_string(const StreamGraphicsDirectory& /* aObj */) -{ - // return dynamic_cast(&aObj)->to_string(); - return ""; -} - - -inline std::string StreamGraphicsDirectory::to_string() const -{ - return ::to_string(*this); -} - - -[[maybe_unused]] -static std::ostream& operator<<(std::ostream& aOs, const StreamGraphicsDirectory& aObj) -{ - aOs << to_string(aObj); - - return aOs; -} - - -#endif // STREAMGRAPHICSDIRECTORY_HPP \ No newline at end of file diff --git a/src/Streams/StreamPackagesDirectory.cpp b/src/Streams/StreamPackagesDirectory.cpp deleted file mode 100644 index 62e18de..0000000 --- a/src/Streams/StreamPackagesDirectory.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#include -#include - -#include -#include - -#include "General.hpp" -#include "Streams/StreamPackagesDirectory.hpp" - - -void StreamPackagesDirectory::read(FileFormatVersion /* aVersion */) -{ - auto& ds = mCtx.mDs; - - mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - - lastModifiedDate = static_cast(ds.readUint32()); - - const uint16_t size = ds.readUint16(); - - for(size_t i = 0u; i < size; ++i) - { - DirItemType item; - - item.name = ds.readStringLenZeroTerm(); - - item.componentType = ToComponentType(ds.readUint16()); - - if(item.componentType != ComponentType::Package) - { - mCtx.mLogger.warn("{}: Unexpected ComponentType `{}`", __func__, ::to_string(item.componentType)); - } - - // @todo This changes with the version of the file format, so maybe it contains - // more details for the format? Or some hash of the specified stream? - ds.printUnknownData(14, fmt::format("item[{:>3}] - 0", i)); - - // @todo Just a guess that this is the version but's highly likely - item.fileFormatVersion = ds.readUint16(); - - mCtx.mLogger.trace("fileFormatVersion = {}", item.fileFormatVersion); - - // Known versions that I obsereved in different files - // 471 in 17.4-2019 S012 (3898062) [10/18/202] - // 472 in 17.4-2019 S019 (3959056) [7/8/2021] - std::vector knownFileVersions{ - 445, 446, 447, 448, 449, - 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, - 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, - 470, 471, 472 - }; - - if(!std::any_of(knownFileVersions.begin(), knownFileVersions.end(), [&](unsigned version){ return version == item.fileFormatVersion; })) - { - mCtx.mLogger.warn("Unexpected File Version {}", item.fileFormatVersion); - } - - item.timezone = ds.readInt16(); - - ds.printUnknownData(2, fmt::format("item[{:>3}] - 1", i)); - - items.push_back(item); - } - - ds.sanitizeEoF(); - - mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - mCtx.mLogger.info(to_string()); -} \ No newline at end of file diff --git a/src/Streams/StreamPackagesDirectory.hpp b/src/Streams/StreamPackagesDirectory.hpp deleted file mode 100644 index 3d3c091..0000000 --- a/src/Streams/StreamPackagesDirectory.hpp +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef STREAMPACKAGESDIRECTORY_HPP -#define STREAMPACKAGESDIRECTORY_HPP - - -#include -#include - -#include -#include - -#include "General.hpp" -#include "StreamDirectoryStruct.hpp" - - -class StreamPackagesDirectory : public StreamDirectoryStruct -{ -public: - - StreamPackagesDirectory(ContainerContext& aCtx, const fs::path& aInputStream) : StreamDirectoryStruct{aCtx, aInputStream} - { } - - std::string to_string() const override; - - void read(FileFormatVersion aVersion = FileFormatVersion::Unknown) override; - - void accept(Visitor& aVisitor) const override - { - aVisitor.visit(*this); - } -}; - - -[[maybe_unused]] -static std::string to_string(const StreamPackagesDirectory& /* aObj */) -{ - // return dynamic_cast(&aObj)->to_string(); - return ""; -} - - -inline std::string StreamPackagesDirectory::to_string() const -{ - return ::to_string(*this); -} - - -[[maybe_unused]] -static std::ostream& operator<<(std::ostream& aOs, const StreamPackagesDirectory& aObj) -{ - aOs << to_string(aObj); - - return aOs; -} - - -#endif // STREAMPACKAGESDIRECTORY_HPP \ No newline at end of file diff --git a/src/Streams/StreamPartsDirectory.cpp b/src/Streams/StreamPartsDirectory.cpp deleted file mode 100644 index d59b9ee..0000000 --- a/src/Streams/StreamPartsDirectory.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include -#include - -#include -#include - -#include "General.hpp" -#include "Streams/StreamDirectoryStruct.hpp" -#include "Streams/StreamPartsDirectory.hpp" - - -void StreamPartsDirectory::read(FileFormatVersion /* aVersion */) -{ - auto& ds = mCtx.mDs; - - mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - - lastModifiedDate = static_cast(ds.readUint32()); - - const uint16_t size = ds.readUint16(); - - for(size_t i = 0u; i < size; ++i) - { - DirItemType item; - - item.name = ds.readStringLenZeroTerm(); - - item.componentType = ToComponentType(ds.readUint16()); - - if(item.componentType != ComponentType::Part) - { - mCtx.mLogger.warn("{}: Unexpected ComponentType `{}`", __func__, ::to_string(item.componentType)); - } - - // @todo This changes with the version of the file format, so maybe it contains - // more details for the format? Or some hash of the specified stream? - ds.printUnknownData(14, fmt::format("item[{:>3}] - 0", i)); - - // @todo Just a guess that this is the version but's highly likely - item.fileFormatVersion = ds.readUint16(); - - mCtx.mLogger.trace("fileFormatVersion = {}", item.fileFormatVersion); - - // Known versions that I obsereved in different files - // 471 in 17.4-2019 S012 (3898062) [10/18/202] - // 472 in 17.4-2019 S019 (3959056) [7/8/2021] - std::vector knownFileVersions{ - 445, 446, 447, 448, 449, - 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, - 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, - 470, 471, 472 - }; - - if(!std::any_of(knownFileVersions.begin(), knownFileVersions.end(), [&](unsigned version){ return version == item.fileFormatVersion; })) - { - mCtx.mLogger.warn("Unexpected File Version {}", item.fileFormatVersion); - } - - item.timezone = ds.readInt16(); - - ds.printUnknownData(2, fmt::format("item[{:>3}] - 1", i)); - - items.push_back(item); - } - - ds.sanitizeEoF(); - - mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - mCtx.mLogger.info(to_string()); -} \ No newline at end of file diff --git a/src/Streams/StreamPartsDirectory.hpp b/src/Streams/StreamPartsDirectory.hpp deleted file mode 100644 index e504aaf..0000000 --- a/src/Streams/StreamPartsDirectory.hpp +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef STREAMPARTSDIRECTORY_HPP -#define STREAMPARTSDIRECTORY_HPP - - -#include -#include - -#include -#include - -#include "General.hpp" -#include "StreamDirectoryStruct.hpp" - - -class StreamPartsDirectory : public StreamDirectoryStruct -{ -public: - - StreamPartsDirectory(ContainerContext& aCtx, const fs::path& aInputStream) : StreamDirectoryStruct{aCtx, aInputStream} - { } - - std::string to_string() const override; - - void read(FileFormatVersion aVersion = FileFormatVersion::Unknown) override; - - void accept(Visitor& aVisitor) const override - { - aVisitor.visit(*this); - } -}; - - -[[maybe_unused]] -static std::string to_string(const StreamPartsDirectory& /* aObj */) -{ - // return dynamic_cast(&aObj)->to_string(); - return ""; -} - - -inline std::string StreamPartsDirectory::to_string() const -{ - return ::to_string(*this); -} - - -[[maybe_unused]] -static std::ostream& operator<<(std::ostream& aOs, const StreamPartsDirectory& aObj) -{ - aOs << to_string(aObj); - - return aOs; -} - - -#endif // STREAMPARTSDIRECTORY_HPP \ No newline at end of file diff --git a/src/Streams/StreamSymbolsDirectory.cpp b/src/Streams/StreamSymbolsDirectory.cpp deleted file mode 100644 index 3af36ae..0000000 --- a/src/Streams/StreamSymbolsDirectory.cpp +++ /dev/null @@ -1,81 +0,0 @@ -#include -#include -#include - -#include -#include - -#include "General.hpp" -#include "Streams/StreamDirectoryStruct.hpp" -#include "Streams/StreamSymbolsDirectory.hpp" - - -void StreamSymbolsDirectory::read(FileFormatVersion /* aVersion */) -{ - auto& ds = mCtx.mDs; - - mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - - lastModifiedDate = static_cast(ds.readUint32()); - - const uint16_t size = ds.readUint16(); - - for(size_t i = 0u; i < size; ++i) - { - DirItemType item; - - item.name = ds.readStringLenZeroTerm(); - - item.componentType = ToComponentType(ds.readUint16()); - - std::vector expected_types = { - ComponentType::GlobalSymbol, - ComponentType::PortSymbol, - ComponentType::OffPageSymbol, - ComponentType::TitleBlockSymbol, - ComponentType::ERCSymbol, - ComponentType::BookMarkSymbol - }; - - const auto result_it = std::find(expected_types.cbegin(), expected_types.cend(), item.componentType); - if(result_it == expected_types.cend()) - { - mCtx.mLogger.warn("{}: Unexpected ComponentType `{}`", __func__, ::to_string(item.componentType)); - } - - // @todo This changes with the version of the file format, so maybe it contains - // more details for the format? Or some hash of the specified stream? - ds.printUnknownData(14, fmt::format("item[{:>3}] - 0", i)); - - // @todo Just a guess that this is the version but's highly likely - item.fileFormatVersion = ds.readUint16(); - - mCtx.mLogger.trace("fileFormatVersion = {}", item.fileFormatVersion); - - // Known versions that I obsereved in different files - // 471 in 17.4-2019 S012 (3898062) [10/18/202] - // 472 in 17.4-2019 S019 (3959056) [7/8/2021] - std::vector knownFileVersions{ - 445, 446, 447, 448, 449, - 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, - 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, - 470, 471, 472 - }; - - if(!std::any_of(knownFileVersions.begin(), knownFileVersions.end(), [&](unsigned version){ return version == item.fileFormatVersion; })) - { - mCtx.mLogger.warn("Unexpected File Version {}", item.fileFormatVersion); - } - - item.timezone = ds.readInt16(); - - ds.printUnknownData(2, fmt::format("item[{:>3}] - 1", i)); - - items.push_back(item); - } - - ds.sanitizeEoF(); - - mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - mCtx.mLogger.info(to_string()); -} \ No newline at end of file diff --git a/src/Streams/StreamSymbolsDirectory.hpp b/src/Streams/StreamSymbolsDirectory.hpp deleted file mode 100644 index 67cb4aa..0000000 --- a/src/Streams/StreamSymbolsDirectory.hpp +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef STREAMSYMBOLSDIRECTORY_HPP -#define STREAMSYMBOLSDIRECTORY_HPP - - -#include -#include - -#include -#include - -#include "General.hpp" -#include "StreamDirectoryStruct.hpp" - - -class StreamSymbolsDirectory : public StreamDirectoryStruct -{ -public: - - StreamSymbolsDirectory(ContainerContext& aCtx, const fs::path& aInputStream) : StreamDirectoryStruct{aCtx, aInputStream} - { } - - std::string to_string() const override; - - void read(FileFormatVersion aVersion = FileFormatVersion::Unknown) override; - - void accept(Visitor& aVisitor) const override - { - aVisitor.visit(*this); - } -}; - - -[[maybe_unused]] -static std::string to_string(const StreamSymbolsDirectory& /* aObj */) -{ - // return dynamic_cast(&aObj)->to_string(); - return ""; -} - - -inline std::string StreamSymbolsDirectory::to_string() const -{ - return ::to_string(*this); -} - - -[[maybe_unused]] -static std::ostream& operator<<(std::ostream& aOs, const StreamSymbolsDirectory& aObj) -{ - aOs << to_string(aObj); - - return aOs; -} - - -#endif // STREAMSYMBOLSDIRECTORY_HPP \ No newline at end of file diff --git a/src/Streams/StreamViewsDirectory.cpp b/src/Streams/StreamViewsDirectory.cpp deleted file mode 100644 index a7fac40..0000000 --- a/src/Streams/StreamViewsDirectory.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include -#include - -#include -#include - -#include "General.hpp" -#include "Streams/StreamDirectoryStruct.hpp" -#include "Streams/StreamViewsDirectory.hpp" - - -void StreamViewsDirectory::read(FileFormatVersion /* aVersion */) -{ - auto& ds = mCtx.mDs; - - mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - - lastModifiedDate = static_cast(ds.readUint32()); - - const uint16_t size = ds.readUint16(); - - for(size_t i = 0u; i < size; ++i) - { - DirItemType item; - - item.name = ds.readStringLenZeroTerm(); - - item.componentType = ToComponentType(ds.readUint16()); - - if(item.componentType != ComponentType::View) - { - mCtx.mLogger.warn("{}: Unexpected ComponentType `{}`", __func__, ::to_string(item.componentType)); - } - - // @todo This changes with the version of the file format, so maybe it contains - // more details for the format? Or some hash of the specified stream? - ds.printUnknownData(14, fmt::format("item[{:>3}] - 0", i)); - - // @todo Just a guess that this is the version but's highly likely - item.fileFormatVersion = ds.readUint16(); - - mCtx.mLogger.trace("fileFormatVersion = {}", item.fileFormatVersion); - - // Known versions that I obsereved in different files - // 471 in 17.4-2019 S012 (3898062) [10/18/202] - // 472 in 17.4-2019 S019 (3959056) [7/8/2021] - std::vector knownFileVersions{ - 445, 446, 447, 448, 449, - 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, - 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, - 470, 471, 472 - }; - - if(!std::any_of(knownFileVersions.begin(), knownFileVersions.end(), [&](unsigned version){ return version == item.fileFormatVersion; })) - { - mCtx.mLogger.warn("Unexpected File Version {}", item.fileFormatVersion); - } - - item.timezone = ds.readInt16(); - - ds.printUnknownData(2, fmt::format("item[{:>3}] - 1", i)); - - items.push_back(item); - } - - ds.sanitizeEoF(); - - mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - mCtx.mLogger.info(to_string()); -} \ No newline at end of file diff --git a/src/Streams/StreamViewsDirectory.hpp b/src/Streams/StreamViewsDirectory.hpp deleted file mode 100644 index e940376..0000000 --- a/src/Streams/StreamViewsDirectory.hpp +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef STREAMVIEWSDIRECTORY_HPP -#define STREAMVIEWSDIRECTORY_HPP - - -#include -#include - -#include -#include - -#include "General.hpp" -#include "StreamDirectoryStruct.hpp" - - -class StreamViewsDirectory : public StreamDirectoryStruct -{ -public: - - StreamViewsDirectory(ContainerContext& aCtx, const fs::path& aInputStream) : StreamDirectoryStruct{aCtx, aInputStream} - { } - - std::string to_string() const override; - - void read(FileFormatVersion aVersion = FileFormatVersion::Unknown) override; - - void accept(Visitor& aVisitor) const override - { - aVisitor.visit(*this); - } -}; - - -[[maybe_unused]] -static std::string to_string(const StreamViewsDirectory& /* aObj */) -{ - // return dynamic_cast(&aObj)->to_string(); - return ""; -} - - -inline std::string StreamViewsDirectory::to_string() const -{ - return ::to_string(*this); -} - - -[[maybe_unused]] -static std::ostream& operator<<(std::ostream& aOs, const StreamViewsDirectory& aObj) -{ - aOs << to_string(aObj); - - return aOs; -} - - -#endif // STREAMVIEWSDIRECTORY_HPP \ No newline at end of file diff --git a/src/VisitorPattern.hpp b/src/VisitorPattern.hpp index 145d4d7..f9d5dd6 100644 --- a/src/VisitorPattern.hpp +++ b/src/VisitorPattern.hpp @@ -17,24 +17,18 @@ class PrimRect; class PrimSymbolVector; class StreamAdminData; class StreamCache; -class StreamCellsDirectory; +class StreamDirectoryStruct; class StreamDsnStream; class StreamERC; -class StreamExportBlocksDirectory; -class StreamGraphicsDirectory; class StreamHierarchy; class StreamHSObjects; class StreamLibrary; class StreamNetBundleMapData; class StreamPackage; -class StreamPackagesDirectory; class StreamPage; -class StreamPartsDirectory; class StreamSchematic; class StreamSymbol; -class StreamSymbolsDirectory; class StreamType; -class StreamViewsDirectory; class StructAlias; class StructBookMarkSymbolInst; class StructBusEntry; @@ -104,24 +98,18 @@ class Visitor virtual void visit(const PrimSymbolVector& aObj) = 0; virtual void visit(const StreamAdminData& aObj) = 0; virtual void visit(const StreamCache& aObj) = 0; - virtual void visit(const StreamCellsDirectory& aObj) = 0; + virtual void visit(const StreamDirectoryStruct& aObj) = 0; virtual void visit(const StreamDsnStream& aObj) = 0; virtual void visit(const StreamERC& aObj) = 0; - virtual void visit(const StreamExportBlocksDirectory& aObj) = 0; - virtual void visit(const StreamGraphicsDirectory& aObj) = 0; virtual void visit(const StreamHierarchy& aObj) = 0; virtual void visit(const StreamHSObjects& aObj) = 0; virtual void visit(const StreamLibrary& aObj) = 0; virtual void visit(const StreamNetBundleMapData& aObj) = 0; virtual void visit(const StreamPackage& aObj) = 0; - virtual void visit(const StreamPackagesDirectory& aObj) = 0; virtual void visit(const StreamPage& aObj) = 0; - virtual void visit(const StreamPartsDirectory& aObj) = 0; virtual void visit(const StreamSchematic& aObj) = 0; virtual void visit(const StreamSymbol& aObj) = 0; - virtual void visit(const StreamSymbolsDirectory& aObj) = 0; virtual void visit(const StreamType& aObj) = 0; - virtual void visit(const StreamViewsDirectory& aObj) = 0; virtual void visit(const StructAlias& aObj) = 0; virtual void visit(const StructBookMarkSymbolInst& aObj) = 0; virtual void visit(const StructBusEntry& aObj) = 0; diff --git a/src/XmlExporter.hpp b/src/XmlExporter.hpp index 082f648..9f6d779 100644 --- a/src/XmlExporter.hpp +++ b/src/XmlExporter.hpp @@ -65,24 +65,18 @@ class XmlExporter : public Visitor virtual void visit(const PrimSymbolVector& aObj) override; virtual void visit(const StreamAdminData& /* aObj */) override { } virtual void visit(const StreamCache& /* aObj */) override { } - virtual void visit(const StreamCellsDirectory& /* aObj */) override { } + virtual void visit(const StreamDirectoryStruct& /* aObj */) override { } virtual void visit(const StreamDsnStream& /* aObj */) override { } virtual void visit(const StreamERC& /* aObj */) override { } - virtual void visit(const StreamExportBlocksDirectory& /* aObj */) override { } - virtual void visit(const StreamGraphicsDirectory& /* aObj */) override { } virtual void visit(const StreamHierarchy& /* aObj */) override { } virtual void visit(const StreamHSObjects& /* aObj */) override { } virtual void visit(const StreamLibrary& /* aObj */) override { } virtual void visit(const StreamNetBundleMapData& /* aObj */) override { } virtual void visit(const StreamPackage& aObj) override; - virtual void visit(const StreamPackagesDirectory& /* aObj */) override { } virtual void visit(const StreamPage& /* aObj */) override { } - virtual void visit(const StreamPartsDirectory& /* aObj */) override { } virtual void visit(const StreamSchematic& /* aObj */) override { } virtual void visit(const StreamSymbol& /* aObj */) override { } - virtual void visit(const StreamSymbolsDirectory& /* aObj */) override { } virtual void visit(const StreamType& /* aObj */) override { } - virtual void visit(const StreamViewsDirectory& /* aObj */) override { } virtual void visit(const StructAlias& /* aObj */) override { } virtual void visit(const StructBookMarkSymbolInst& /* aObj */) override { } virtual void visit(const StructBusEntry& /* aObj */) override { }