SHADE_Y3/SHADE_Engine/src/Serialization/SHSerialization.h

43 lines
1.3 KiB
C
Raw Normal View History

2022-09-26 21:08:59 +08:00
#pragma once
#include "SH_API.h"
#include <string>
#include <filesystem>
#include <ECS_Base/Components/SHComponent.h>
2022-09-27 21:06:25 +08:00
2022-09-26 21:08:59 +08:00
namespace YAML
{
class Emitter;
class Node;
}
namespace SHADE
{
class SHSceneNode;
2022-09-27 21:06:25 +08:00
constexpr const char* ComponentsNode = "Components";
constexpr const char* EntityNameNode = "Name";
constexpr const char* EIDNode = "EID";
constexpr const char* IsActiveNode = "IsActive";
constexpr const char* NumberOfChildrenNode = "NumberOfChildren";
2022-09-26 23:51:20 +08:00
struct SH_API SHSerialization
2022-09-26 21:08:59 +08:00
{
2022-09-27 21:06:25 +08:00
//TODO: change paths to resource ID
2022-09-26 21:08:59 +08:00
static void SerializeSceneToFile(std::filesystem::path const& path);
static std::string SerializeSceneToString();
static void SerializeSceneToEmitter(YAML::Emitter& out);
2022-10-01 23:43:00 +08:00
static void DeserializeSceneFromFile(std::filesystem::path const& path);
2022-09-27 21:06:25 +08:00
2022-10-19 01:03:32 +08:00
static void EmitEntity(SHSceneNode* entityNode, YAML::Emitter& out);
static std::string SerializeEntitiesToString(std::vector<EntityID> const& entities);
2022-09-26 21:08:59 +08:00
static void SerializeEntityToFile(std::filesystem::path const& path);
static YAML::Node SerializeEntityToNode(SHSceneNode* sceneNode);
2022-09-27 21:06:25 +08:00
static std::vector<ComponentTypeID> GetComponentIDList(YAML::Node const& componentsNode);
private:
2022-10-01 23:43:00 +08:00
static void InitializeEntity(YAML::Node const& entityNode, EntityID const& eid);
2022-09-26 23:51:20 +08:00
};
2022-09-26 21:08:59 +08:00
}