Skip to content

Commit

Permalink
Rename Parser to Container
Browse files Browse the repository at this point in the history
  • Loading branch information
Werni2A committed Dec 24, 2023
1 parent 23ab7a4 commit fd6fc26
Show file tree
Hide file tree
Showing 13 changed files with 299 additions and 299 deletions.
4 changes: 2 additions & 2 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ find_package(tinyxml2 CONFIG REQUIRED)

set(SOURCES
${LIB_SRC_DIR}/CommonBase.cpp
${LIB_SRC_DIR}/Container.cpp
${LIB_SRC_DIR}/ContainerExtractor.cpp
${LIB_SRC_DIR}/DataStream.cpp
# ${LIB_SRC_DIR}/Misc.cpp
${LIB_SRC_DIR}/PageSettings.cpp
${LIB_SRC_DIR}/Parser.cpp
${LIB_SRC_DIR}/Primitives/Point.cpp
${LIB_SRC_DIR}/Primitives/PrimArc.cpp
${LIB_SRC_DIR}/Primitives/PrimBezier.cpp
Expand Down Expand Up @@ -99,6 +99,7 @@ set(SOURCES
)

set(HEADERS
${LIB_INCLUDE_DIR}/Container.hpp
${LIB_INCLUDE_DIR}/ContainerExtractor.hpp
${LIB_INCLUDE_DIR}/DataStream.hpp
${LIB_INCLUDE_DIR}/Enums/Color.hpp
Expand All @@ -113,7 +114,6 @@ set(HEADERS
${LIB_INCLUDE_DIR}/FutureData.hpp
${LIB_INCLUDE_DIR}/General.hpp
${LIB_INCLUDE_DIR}/PageSettings.hpp
${LIB_INCLUDE_DIR}/Parser.hpp
${LIB_INCLUDE_DIR}/ParserContext.hpp
${LIB_INCLUDE_DIR}/Primitives/Point.hpp
${LIB_INCLUDE_DIR}/Primitives/PrimArc.hpp
Expand Down
22 changes: 11 additions & 11 deletions src/Parser.cpp → src/Container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <spdlog/spdlog.h>

#include "CommonBase.hpp"
#include "Container.hpp"
#include "ContainerExtractor.hpp"
#include "DataStream.hpp"
#include "Enums/FillStyle.hpp"
Expand All @@ -32,7 +33,6 @@
#include "Exception.hpp"
#include "General.hpp"
#include "Library.hpp"
#include "Parser.hpp"
#include "PinShape.hpp"
#include "StreamFactory.hpp"

Expand All @@ -46,7 +46,7 @@ FileType gFileType = FileType::Library; // @todo move to parser context
FileFormatVersion gFileFormatVersion = FileFormatVersion::C; // @todo move to parser context


Parser::Parser(const fs::path& aCfbfContainer, ParserConfig aCfg) :
Container::Container(const fs::path& aCfbfContainer, ParserConfig aCfg) :
mFileCtr{0U}, mFileErrCtr{0U}, tmpCtx{"", "", "", aCfg}, mCtx{tmpCtx}, mCfg{aCfg}
{
gFileType = getFileTypeByExtension(aCfbfContainer);
Expand All @@ -67,7 +67,7 @@ Parser::Parser(const fs::path& aCfbfContainer, ParserConfig aCfg) :
}


Parser::~Parser()
Container::~Container()
{
if(!mCfg.mKeepTmpFiles)
{
Expand All @@ -81,7 +81,7 @@ Parser::~Parser()
/**
* @brief Parse the whole library.
*/
void Parser::parseLibrary()
void Container::parseLibrary()
{
spdlog::info("Start parsing library located at {}", mExtractedCfbfPath.string());

Expand Down Expand Up @@ -134,7 +134,7 @@ void Parser::parseLibrary()
}


void Parser::exceptionHandling()
void Container::exceptionHandling()
{
try
{
Expand All @@ -158,7 +158,7 @@ void Parser::exceptionHandling()
}


fs::path Parser::extractContainer(const fs::path& aFile, const fs::path& aOutDir) const
fs::path Container::extractContainer(const fs::path& aFile, const fs::path& aOutDir) const
{
ContainerExtractor extractor{aFile};

Expand All @@ -168,20 +168,20 @@ fs::path Parser::extractContainer(const fs::path& aFile, const fs::path& aOutDir
}


fs::path Parser::extractContainer(const fs::path& aOutDir) const
fs::path Container::extractContainer(const fs::path& aOutDir) const
{
return extractContainer(mInputCfbfFile, aOutDir);
}


void Parser::printContainerTree() const
void Container::printContainerTree() const
{
ContainerExtractor extractor{mInputCfbfFile};
extractor.printContainerTree();
}


FileType Parser::getFileTypeByExtension(const fs::path& aFile) const
FileType Container::getFileTypeByExtension(const fs::path& aFile) const
{
std::string extension = aFile.extension().string();

Expand Down Expand Up @@ -212,15 +212,15 @@ FileType Parser::getFileTypeByExtension(const fs::path& aFile) const
}


void Parser::openFile(const fs::path& aInputStream)
void Container::openFile(const fs::path& aInputStream)
{
spdlog::info("Opening file: {}", aInputStream.string());

spdlog::info("File contains {} byte.", fs::file_size(aInputStream));
}


void Parser::closeFile()
void Container::closeFile()
{
spdlog::info("Closing file: {}", mCtx.get().mInputStream.string());

Expand Down
12 changes: 6 additions & 6 deletions src/Parser.hpp → src/Container.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef PARSER_HPP
#define PARSER_HPP
#ifndef CONTAINER_HPP
#define CONTAINER_HPP


#include <any>
Expand All @@ -25,13 +25,13 @@
namespace fs = std::filesystem;


class Parser
class Container
{
public:

Parser(const fs::path& aFile, ParserConfig aCfg);
Container(const fs::path& aFile, ParserConfig aCfg);

~Parser();
~Container();

size_t getFileErrCtr() const
{
Expand Down Expand Up @@ -102,4 +102,4 @@ class Parser
};


#endif // PARSER_HPP
#endif // CONTAINER_HPP
2 changes: 1 addition & 1 deletion src/Misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ std::string SymbolUserProp::getVal() const


// @todo this is a whole file parser. Split it up into the title block structure and move the rest to the symbol parser?
void Parser::readTitleBlockSymbol()
void Container::readTitleBlockSymbol()
{
auto& ds = mCtx.get().mDs.get();

Expand Down
2 changes: 1 addition & 1 deletion src/Structures/StructBookMarkSymbolInst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

#include <nameof.hpp>

#include "Container.hpp"
#include "Enums/Structure.hpp"
#include "General.hpp"
#include "Parser.hpp"
#include "Structures/StructBookMarkSymbolInst.hpp"


Expand Down
2 changes: 1 addition & 1 deletion src/Structures/StructERCSymbolInst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

#include <nameof.hpp>

#include "Container.hpp"
#include "Enums/Structure.hpp"
#include "General.hpp"
#include "Parser.hpp"
#include "Structures/StructERCSymbolInst.hpp"


Expand Down
2 changes: 1 addition & 1 deletion src/Structures/StructGlobal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

#include <nameof.hpp>

#include "Container.hpp"
#include "Enums/Structure.hpp"
#include "General.hpp"
#include "Parser.hpp"
#include "Structures/StructGlobal.hpp"


Expand Down
2 changes: 1 addition & 1 deletion src/Structures/StructT0x10.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

#include <nameof.hpp>

#include "Container.hpp"
#include "Enums/Structure.hpp"
#include "General.hpp"
#include "Parser.hpp"
#include "Structures/StructT0x10.hpp"


Expand Down
2 changes: 1 addition & 1 deletion src/Structures/StructTitleBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

#include <nameof.hpp>

#include "Container.hpp"
#include "Enums/Structure.hpp"
#include "General.hpp"
#include "Parser.hpp"
#include "Structures/StructTitleBlock.hpp"


Expand Down
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <spdlog/sinks/stdout_color_sinks.h>
#include <spdlog/spdlog.h>

#include "Parser.hpp"
#include "Container.hpp"
#include "XmlExporter.hpp"


Expand Down Expand Up @@ -153,7 +153,7 @@ int main(int argc, char* argv[])
cfg.mSkipInvalidPrim = allowSkipping;
cfg.mKeepTmpFiles = keepTmpFiles;

Parser parser{inputFile, cfg};
Container parser{inputFile, cfg};

ParserContext& ctx = parser.getContext();

Expand Down
4 changes: 2 additions & 2 deletions test/py/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def create_repo_cpp_unit_test(repo: Repository, path_repo: str, path_unit_test:
#include <catch2/catch_all.hpp>
#include <Parser.hpp>
#include <Container.hpp>
#include "Helper.hpp"
Expand All @@ -125,7 +125,7 @@ def create_repo_cpp_unit_test(repo: Repository, path_repo: str, path_unit_test:
ParserConfig cfg = get_parser_config();
Parser parser{{inputFile, cfg}};
Container parser{{inputFile, cfg}};
parser.parseLibrary();
check_error_count(inputFile, parser.getFileErrCtr(), {file.errors});
Expand Down
2 changes: 1 addition & 1 deletion test/src/Helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include <spdlog/spdlog.h>

#include <Parser.hpp>
#include <Container.hpp>


namespace fs = std::filesystem;
Expand Down
Loading

0 comments on commit fd6fc26

Please sign in to comment.