Skip to content

Vanish0314/VanishSerializer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Vanish Serializer

A single-file header-only library for serializing and deserializing data.

Features

  • Supports basic data types (int, float, double, bool, string, vector, etc.)
  • Supports custom data types by implementing the ISerializable interface
  • Supports little-endian and big-endian byte order
  • Supports binary and text serialization formats

Usage

Add DataStream.hpp to your project.

Example

Simple Data

#include <iostream>
#include <vector>
#include <string>
#include "DataStream.hpp"

using namespace Vanish::Serialize;

int main()
{
    // Create a DataStream object
    DataStream ds;

    // Write some data to the stream
    int x = 5;
    string s = "Hello, world!";
    vector<int> v = {1, 2, 3, 4, 5};

    ds<<x<<s<<v;
    // Read the data from the stream
    int y;
    string t;
    vector<int> w;

    ds>>y>>t>>w;

    // Print the data
    std::cout<<"x: "<<x<<std::endl;
    std::cout<<"s: "<<s<<std::endl;
    std::cout<<"v: "<<v<<std::endl;
    std::cout<<"y: "<<y<<std::endl;
    std::cout<<"t: "<<t<<std::endl;
    std::cout<<"w: "<<w<<std::endl;

    return 0;
}

Custom Data

class MyData : ISerializable
{
public:
    int a;
    string b;
    vector<int> c;

    SERIALIZE_FUNC(a,b,c)
}

About

A single-file header-only library for serializing and deserializing data.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages