Olympe Engine
2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Source
BlueprintEditor
serialize_example.cpp
Go to the documentation of this file.
1
#include <fstream>
2
#include "
Graph.h
"
3
#include "../../Source/third_party/nlohmann/json.hpp"
4
5
void
SaveGraphToFile
(
const
Graph
& g,
const
std::string& path)
6
{
7
auto
j
= g.
ToJson
();
8
std::ofstream
ofs
(path);
9
if
(
ofs
)
ofs
<<
j
.dump(4);
10
}
11
12
Graph
LoadGraphFromFile
(
const
std::string& path)
13
{
14
std::ifstream
ifs
(path);
15
if
(!
ifs
)
return
Graph
();
16
std::string
contents
((std::istreambuf_iterator<char>(
ifs
)), std::istreambuf_iterator<char>());
17
nlohmann::json
j
= nlohmann::json::parse(
contents
);
18
return
Graph::FromJson
(
j
);
19
}
GetComponentTypeID_Static
ComponentTypeID GetComponentTypeID_Static()
Definition
ECS_Entity.h:56
Graph.h
nlohmann::json
nlohmann::json json
Definition
ParameterSchema.h:23
LoadGraphFromFile
Graph LoadGraphFromFile(const std::string &path)
Definition
serialize_example.cpp:12
SaveGraphToFile
void SaveGraphToFile(const Graph &g, const std::string &path)
Definition
serialize_example.cpp:5
Graph
Definition
Graph.h:15
Graph::FromJson
static Graph FromJson(const nlohmann::json &j)
Definition
Graph.cpp:23
Graph::ToJson
nlohmann::json ToJson() const
Definition
Graph.cpp:6
Generated on Tue Feb 17 2026 13:49:10 for Olympe Engine by
1.9.8