diff --git a/include/ki/serialization/SerializerBinary.h b/include/ki/serialization/BinarySerializer.h similarity index 93% rename from include/ki/serialization/SerializerBinary.h rename to include/ki/serialization/BinarySerializer.h index d6ca401..bbecc24 100644 --- a/include/ki/serialization/SerializerBinary.h +++ b/include/ki/serialization/BinarySerializer.h @@ -13,7 +13,7 @@ namespace serialization /** * TODO: Documentation */ - class SerializerBinary + class BinarySerializer { public: /** @@ -41,9 +41,9 @@ namespace serialization * @param is_file Determines whether or not to write type sizes, and property headers. * @param flags Determines how serialized data is formatted. */ - explicit SerializerBinary(const pclass::TypeSystem &type_system, + explicit BinarySerializer(const pclass::TypeSystem &type_system, bool is_file, flags flags); - virtual ~SerializerBinary() {} + virtual ~BinarySerializer() {} /** * @param object @@ -110,4 +110,4 @@ namespace serialization } // Make sure the flags enum can be used like a bitflag -MAKE_FLAGS_ENUM(ki::serialization::SerializerBinary::flags); +MAKE_FLAGS_ENUM(ki::serialization::BinarySerializer::flags); diff --git a/include/ki/serialization/SerializerFile.h b/include/ki/serialization/SerializerFile.h deleted file mode 100644 index e69de29..0000000 diff --git a/include/ki/serialization/SerializerXML.h b/include/ki/serialization/SerializerXML.h deleted file mode 100644 index e69de29..0000000 diff --git a/src/serialization/SerializerBinary.cpp b/src/serialization/BinarySerializer.cpp similarity index 96% rename from src/serialization/SerializerBinary.cpp rename to src/serialization/BinarySerializer.cpp index 5a0be20..c5f1053 100644 --- a/src/serialization/SerializerBinary.cpp +++ b/src/serialization/BinarySerializer.cpp @@ -1,4 +1,4 @@ -#include "ki/serialization/SerializerBinary.h" +#include "ki/serialization/BinarySerializer.h" #include #include #include "ki/util/unique.h" @@ -7,7 +7,7 @@ namespace ki { namespace serialization { - SerializerBinary::SerializerBinary(const pclass::TypeSystem &type_system, + BinarySerializer::BinarySerializer(const pclass::TypeSystem &type_system, const bool is_file, const flags flags) { m_type_system = &type_system; @@ -16,7 +16,7 @@ namespace serialization m_root_object = nullptr; } - void SerializerBinary::save(const pclass::PropertyClass *object, BitStream &stream) + void BinarySerializer::save(const pclass::PropertyClass *object, BitStream &stream) { // Write the serializer flags if (FLAG_IS_SET(m_flags, flags::WRITE_SERIALIZER_FLAGS)) @@ -114,7 +114,7 @@ namespace serialization } } - void SerializerBinary::presave_object(const pclass::PropertyClass *object, BitStream &stream) const + void BinarySerializer::presave_object(const pclass::PropertyClass *object, BitStream &stream) const { // If we have an object, write the type hash, otherwise, write NULL (0). if (object) @@ -123,7 +123,7 @@ namespace serialization stream.write(NULL); } - void SerializerBinary::save_object(const pclass::PropertyClass *object, BitStream &stream) const + void BinarySerializer::save_object(const pclass::PropertyClass *object, BitStream &stream) const { // Write any object headers presave_object(object, stream); @@ -165,7 +165,7 @@ namespace serialization stream.seek(BitStream::stream_pos(stream.tell().as_bytes(), 0)); } - void SerializerBinary::save_property(const pclass::IProperty &prop, BitStream &stream) const + void BinarySerializer::save_property(const pclass::IProperty &prop, BitStream &stream) const { // Remember where we started writing the property data const auto start_pos = stream.tell(); @@ -236,7 +236,7 @@ namespace serialization } } - void SerializerBinary::load( + void BinarySerializer::load( std::unique_ptr &dest, BitStream &stream, const std::size_t size) { @@ -299,7 +299,7 @@ namespace serialization load_object(dest, segment_stream); } - void SerializerBinary::preload_object( + void BinarySerializer::preload_object( std::unique_ptr &dest, BitStream &stream) const { const auto type_hash = stream.read(); @@ -314,7 +314,7 @@ namespace serialization dest = nullptr; } - void SerializerBinary::load_object( + void BinarySerializer::load_object( std::unique_ptr &dest, BitStream &stream) const { // Read the object header @@ -376,7 +376,7 @@ namespace serialization stream.seek(BitStream::stream_pos(stream.tell().as_bytes(), 0), false); } - void SerializerBinary::load_property(pclass::IProperty &prop, BitStream &stream) const + void BinarySerializer::load_property(pclass::IProperty &prop, BitStream &stream) const { auto &property_type = prop.get_type(); if (prop.is_dynamic()) diff --git a/src/serialization/CMakeLists.txt b/src/serialization/CMakeLists.txt index e19681a..fd194c8 100644 --- a/src/serialization/CMakeLists.txt +++ b/src/serialization/CMakeLists.txt @@ -1,4 +1,4 @@ target_sources(${PROJECT_NAME} PRIVATE - ${PROJECT_SOURCE_DIR}/src/serialization/SerializerBinary.cpp + ${PROJECT_SOURCE_DIR}/src/serialization/BinarySerializer.cpp ) \ No newline at end of file diff --git a/test/src/unit-serialization.cpp b/test/src/unit-serialization.cpp index 3e41649..dce8f2b 100644 --- a/test/src/unit-serialization.cpp +++ b/test/src/unit-serialization.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include "ki/util/unique.h" using namespace ki; @@ -394,11 +394,11 @@ void validate_test_object(TestObject &object) } /** - * Conduct save/load tests with a SerializerBinary instance. + * Conduct save/load tests with a BinarySerializer instance. */ void test_serializer( std::unique_ptr &test_object, - serialization::SerializerBinary &serializer, + serialization::BinarySerializer &serializer, const std::string &file_suffix) { BitBuffer buffer; @@ -473,38 +473,38 @@ TEST_CASE("Serialization tests", "[serialization]") std::unique_ptr test_object = nullptr; define_types(); - SECTION("SerializerBinary") + SECTION("BinarySerializer") { SECTION("Regular format without compression") { - serialization::SerializerBinary serializer( + serialization::BinarySerializer serializer( *g_type_system.get(), false, - serialization::SerializerBinary::flags::NONE + serialization::BinarySerializer::flags::NONE ); test_serializer(test_object, serializer, "_regular"); } SECTION("File format without compression") { - serialization::SerializerBinary serializer( + serialization::BinarySerializer serializer( *g_type_system.get(), true, - serialization::SerializerBinary::flags::WRITE_SERIALIZER_FLAGS + serialization::BinarySerializer::flags::WRITE_SERIALIZER_FLAGS ); test_serializer(test_object, serializer, "_file"); } SECTION("Regular format with compression") { - serialization::SerializerBinary serializer( + serialization::BinarySerializer serializer( *g_type_system.get(), false, - serialization::SerializerBinary::flags::COMPRESSED + serialization::BinarySerializer::flags::COMPRESSED ); test_serializer(test_object, serializer, "_regular_compressed"); } SECTION("File format with compression") { - serialization::SerializerBinary serializer( + serialization::BinarySerializer serializer( *g_type_system.get(), true, - serialization::SerializerBinary::flags::WRITE_SERIALIZER_FLAGS | - serialization::SerializerBinary::flags::COMPRESSED + serialization::BinarySerializer::flags::WRITE_SERIALIZER_FLAGS | + serialization::BinarySerializer::flags::COMPRESSED ); test_serializer(test_object, serializer, "_file_compressed"); }