diff --git a/msbuild.binlog b/msbuild.binlog new file mode 100644 index 0000000..912cac3 Binary files /dev/null and b/msbuild.binlog differ diff --git a/projs/shadow-file-format-test/test.cpp b/projs/shadow-file-format-test/test.cpp index e238589..c0bb16c 100644 --- a/projs/shadow-file-format-test/test.cpp +++ b/projs/shadow-file-format-test/test.cpp @@ -1,5 +1,7 @@ #include "pch.h" +import Shadow.FileFormat; + TEST(TestCaseName, TestName) { EXPECT_EQ(1, 1); EXPECT_TRUE(true); diff --git a/projs/shadow-file-format/shadow-file-format.cpp b/projs/shadow-file-format/shadow-file-format.cpp deleted file mode 100644 index 662f75c..0000000 --- a/projs/shadow-file-format/shadow-file-format.cpp +++ /dev/null @@ -1,3 +0,0 @@ - -// TODO: write your library functions here - diff --git a/projs/shadow-file-format/shadow-file-format.vcxproj b/projs/shadow-file-format/shadow-file-format.vcxproj index 69655da..c6578f5 100644 --- a/projs/shadow-file-format/shadow-file-format.vcxproj +++ b/projs/shadow-file-format/shadow-file-format.vcxproj @@ -18,10 +18,22 @@ + + + CompileAsCppModule + + - - + + + + + + + + + {7b9e6056-e4fb-411b-9612-a2fd679c2b69} diff --git a/projs/shadow-file-format/shadow-file-format.vcxproj.filters b/projs/shadow-file-format/shadow-file-format.vcxproj.filters index f322c4d..f5fb9e6 100644 --- a/projs/shadow-file-format/shadow-file-format.vcxproj.filters +++ b/projs/shadow-file-format/shadow-file-format.vcxproj.filters @@ -15,7 +15,7 @@ - + Source Files @@ -24,9 +24,20 @@ Source Files + + Source Files + + + Source Files + + + - + + Header Files + + Header Files @@ -41,5 +52,14 @@ Header Files + + Header Files + + + Header Files + + + Header Files + \ No newline at end of file diff --git a/projs/shadow-file-format/src/SFFElement.cpp b/projs/shadow-file-format/src/SFFElement.cpp index 82d4975..f8d01ec 100644 --- a/projs/shadow-file-format/src/SFFElement.cpp +++ b/projs/shadow-file-format/src/SFFElement.cpp @@ -1,26 +1,37 @@ -//#include "pch.h" -#include "SFFElement.h" +module; -SFFElement* SFFElement::GetFirstChild() -{ - return children.size() > 0 ? children[0]: nullptr; -} +import ; -SFFElement* SFFElement::GetChildByIndex(int i) -{ - ChildrenMap::iterator it = children.begin(); - for (size_t i = 0; i < i; i++) +import shadow_utils; + +module Shadow.FileFormat:SFFElement; + + +namespace Shadow::SFF { + + + SFFElement* SFFElement::GetFirstChild() { - it++; + return children.size() > 0 ? children.begin()->second : nullptr; } - return it->second; -} -SFFElement* SFFElement::GetChildByName(std::string name) -{ - ChildrenMap::iterator it = children.find(name); - if (it != children.end()) { + SFFElement* SFFElement::GetChildByIndex(int index) + { + ChildrenMap::iterator it = children.begin(); + for (size_t i = 0; i < index; i++) + { + it++; + } return it->second; } - return nullptr; -} + + SFFElement* SFFElement::GetChildByName(std::string name) + { + ChildrenMap::iterator it = children.find(name); + if (it != children.end()) { + return it->second; + } + return nullptr; + } + +} \ No newline at end of file diff --git a/projs/shadow-file-format/src/SFFElement.h b/projs/shadow-file-format/src/SFFElement.h deleted file mode 100644 index 1002099..0000000 --- a/projs/shadow-file-format/src/SFFElement.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -#include -#include -#include - -class SFFElement -{ -public: - SFFElement* parent; - - std::string name; - - bool isBlock; - - std::string value; - typedef std::map ChildrenMap; - - std::list properties_old; - std::map children; - - std::string GetStringProperty(std::string name); - - SFFElement* GetFirstChild(); - - SFFElement* GetChildByIndex(int i); - SFFElement* GetChildByName(std::string name); - - ~SFFElement(); - -}; diff --git a/projs/shadow-file-format/src/SFFElement.ixx b/projs/shadow-file-format/src/SFFElement.ixx new file mode 100644 index 0000000..7098821 --- /dev/null +++ b/projs/shadow-file-format/src/SFFElement.ixx @@ -0,0 +1,40 @@ +module; + +import ; +import ; +import ; + +export module Shadow.FileFormat:SFFElement; + + +export namespace Shadow::SFF { + + class SFFElement + { + public: + SFFElement* parent; + + std::string name; + + bool isBlock; + + std::string value; + typedef std::map ChildrenMap; + + std::list properties_old; + std::map children; + + std::string GetStringProperty(std::string name); + + + SFFElement* GetFirstChild(); + + SFFElement* GetChildByIndex(int index); + + SFFElement* GetChildByName(std::string name); + + ~SFFElement(); + + }; + +} \ No newline at end of file diff --git a/projs/shadow-file-format/src/SFFParser.cpp b/projs/shadow-file-format/src/SFFParser.cpp index 4d056ca..367e1ec 100644 --- a/projs/shadow-file-format/src/SFFParser.cpp +++ b/projs/shadow-file-format/src/SFFParser.cpp @@ -1,12 +1,17 @@ -#include "SFFParser.h" - -#include -#include +module; +import ; +import ; +import ; import shadow_utils; +module Shadow.FileFormat:SFFParser; -namespace ShadowEngine::SFF { +import :SFFElement; +import :SFFVersion; + + +namespace Shadow::SFF { SFFElement* SFFParser::ReadFromStream(std::istream& stream) { @@ -27,8 +32,6 @@ namespace ShadowEngine::SFF { auto* current = new SFFElement; - - std::string buffer; char c; diff --git a/projs/shadow-file-format/src/SFFParser.h b/projs/shadow-file-format/src/SFFParser.ixx similarity index 57% rename from projs/shadow-file-format/src/SFFParser.h rename to projs/shadow-file-format/src/SFFParser.ixx index 09b0287..53621ed 100644 --- a/projs/shadow-file-format/src/SFFParser.h +++ b/projs/shadow-file-format/src/SFFParser.ixx @@ -1,12 +1,19 @@ -#pragma once -#include "SFFElement.h" -#include "SFFVersion.h" +module; -namespace ShadowEngine::SFF { +import ; +import ; + +export module Shadow.FileFormat:SFFParser; + +import :SFFElement; +import :SFFVersion; + +export namespace Shadow::SFF { class SFFParser { public: + static SFFElement* ReadFromStream(std::istream& stream); static SFFVersion ReadVersionFromHeader(std::istream& stream); diff --git a/projs/shadow-file-format/src/SFFVersion.h b/projs/shadow-file-format/src/SFFVersion.h deleted file mode 100644 index 0f9815c..0000000 --- a/projs/shadow-file-format/src/SFFVersion.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -struct SFFVersion { -public: - int mayor; - int minor; - int patch; - - bool invalid; - - SFFVersion(int ma, int mi, int pa) - { - this->mayor = ma; - this->minor = mi; - this->patch = pa; - - if (ma >= 0 && mi >= 0 && pa >= 0) { - this->invalid = false; - } - else - { - invalid = true; - } - } -}; \ No newline at end of file diff --git a/projs/shadow-file-format/src/SFFVersion.ixx b/projs/shadow-file-format/src/SFFVersion.ixx new file mode 100644 index 0000000..44d5da7 --- /dev/null +++ b/projs/shadow-file-format/src/SFFVersion.ixx @@ -0,0 +1,28 @@ +export module Shadow.FileFormat:SFFVersion; + +export namespace Shadow::SFF { + + struct SFFVersion { + public: + int mayor; + int minor; + int patch; + + bool invalid; + + SFFVersion(int ma, int mi, int pa) + { + this->mayor = ma; + this->minor = mi; + this->patch = pa; + + if (ma >= 0 && mi >= 0 && pa >= 0) { + this->invalid = false; + } + else + { + invalid = true; + } + } + }; +} \ No newline at end of file diff --git a/projs/shadow-file-format/src/Shadow.FileFormat.ixx b/projs/shadow-file-format/src/Shadow.FileFormat.ixx new file mode 100644 index 0000000..4801a80 --- /dev/null +++ b/projs/shadow-file-format/src/Shadow.FileFormat.ixx @@ -0,0 +1,5 @@ +export module Shadow.FileFormat; + +export import :SFFElement; +export import :SFFParser; +export import :SFFVersion; \ No newline at end of file diff --git a/projs/shadow-utility/shadow-utils.ixx b/projs/shadow-utility/shadow-utils.ixx index 9585748..e5b693b 100644 --- a/projs/shadow-utility/shadow-utils.ixx +++ b/projs/shadow-utility/shadow-utils.ixx @@ -1,5 +1,9 @@ +module; + +#include +#include + export module shadow_utils; -import std.core; export std::vector explode(const std::string& s, const char& c); \ No newline at end of file diff --git a/projs/shadow-utility/string-helpers.cpp b/projs/shadow-utility/string-helpers.cpp index aa84ada..6a5ce44 100644 --- a/projs/shadow-utility/string-helpers.cpp +++ b/projs/shadow-utility/string-helpers.cpp @@ -1,8 +1,10 @@ +module; + +import ; +import ; + module shadow_utils; -import std.core; - - inline std::vector explode(const std::string& s, const char& c) { std::string buff;