Moved majority over to flint2 and updated sol2

This commit is contained in:
2020-05-06 22:32:30 +02:00
parent 748b9c76ef
commit 3b49c00df0
9 changed files with 188 additions and 44 deletions

View File

@@ -1,5 +1,3 @@
#include "/home/tim/Projects/cpp/iohelper/iohelper/include/iohelper/read.h"
#include "/home/tim/Projects/cpp/iohelper/iohelper/include/iohelper/write.h"
#include "components.h"
#include "ecs-lua.h"
#include "ecs-serial.h"
@@ -60,29 +58,29 @@ int main(int argc, const char** argv) {
for (auto [a, b] : wrapper->table) {
size++;
}
iohelper::write_length(os, size);
io::write<size_t>(os, size);
for (auto [a, b] : wrapper->table) {
iohelper::write<std::string>(os, a.as<std::string>());
io::write<std::string>(os, a.as<std::string>());
sol::type type = b.get_type();
iohelper::write<uint8_t>(os, (uint8_t)type);
io::write<uint8_t>(os, (uint8_t)type);
switch (type) {
case sol::type::none:
case sol::type::nil:
break;
case sol::type::string:
iohelper::write<std::string>(os, b.as<std::string>());
io::write<std::string>(os, b.as<std::string>());
break;
case sol::type::number:
// @todo These should be doubles instead of floats
iohelper::write<float>(os, b.as<float>());
io::write<float>(os, b.as<float>());
break;
case sol::type::boolean:
iohelper::write<bool>(os, b.as<bool>());
io::write<bool>(os, b.as<bool>());
break;
case sol::type::table:
@@ -101,14 +99,14 @@ int main(int argc, const char** argv) {
// @todo Only do this if table is not created yet
wrapper->table = lua.create_table();
size_t size = iohelper::read_length(is);
size_t size = io::read<size_t>(is);
std::cout << "Size: " << size << '\n';
for (size_t i = 0; i < size; ++i) {
std::string name = iohelper::read<std::string>(is);
std::string name = io::read<std::string>(is);
std::cout << "Name: " << name << '\n';
sol::type type = (sol::type)iohelper::read<uint8_t>(is);
sol::type type = (sol::type)io::read<uint8_t>(is);
switch (type) {
case sol::type::none:
break;
@@ -117,16 +115,16 @@ int main(int argc, const char** argv) {
break;
case sol::type::string:
wrapper->table[name] = iohelper::read<std::string>(is);
wrapper->table[name] = io::read<std::string>(is);
break;
case sol::type::number:
wrapper->table[name] = iohelper::read<float>(is);
wrapper->table[name] = io::read<float>(is);
break;
case sol::type::boolean:
{
wrapper->table[name] = iohelper::read<bool>(is);
wrapper->table[name] = io::read<bool>(is);
break;
}
@@ -199,7 +197,7 @@ int main(int argc, const char** argv) {
std::ofstream file("entities", std::ios::out | std::ios::trunc);
ecs::serial::serialize_ids(file);
iohelper::write_length(file, manager.view<>().size());
io::write<size_t>(file, manager.view<>().size());
for (auto [uuid, entity] : manager.view<>()) {
ecs::serial::serialize(file, entity);
}
@@ -221,7 +219,7 @@ int main(int argc, const char** argv) {
ecs::serial::deserialize_ids(file);
size_t entity_count = iohelper::read_length(file);
size_t entity_count = io::read<size_t>(file);
size_t pos = file.tellg();
for (size_t i = 0; i < entity_count; ++i) {
ecs::serial::deserialize(file, manager);