[BUILD] Removed cpp20 modules. As no IDE supports them they will not be used.

This should be re-evluated later when both VScode and Clion has support for them.
This commit is contained in:
dpeter99 2022-06-15 16:31:15 +02:00
parent b4d27c8b39
commit 87e7c7d202
26 changed files with 409 additions and 421 deletions

3
.gitignore vendored
View File

@ -3,3 +3,6 @@ obj/
/packages/ /packages/
riderModule.iml riderModule.iml
/_ReSharper.Caches/ /_ReSharper.Caches/
*.user
projs/shadow-file-format/shadow-file-format.vcxproj.user

View File

@ -10,6 +10,13 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup> </ImportGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{47591591-E091-4B88-8418-74D3CBEC5712}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<PropertyGroup Label="UserMacros" /> <PropertyGroup Label="UserMacros" />
<PropertyGroup> <PropertyGroup>
<PreferredToolArchitecture>x64</PreferredToolArchitecture> <PreferredToolArchitecture>x64</PreferredToolArchitecture>
@ -47,8 +54,6 @@
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp20</LanguageStandard> <LanguageStandard>stdcpp20</LanguageStandard>
<EnableModules>true</EnableModules> <EnableModules>true</EnableModules>
<AdditionalIncludeDirectories>%(AdditionalIncludes.Split(';'));asd;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>

View File

@ -0,0 +1,16 @@
@startuml
[shadow-engine] <<static lib>> as engine
[shadow-light] <<exe>> as editor
[shadow-runner] <<exe>> as runner
[test-game] <<dll>> as game
engine <-editor
runner -> engine
game ..> engine
runner --> game : loads
editor --> game : loads
@enduml

View File

@ -1,7 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="../../Umbra.CPP.props" /> <ImportGroup Label="PropertySheets">
<Import Project="../../Umbra.CPP.props" />
</ImportGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion> <VCProjectVersion>15.0</VCProjectVersion>
@ -17,11 +19,8 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="ExtensionSettings" />
</ImportGroup> <ImportGroup Label="Shared"/>
<ImportGroup Label="Shared">
</ImportGroup>
<PropertyGroup Label="UserMacros" /> <PropertyGroup Label="UserMacros" />
<ItemGroup> <ItemGroup>

View File

@ -1,47 +1,9 @@
#include "pch.h" #include "pch.h"
import Shadow.FileFormat; //import Shadow.FileFormat;
#include "SFFWriter.h"
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 streamFrom(std::string str) {
std::stringstream ss; std::stringstream ss;
ss << str; ss << str;
@ -49,9 +11,9 @@ std::stringstream streamFrom(std::string str) {
return ss; return ss;
} }
TEST(EmptyFile, HasHeader) { TEST(Write_EmptyFile, HasHeader) {
std::stringstream ss = streamFrom(example_empty); //std::stringstream ss = streamFrom(example_empty);
//auto a = Shadow::SFF::SFFWriter:: //auto a = Shadow::SFF::SFFWriter::
@ -59,3 +21,5 @@ TEST(EmptyFile, HasHeader) {
//EXPECT_EQ(assets, nullptr); //EXPECT_EQ(assets, nullptr);
} }
*/

View File

@ -1,7 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="../../Umbra.CPP.props" /> <ImportGroup Label="PropertySheets">
<Import Project="../../Umbra.CPP.props" />
</ImportGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{3b7d6797-cc0c-43fa-8866-f438032e1c67}</ProjectGuid> <ProjectGuid>{3b7d6797-cc0c-43fa-8866-f438032e1c67}</ProjectGuid>
<Keyword>Win32Proj</Keyword> <Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0.19041.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0.19041.0</WindowsTargetPlatformVersion>
@ -14,8 +17,14 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings" /> <ImportGroup Label="ExtensionSettings" />
<ImportGroup Label="Shared" /> <ImportGroup Label="Shared" />
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" /> <PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(SolutionDir)\projs\shadow-file-format\src\; %(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="pch.h" /> <ClInclude Include="pch.h" />
</ItemGroup> </ItemGroup>
@ -23,8 +32,7 @@
<ClCompile Include="test.cpp" /> <ClCompile Include="test.cpp" />
<ClCompile Include="sff_writer_tests.cpp" /> <ClCompile Include="sff_writer_tests.cpp" />
<ClCompile Include="pch.cpp"> <ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader> <PrecompiledHeader>Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,6 +1,7 @@
#include "pch.h" #include "pch.h"
#include "../shadow-file-format/src/SFFParser.h"
import Shadow.FileFormat; //import Shadow.FileFormat;
std::string example_empty = "ShadowFileFormat_1_0_0"; std::string example_empty = "ShadowFileFormat_1_0_0";

View File

@ -1,50 +1,45 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets"> <ImportGroup Label="PropertySheets">
<Import Project="../../Umbra.CPP.props" /> <Import Project="../../Umbra.CPP.props" />
</ImportGroup> </ImportGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{B2E3515C-3FE0-44B9-9ABE-8584A836230F}</ProjectGuid> <ProjectGuid>{B2E3515C-3FE0-44B9-9ABE-8584A836230F}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>shadow_file_format</RootNamespace> <RootNamespace>shadow_file_format</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> <ProjectName>shadow-file-format</ProjectName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Label="Configuration"> <PropertyGroup Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType> <ConfigurationType>StaticLibrary</ConfigurationType>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="ExtensionSettings" />
</ImportGroup> <ImportGroup Label="Shared" />
<ImportGroup Label="Shared">
</ImportGroup>
<PropertyGroup Label="UserMacros" /> <PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup> <ItemDefinitionGroup>
<ClCompile> <ClCompile>
<CompileAs>CompileAsCppModule</CompileAs> <AdditionalIncludeDirectories>$(SolutionDir)\projs\shadow-utility\src\; %(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="src/SFFWriter.ixx" /> <ClCompile Include="src/SFFElement.cpp" />
<!--<ClCompile Include="src/SFFElement.cpp" />--> <ClCompile Include="src\SFFParser.cpp" />
<!--<ClCompile Include="src/SFFParser.cpp" />--> <ClCompile Include="src\SFFWriter.cpp" />
<ClCompile Include="src/SFFElement.ixx" /> </ItemGroup>
<ClCompile Include="src/Shadow.FileFormat.ixx" /> <ItemGroup>
<ClCompile Include="src/SFFParser.ixx" /> <ClInclude Include="src/SFFElement.h" />
<ClCompile Include="src/SFFVersion.ixx" /> <ClInclude Include="src\SFFParser.h" />
<ClInclude Include="src\SFFVersion.h" />
<ClInclude Include="src\SFFWriter.h" />
</ItemGroup>
<ItemGroup>
<Natvis Include="SFFElement.natvis" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\shadow-utility\shadow-utility.vcxproj"> <ProjectReference Include="..\shadow-utility\shadow-utility.vcxproj">
<Project>{7b9e6056-e4fb-411b-9612-a2fd679c2b69}</Project> <Project>{7b9e6056-e4fb-411b-9612-a2fd679c2b69}</Project>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Natvis Include="SFFElement.natvis" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets" />
</ImportGroup>
</Project> </Project>

View File

@ -15,35 +15,45 @@
</Filter> </Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="src\SFFParser.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src/SFFElement.cpp"> <ClCompile Include="src/SFFElement.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="src/SFFParser.cpp"> <ClCompile Include="src\SFFParser.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\SFFWriter.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="src/SFFElement.ixx" />
<ClCompile Include="src/Shadow.FileFormat.ixx" />
<ClCompile Include="src/SFFParser.ixx" />
<ClCompile Include="src/SFFVersion.ixx" />
<ClCompile Include="SFFWriter.ixx" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="src/**/*.h"> <ClInclude Include="src\SFFParser.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="src/**/*.h"> <ClInclude Include="src\SFFVersion.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="src/**/*.h"> <ClInclude Include="src\SFFWriter.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="src/**/*.h"> <ClInclude Include="src\SFFParser.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="src/**/*.h"> <ClInclude Include="src\SFFVersion.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\SFFWriter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src/SFFElement.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\SFFParser.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\SFFVersion.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\SFFWriter.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>

View File

@ -1,15 +1,35 @@
/* #include "SFFElement.h"
module;
module Shadow.FileFormat:SFFElement;
import <string>;
import shadow_utils;
namespace Shadow::SFF {
namespace Shadow::SFF {
SFFElement* SFFElement::GetFirstChild()
{
return children.size() > 0 ? children.begin()->second : nullptr;
}
SFFElement* SFFElement::GetChildByIndex(int index)
{
SFFElement::ChildrenMap::iterator it = children.begin();
if (it == children.end())
return nullptr;
for (size_t i = 0; i < index; i++)
{
it++;
}
return it->second;
}
SFFElement* SFFElement::GetChildByName(std::string name)
{
SFFElement::ChildrenMap::iterator it = children.find(name);
if (it != children.end()) {
return it->second;
}
return nullptr;
}
SFFElement::~SFFElement(){}
} }
*/

View File

@ -0,0 +1,36 @@
#pragma once
#include <string>
#include <map>
#include <list>
namespace Shadow::SFF {
class SFFElement
{
public:
SFFElement* parent;
std::string name;
bool isBlock;
std::string value;
typedef std::map<std::string, SFFElement*> ChildrenMap;
ChildrenMap children;
std::string GetStringProperty(std::string name);
SFFElement* GetFirstChild();
SFFElement* GetChildByIndex(int index);
SFFElement* GetChildByName(std::string name);
~SFFElement();
};
}

View File

@ -1,58 +0,0 @@
module;
export module Shadow.FileFormat:SFFElement;
import <string>;
import <map>;
import <list>;
namespace Shadow::SFF {
export class SFFElement
{
public:
SFFElement* parent;
std::string name;
bool isBlock;
std::string value;
typedef std::map<std::string, SFFElement*> ChildrenMap;
ChildrenMap children;
std::string GetStringProperty(std::string name);
SFFElement* GetFirstChild()
{
return children.size() > 0 ? children.begin()->second : nullptr;
}
SFFElement* GetChildByIndex(int index)
{
ChildrenMap::iterator it = children.begin();
if (it == children.end())
return nullptr;
for (size_t i = 0; i < index; i++)
{
it++;
}
return it->second;
}
SFFElement* GetChildByName(std::string name)
{
ChildrenMap::iterator it = children.find(name);
if (it != children.end()) {
return it->second;
}
return nullptr;
}
~SFFElement();
};
}

View File

@ -1,18 +1,129 @@
/* #include "SFFParser.h"
module;
import <string>;
import <iostream>;
import <string>;
import shadow_utils; #include <fstream>
module Shadow.FileFormat:SFFParser;
import :SFFElement;
import :SFFVersion;
#include "string-helpers.h"
namespace Shadow::SFF { namespace Shadow::SFF {
SFFElement* SFFParser::ReadFromStream(std::istream& stream)
{
auto version = ReadVersionFromHeader(stream);
if (version.invalid) {
//SH_CORE_WARN("Shadow File is invalid");
return nullptr;
}
//The current node that we are building
auto* context = new SFFElement;
context->name = "root";
//Top level Element
SFFElement* base = context;
//The new node that will be a child of the context
SFFElement* current = nullptr;
std::string buffer;
char c;
while (!stream.eof())
{
stream.get(c);
switch (c) {
case ':':
//The stuff in the buffer is a parameter name
//std::cout << "Name: " << buffer;
current = new SFFElement;
current->name = buffer;
current->parent = context;
buffer = "";
break;
case '{':
//Start of a new block
current->isBlock = true;
context = current;
current = nullptr;
break;
case ',':
// End of a property
if (!current->isBlock) {
//The stuff is the value
current->value = buffer;
current->parent = context;
current->isBlock = false;
}
buffer = "";
context->children[current->name] = current;
current = nullptr;
break;
case '}':
if (current != nullptr) {
// End of a block
current->parent = context;
context->children[current->name] = current;
}
current = context;
context = current->parent;
break;
default:
if (std::isspace(c) == 0)
{
buffer += c;
}
break;
}
}
//std::cout << "END" << std::endl;
return base;
}
SFFVersion SFFParser::ReadVersionFromHeader(std::istream& stream) {
std::string line;
std::getline(stream, line);
auto parts = explode(line, '_');
if (parts[0] != "ShadowFileFormat") {
return SFFVersion(-1, -1, -1);
}
else {
int mayor = std::stoi(parts[1]);
int minor = std::stoi(parts[2]);
int patch = std::stoi(parts[3]);
return SFFVersion(mayor, minor, patch);
}
}
SFFElement* SFFParser::ReadFromFile(std::string path)
{
std::ifstream inputFileStream(path);
if (errno)
{
//SH_CORE_ERROR("Error: {0} | File: {1}", strerror(errno), path);
//std::cerr << "Error: " << strerror(errno) << std::endl;
//std::cerr << "File: " << path << std::endl;
return nullptr;
}
return ReadFromStream(inputFileStream);
}
} }
*/

View File

@ -0,0 +1,22 @@
#pragma once
#include <string>
#include <iostream>
#include "SFFElement.h"
#include "SFFVersion.h"
namespace Shadow::SFF {
class SFFParser
{
public:
static SFFElement* ReadFromStream(std::istream& stream);
static SFFVersion ReadVersionFromHeader(std::istream& stream);
static SFFElement* ReadFromFile(std::string path);
};
}

View File

@ -1,142 +0,0 @@
module;
export module Shadow.FileFormat:SFFParser;
import <string>;
import <iostream>;
import <fstream>;
import <string>;
import shadow_utils;
import :SFFElement;
import :SFFVersion;
namespace Shadow::SFF {
export class SFFParser
{
public:
static SFFElement* ReadFromStream(std::istream& stream)
{
auto version = ReadVersionFromHeader(stream);
if (version.invalid) {
//SH_CORE_WARN("Shadow File is invalid");
return nullptr;
}
//The current node that we are building
auto* context = new SFFElement;
context->name = "root";
//Top level Element
SFFElement* base = context;
//The new node that will be a child of the context
SFFElement* current = nullptr;
std::string buffer;
char c;
while (!stream.eof())
{
stream.get(c);
switch (c) {
case ':':
//The stuff in the buffer is a parameter name
//std::cout << "Name: " << buffer;
current = new SFFElement;
current->name = buffer;
current->parent = context;
buffer = "";
break;
case '{':
//Start of a new block
current->isBlock = true;
context = current;
current = nullptr;
break;
case ',':
// End of a property
if (!current->isBlock) {
//The stuff is the value
current->value = buffer;
current->parent = context;
current->isBlock = false;
}
buffer = "";
context->children[current->name] = current;
current = nullptr;
break;
case '}':
if (current != nullptr) {
// End of a block
current->parent = context;
context->children[current->name] = current;
}
current = context;
context = current->parent;
break;
default:
if (std::isspace(c) == 0)
{
buffer += c;
}
break;
}
}
//std::cout << "END" << std::endl;
return base;
}
static SFFVersion ReadVersionFromHeader(std::istream& stream) {
std::string line;
std::getline(stream, line);
auto parts = explode(line, '_');
if (parts[0] != "ShadowFileFormat") {
return SFFVersion(-1, -1, -1);
}
else {
int mayor = std::stoi(parts[1]);
int minor = std::stoi(parts[2]);
int patch = std::stoi(parts[3]);
return SFFVersion(mayor, minor, patch);
}
}
static SFFElement* ReadFromFile(std::string path)
{
std::ifstream inputFileStream(path);
if (errno)
{
//SH_CORE_ERROR("Error: {0} | File: {1}", strerror(errno), path);
//std::cerr << "Error: " << strerror(errno) << std::endl;
//std::cerr << "File: " << path << std::endl;
return nullptr;
}
return ReadFromStream(inputFileStream);
}
};
}

View File

@ -1,6 +1,6 @@
export module Shadow.FileFormat:SFFVersion; #pragma once
export namespace Shadow::SFF { namespace Shadow::SFF {
struct SFFVersion { struct SFFVersion {
public: public:

View File

@ -0,0 +1,48 @@
#include "SFFWriter.h"
namespace Shadow::SFF {
void SFFWriter::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();
}
void SFFWriter::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.children)
{
WriteElement(w, *prop.second, depth);
}
std::string close = "}";
close.insert(head.begin(), depth, '\t');
w << close;
depth -= 1;
}
else
{
w << e.value << ",";
}
}
}

View File

@ -0,0 +1,26 @@
#pragma once
#include <string>
#include <iostream>
#include <fstream>
#include "SFFElement.h"
#include "SFFVersion.h"
namespace Shadow::SFF {
class SFFWriter
{
public:
static void WriteFile(SFFElement& root, std::string path);
static void WriteElement(std::ostream& w, SFFElement& e, int &depth);
};
}

View File

@ -1,68 +0,0 @@
module;
//#include <iostream>;
//#include <fstream>;
export module Shadow.FileFormat:SFFWriter;
import <string>;
import <iostream>;
import <fstream>;
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 << ",";
}
}
};
}

View File

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="../../Umbra.CPP.props" /> <ImportGroup Label="PropertySheets">
<Import Project="../../Umbra.CPP.props" />
</ImportGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion> <VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{7B9E6056-E4FB-411B-9612-A2FD679C2B69}</ProjectGuid> <ProjectGuid>{7B9E6056-E4FB-411B-9612-A2FD679C2B69}</ProjectGuid>
@ -13,27 +15,21 @@
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="ExtensionSettings"/>
</ImportGroup> <ImportGroup Label="Shared"/>
<ImportGroup Label="Shared">
</ImportGroup>
<PropertyGroup Label="UserMacros" /> <PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<CompileAs>CompileAsCppModule</CompileAs>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<CompileAs>CompileAsCppModule</CompileAs>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="src\string-helpers.h" /> <ClInclude Include="src\string-helpers.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="shadow-utils.ixx" /> <ClCompile Include="src\string-helpers.cpp" />
<ClCompile Include="string-helpers.cpp" /> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\shadow-entity\shadow-entity.vcxproj">
<Project>{47591591-e091-4b88-8418-74d3cbec5712}</Project>
</ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">

View File

@ -20,7 +20,6 @@
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="shadow-utils.ixx" />
<ClCompile Include="string-helpers.cpp"> <ClCompile Include="string-helpers.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>

View File

@ -1,11 +1,7 @@
module;
module shadow_utils; #include "string-helpers.h"
import <string>; std::vector<std::string> explode(const std::string& s, const char& c)
import <vector>;
inline std::vector<std::string> explode(const std::string& s, const char& c)
{ {
std::string buff; std::string buff;
std::vector<std::string> v; std::vector<std::string> v;

View File

@ -1,2 +1,6 @@
#pragma once #pragma once
#include <string>
#include <vector>
std::vector<std::string> explode(const std::string& s, const char& c);

View File

@ -9,12 +9,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shadow-entity", "projs\shad
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vendor", "vendor", "{D53EF63D-47DE-4936-8707-CE5E59FC0F7A}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vendor", "vendor", "{D53EF63D-47DE-4936-8707-CE5E59FC0F7A}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shadow-file-format", "projs\shadow-file-format\shadow-file-format.vcxproj", "{B2E3515C-3FE0-44B9-9ABE-8584A836230F}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shadow-file-format-test", "projs\shadow-file-format-test\shadow-file-format-test.vcxproj", "{3B7D6797-CC0C-43FA-8866-F438032E1C67}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shadow-file-format-test", "projs\shadow-file-format-test\shadow-file-format-test.vcxproj", "{3B7D6797-CC0C-43FA-8866-F438032E1C67}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shadow-utility", "projs\shadow-utility\shadow-utility.vcxproj", "{7B9E6056-E4FB-411B-9612-A2FD679C2B69}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shadow-utility", "projs\shadow-utility\shadow-utility.vcxproj", "{7B9E6056-E4FB-411B-9612-A2FD679C2B69}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shadow-file-format", "projs\shadow-file-format\shadow-file-format.vcxproj", "{B2E3515C-3FE0-44B9-9ABE-8584A836230F}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64 Debug|x64 = Debug|x64
@ -29,10 +29,6 @@ Global
{47591591-E091-4B88-8418-74D3CBEC5712}.Debug|x64.Build.0 = Debug|x64 {47591591-E091-4B88-8418-74D3CBEC5712}.Debug|x64.Build.0 = Debug|x64
{47591591-E091-4B88-8418-74D3CBEC5712}.Release|x64.ActiveCfg = Release|x64 {47591591-E091-4B88-8418-74D3CBEC5712}.Release|x64.ActiveCfg = Release|x64
{47591591-E091-4B88-8418-74D3CBEC5712}.Release|x64.Build.0 = Release|x64 {47591591-E091-4B88-8418-74D3CBEC5712}.Release|x64.Build.0 = Release|x64
{B2E3515C-3FE0-44B9-9ABE-8584A836230F}.Debug|x64.ActiveCfg = Debug|x64
{B2E3515C-3FE0-44B9-9ABE-8584A836230F}.Debug|x64.Build.0 = Debug|x64
{B2E3515C-3FE0-44B9-9ABE-8584A836230F}.Release|x64.ActiveCfg = Release|x64
{B2E3515C-3FE0-44B9-9ABE-8584A836230F}.Release|x64.Build.0 = Release|x64
{3B7D6797-CC0C-43FA-8866-F438032E1C67}.Debug|x64.ActiveCfg = Debug|x64 {3B7D6797-CC0C-43FA-8866-F438032E1C67}.Debug|x64.ActiveCfg = Debug|x64
{3B7D6797-CC0C-43FA-8866-F438032E1C67}.Debug|x64.Build.0 = Debug|x64 {3B7D6797-CC0C-43FA-8866-F438032E1C67}.Debug|x64.Build.0 = Debug|x64
{3B7D6797-CC0C-43FA-8866-F438032E1C67}.Release|x64.ActiveCfg = Release|x64 {3B7D6797-CC0C-43FA-8866-F438032E1C67}.Release|x64.ActiveCfg = Release|x64
@ -41,6 +37,10 @@ Global
{7B9E6056-E4FB-411B-9612-A2FD679C2B69}.Debug|x64.Build.0 = Debug|x64 {7B9E6056-E4FB-411B-9612-A2FD679C2B69}.Debug|x64.Build.0 = Debug|x64
{7B9E6056-E4FB-411B-9612-A2FD679C2B69}.Release|x64.ActiveCfg = Release|x64 {7B9E6056-E4FB-411B-9612-A2FD679C2B69}.Release|x64.ActiveCfg = Release|x64
{7B9E6056-E4FB-411B-9612-A2FD679C2B69}.Release|x64.Build.0 = Release|x64 {7B9E6056-E4FB-411B-9612-A2FD679C2B69}.Release|x64.Build.0 = Release|x64
{B2E3515C-3FE0-44B9-9ABE-8584A836230F}.Debug|x64.ActiveCfg = Debug|x64
{B2E3515C-3FE0-44B9-9ABE-8584A836230F}.Debug|x64.Build.0 = Debug|x64
{B2E3515C-3FE0-44B9-9ABE-8584A836230F}.Release|x64.ActiveCfg = Release|x64
{B2E3515C-3FE0-44B9-9ABE-8584A836230F}.Release|x64.Build.0 = Release|x64
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -8,6 +8,7 @@
$(SolutionDir)vendor/sdl2/SDL2-2.0.22/include/ $(SolutionDir)vendor/sdl2/SDL2-2.0.22/include/
</Item> </Item>
</ItemGroup> </ItemGroup>
<ClCompile> <ClCompile>
<AdditionalIncludeDirectories>$(SolutionDir)vendor/sdl2/SDL2-2.0.22/include/; %(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(SolutionDir)vendor/sdl2/SDL2-2.0.22/include/; %(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>