Removed std.core

This commit is contained in:
dpeter99 2022-05-26 23:52:01 +02:00
parent 080f6177d2
commit defbb33ce8
15 changed files with 172 additions and 97 deletions

BIN
msbuild.binlog Normal file

Binary file not shown.

View File

@ -1,5 +1,7 @@
#include "pch.h" #include "pch.h"
import Shadow.FileFormat;
TEST(TestCaseName, TestName) { TEST(TestCaseName, TestName) {
EXPECT_EQ(1, 1); EXPECT_EQ(1, 1);
EXPECT_TRUE(true); EXPECT_TRUE(true);

View File

@ -1,3 +0,0 @@
// TODO: write your library functions here

View File

@ -18,10 +18,22 @@
<ImportGroup Label="Shared"> <ImportGroup Label="Shared">
</ImportGroup> </ImportGroup>
<PropertyGroup Label="UserMacros" /> <PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup>
<ClCompile>
<CompileAs>CompileAsCppModule</CompileAs>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="src/**/*.cpp" /> <ClCompile Include="src/SFFElement.cpp" />
<ClInclude Include="src/**/*.h" /> <ClCompile Include="src/SFFParser.cpp" />
<ClCompile Include="src/SFFElement.ixx" />
<ClCompile Include="src/Shadow.FileFormat.ixx" />
<ClCompile Include="src/SFFParser.ixx" />
<ClCompile Include="src/SFFVersion.ixx" />
</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>

View File

@ -15,7 +15,7 @@
</Filter> </Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="src/**/*.cpp"> <ClCompile Include="src\SFFParser.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="src/**/*.cpp"> <ClCompile Include="src/**/*.cpp">
@ -24,9 +24,20 @@
<ClCompile Include="src/**/*.cpp"> <ClCompile Include="src/**/*.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="src/SFFElement.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src/SFFParser.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SFFElement.ixx" />
<ClCompile Include="Shadow.FileFormat.ixx" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="src/**/*.h"> <ClInclude Include="src\SFFParser.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\SFFVersion.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="src/**/*.h"> <ClInclude Include="src/**/*.h">
@ -41,5 +52,14 @@
<ClInclude Include="src/**/*.h"> <ClInclude Include="src/**/*.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="src/**/*.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>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

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

View File

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

View File

@ -0,0 +1,40 @@
module;
import <string>;
import <map>;
import <list>;
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<std::string, SFFElement*> ChildrenMap;
std::list<SFFElement*> properties_old;
std::map<std::string, SFFElement*> children;
std::string GetStringProperty(std::string name);
SFFElement* GetFirstChild();
SFFElement* GetChildByIndex(int index);
SFFElement* GetChildByName(std::string name);
~SFFElement();
};
}

View File

@ -1,12 +1,17 @@
#include "SFFParser.h" module;
import <string>;
#include <fstream> import <iostream>;
#include <iostream> import <string>;
import shadow_utils; import shadow_utils;
module Shadow.FileFormat:SFFParser;
namespace ShadowEngine::SFF { import :SFFElement;
import :SFFVersion;
namespace Shadow::SFF {
SFFElement* SFFParser::ReadFromStream(std::istream& stream) SFFElement* SFFParser::ReadFromStream(std::istream& stream)
{ {
@ -27,8 +32,6 @@ namespace ShadowEngine::SFF {
auto* current = new SFFElement; auto* current = new SFFElement;
std::string buffer; std::string buffer;
char c; char c;

View File

@ -1,12 +1,19 @@
#pragma once module;
#include "SFFElement.h"
#include "SFFVersion.h"
namespace ShadowEngine::SFF { import <string>;
import <iostream>;
export module Shadow.FileFormat:SFFParser;
import :SFFElement;
import :SFFVersion;
export namespace Shadow::SFF {
class SFFParser class SFFParser
{ {
public: public:
static SFFElement* ReadFromStream(std::istream& stream); static SFFElement* ReadFromStream(std::istream& stream);
static SFFVersion ReadVersionFromHeader(std::istream& stream); static SFFVersion ReadVersionFromHeader(std::istream& stream);

View File

@ -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;
}
}
};

View File

@ -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;
}
}
};
}

View File

@ -0,0 +1,5 @@
export module Shadow.FileFormat;
export import :SFFElement;
export import :SFFParser;
export import :SFFVersion;

View File

@ -1,5 +1,9 @@
module;
#include <string>
#include <vector>
export module shadow_utils; export module shadow_utils;
import std.core;
export std::vector<std::string> explode(const std::string& s, const char& c); export std::vector<std::string> explode(const std::string& s, const char& c);

View File

@ -1,8 +1,10 @@
module;
import <string>;
import <vector>;
module shadow_utils; module shadow_utils;
import std.core;
inline std::vector<std::string> explode(const std::string& s, const char& c) inline std::vector<std::string> explode(const std::string& s, const char& c)
{ {
std::string buff; std::string buff;