diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7cd4adf..91ddb87 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,7 +4,7 @@ on: push: branches: [ main ] paths-ignore: - - 'docs/**' + - 'projs/docs/**' - 'specs/**' jobs: diff --git a/projs/docs/thesis/.gitkeep b/projs/docs/thesis/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/projs/shadow-file-format-test/sff_writer_tests.cpp b/projs/shadow-file-format-test/sff_writer_tests.cpp new file mode 100644 index 0000000..1228f8c --- /dev/null +++ b/projs/shadow-file-format-test/sff_writer_tests.cpp @@ -0,0 +1,61 @@ +#include "pch.h" + +import Shadow.FileFormat; + +std::string example_empty = "ShadowFileFormat_1_0_0"; + +std::string example_simple = "ShadowFileFormat_1_0_0 \n\ +Assets:{ \ + 9:Content_9, \ + 10 : Content_10, \ + 11: Content_11, \ +}, \ +"; + +std::string example_multi_root = +"ShadowFileFormat_1_0_0 \n \ +Assets:{ \ + 9:Content_9, \ +}, \ +Texture:{ \ + texture:checker_board.png, \ +}, \ +"; + + +std::string example_multi_level = "ShadowFileFormat_1_0_0 \n\ +Assets:{ \ + 9: { \ + \ + }, \ +}, \ +"; + +std::string example_multi_level_content = "ShadowFileFormat_1_0_0 \n\ +Assets:{ \ + a: { \ + 0: ContentContent0, \ + 1: ContentContent1, \ + 2: ContentContent2, \ + }, \ + b: ContentB, \ +}, \ +"; + +std::stringstream streamFrom(std::string str) { + std::stringstream ss; + ss << str; + + return ss; +} + +TEST(EmptyFile, HasHeader) { + + std::stringstream ss = streamFrom(example_empty); + + //auto a = Shadow::SFF::SFFWriter:: + + //auto assets = a->GetChildByIndex(0); + + //EXPECT_EQ(assets, nullptr); +} \ No newline at end of file diff --git a/projs/shadow-file-format-test/shadow-file-format-test.vcxproj b/projs/shadow-file-format-test/shadow-file-format-test.vcxproj index 951ec61..79d44f2 100644 --- a/projs/shadow-file-format-test/shadow-file-format-test.vcxproj +++ b/projs/shadow-file-format-test/shadow-file-format-test.vcxproj @@ -21,6 +21,7 @@ + Create Create diff --git a/projs/shadow-file-format/shadow-file-format.vcxproj b/projs/shadow-file-format/shadow-file-format.vcxproj index 9287768..32eae02 100644 --- a/projs/shadow-file-format/shadow-file-format.vcxproj +++ b/projs/shadow-file-format/shadow-file-format.vcxproj @@ -1,6 +1,10 @@ - + + + + + 15.0 {B2E3515C-3FE0-44B9-9ABE-8584A836230F} @@ -24,8 +28,9 @@ - - + + + diff --git a/projs/shadow-file-format/shadow-file-format.vcxproj.filters b/projs/shadow-file-format/shadow-file-format.vcxproj.filters index beff2f9..16f1e99 100644 --- a/projs/shadow-file-format/shadow-file-format.vcxproj.filters +++ b/projs/shadow-file-format/shadow-file-format.vcxproj.filters @@ -18,9 +18,6 @@ Source Files - - Source Files - Source Files @@ -31,6 +28,7 @@ + diff --git a/projs/shadow-file-format/src/SFFWriter.ixx b/projs/shadow-file-format/src/SFFWriter.ixx new file mode 100644 index 0000000..57b47c1 --- /dev/null +++ b/projs/shadow-file-format/src/SFFWriter.ixx @@ -0,0 +1,68 @@ +module; + +//#include ; +//#include ; + +export module Shadow.FileFormat:SFFWriter; + +import ; +import ; +import ; +import shadow_utils; + +import :SFFElement; +import :SFFVersion; + +namespace Shadow::SFF { + + export class SFFParser + { + public: + + static void WriteFile(SFFElement& root, std::string path) + { + std::ofstream writer(path); + writer << "ShadowFileFormat_1_0_0" << std::endl; + + int depth = 0; + WriteElement(writer, root, depth); + + writer.flush(); + } + + static void WriteElement(std::ostream& w, SFFElement& e, int &depth) + { + std::string head = (e.name + (e.isBlock ? ":{" : ":")); + //head = head.PadLeft(depth + head.Length, '\t'); + head.insert(head.begin(), depth, '\t'); + w << head << std::endl; + + if (e.isBlock) + { + depth += 1; + w << std::endl; + for(auto& prop : e.properties) + { + WriteElement(w, prop.Value, depth); + } + + std::string close = "}"; + close.insert(head.begin(), depth, '\t'); + w << close; + depth -= 1; + } + else + { + w << e.value << ","; + } + + + } + + + + }; + +} + + diff --git a/projs/shadow-file-format/src/Shadow.FileFormat.ixx b/projs/shadow-file-format/src/Shadow.FileFormat.ixx index 4801a80..2ae9403 100644 --- a/projs/shadow-file-format/src/Shadow.FileFormat.ixx +++ b/projs/shadow-file-format/src/Shadow.FileFormat.ixx @@ -2,4 +2,5 @@ export module Shadow.FileFormat; export import :SFFElement; export import :SFFParser; +export import :SFFWriter; export import :SFFVersion; \ No newline at end of file