A C++11 library for serialization

Overview

cereal - A C++11 library for serialization

cereal is a header-only C++11 serialization library. cereal takes arbitrary data types and reversibly turns them into different representations, such as compact binary encodings, XML, or JSON. cereal was designed to be fast, light-weight, and easy to extend - it has no external dependencies and can be easily bundled with other code or used standalone.

cereal has great documentation

Looking for more information on how cereal works and its documentation? Visit cereal's web page to get the latest information.

cereal is easy to use

Installation and use of of cereal is fully documented on the main web page, but this is a quick and dirty version:

  • Download cereal and place the headers somewhere your code can see them
  • Write serialization functions for your custom types or use the built in support for the standard library cereal provides
  • Use the serialization archives to load and save data
#include <cereal/types/unordered_map.hpp>
#include <cereal/types/memory.hpp>
#include <cereal/archives/binary.hpp>
#include <fstream>
    
struct MyRecord
{
  uint8_t x, y;
  float z;
  
  template <class Archive>
  void serialize( Archive & ar )
  {
    ar( x, y, z );
  }
};
    
struct SomeData
{
  int32_t id;
  std::shared_ptr<std::unordered_map<uint32_t, MyRecord>> data;
  
  template <class Archive>
  void save( Archive & ar ) const
  {
    ar( data );
  }
      
  template <class Archive>
  void load( Archive & ar )
  {
    static int32_t idGen = 0;
    id = idGen++;
    ar( data );
  }
};

int main()
{
  std::ofstream os("out.cereal", std::ios::binary);
  cereal::BinaryOutputArchive archive( os );

  SomeData myData;
  archive( myData );

  return 0;
}

cereal has a mailing list

Either get in touch over email or on the web.

cereal has a permissive license

cereal is licensed under the BSD license.

cereal build status

  • master : Build Status Build status

Were you looking for the Haskell cereal? Go here.

Comments
  • Exposing references to objects created outside the cereal load process.

    Exposing references to objects created outside the cereal load process.

    Concept:

    During load you may have dependencies on something which is already in memory loaded from another aspect of your application. That may be something like a renderer, or a mouse, or a central texture atlas which has its own load/save process unrelated to your existing object hierarchy. You may even need to hook up some loaded/saved items to objects outside of the save/load heirarchy (as in the case with a central texture atlas, if you have textures from a loaded scene coming in, maybe you want to register them with that atlas as they get created.)

    Right now you can construct objects through cereal and any owned resources will be correctly loaded during the save/load(serialize) process. The issue is that handles to in-memory resources need to be reconstituted later.

    For simple cases of flat single type objects this can be trivial to hook up after load.

    RenderObject myRenderer;
    
    JSONInputArchive archive;
    std::shared_ptr<Rectangle> rect;
    archive(cereal::make_nvp("rect", rect));
    rect->setRenderer(myRenderer); //acceptable!  Unless the rectangle needs information about the viewport on load.  Maybe we have to re-design the class a bit, but probably workable.
    

    This becomes more difficult, however when layers are added, and polymorphic types step in. What if I have a clickable element deep inside a scene graph and it needs reference to the mouse wrangler?

    RenderThing myRenderer;
    MouseWrangler myMouse;
    
    JSONInputArchive archive;
    std::shared_ptr<Node> root;
    archive(cereal::make_nvp("root", root));
    root->setRenderer(myRenderer); //Same as above example!
    //root->setMouse(myMouse); //WHOOPSE!  What if setMouse only exists in clickable nodes?  Now the user of cereal has to make a choice as to how to fix the loaded object post-load, or make myMouse globally accessible!
    

    Ideally we would be able to supply these additional requirements which the enclosing scope (enclosing of the archive process) would already have access to. Then propogate that through the load process so objects could grab that information during their creation/loading instead of after.

    RenderThing myRenderer;
    MouseWrangler myMouse;
    Point defaultRotateOrigin; //just adding this for a "value" example of something we want copied.
    
    JSONInputArchive archive;
    
    archive.store( cereal::make_nvp("mouse", &myMouse), cereal::make_nvp("renderer", &myRenderer), cereal::make_nvp("defaultRotateOrigin", defaultRotateOrigin));
    
    std::shared_ptr<Node> root;
    archive(cereal::make_nvp("root", root));
    //Oh, and hey, all the items are now responsible for their own loading.  If they try to access a value that doesn't exist in the archive we can throw or something as usual.
    

    the following is some pseudo code:

    class Clickable : public Node {
    Clickable(const std::string &name, RenderThing* renderer, MouseWrangler &mouse, Point defaultRotateOrigin);
    ...
    
    template <class Archive>
    static void load_and_allocate( Archive & ar, cereal::allocate<Clickable > & allocate )
        {
          std::string name;
          Point position;
    
          ar( cereal::make_nvp("name", name), cereal::make_nvp("position", position) );
    
          RenderThing* renderer;
          MouseWrangler* mouse;
          Point defaultRotateOrigin;
          ar.extract(cereal::make_nvp("renderer", renderer), cereal::make_nvp("mouse", mouse), cereal::make_nvp("defaultRotateOrigin", defaultRotateOrigin));
          assert(mouse != null);
    
          allocate( name, renderer, mouse, defaultRotateOrigin );
          allocate.object().position = position;
    }
    ...
    }
    
    enhancement discussion 
    opened by Devacor 47
  • PolymorphicVirtualCaster StaticObject instantiation takes a very long time at app startup

    PolymorphicVirtualCaster StaticObject instantiation takes a very long time at app startup

    I recently updated to a newer version of cereal and it seems like some things have changed.

    On startup Cereal creates these "StaticObject" instances now for every polymorphic registration. My app now takes around 60 seconds to startup, compared to 1 second previously. I'm on iOS with an iPad Pro.

    Why does this happen now? What's the benefit of these StaticObjects? Can I turn this off somehow?

    enhancement optimization 
    opened by ForestRingGames 40
  • Add serialization support for C++17 std::optional and std::variant

    Add serialization support for C++17 std::optional and std::variant

    The test and code has been written in similar style to that of the existing support for boost_variant, I hope this is fine. For the tests to run one shall pass -DCMAKE_CXX_STANDARD=17 to cmake.

    enhancement 
    opened by arximboldi 36
  • Primitive types

    Primitive types

    I am missing the equivalent of BOOST_CLASS_IMPLEMENTATION(MyClass, primitive_type)

    Example: I have classes that already know how to convert to/from a string. so I use

    template<class Archive>                                 
    void save( Archive& archive ) const                         
    {                                                                           
        archive( ToString() );              
    }          
    

    resulting in the JSON

    "testobject": {
        "value0": "testobjectAsString"
    }
    

    but WHAT I WANT is just a single line

    "testobject": "testobjectAsString"
    

    Remark: the same thing happens for ENUMs in your implementation. They are always saved as a 2-level object, which seems unnecessary.


    enhancement 
    opened by DrAWolf 29
  • Nested circular references using load_and_allocate

    Nested circular references using load_and_allocate

    I'm opening this as a separate issue as it was introduced by the most recent couple check-ins on the develop branch. You should be using Visual Studio 2013 to reproduce this (I am currently on the November Compiler Prerelease as well, but I suspect it's a problem with the standard install too.)

    #include <iostream>
    #include <sstream>
    #include <string>
    #include <map>
    
    #include "cereal/cereal.hpp"
    #include "cereal/types/map.hpp"
    #include "cereal/types/vector.hpp"
    #include "cereal/types/memory.hpp"
    #include "cereal/types/string.hpp"
    #include "cereal/types/base_class.hpp"
    
    #include "cereal/archives/json.hpp"
    #include <cereal/types/polymorphic.hpp>
    
    class BaseClass : public std::enable_shared_from_this<BaseClass> {
    public:
        virtual ~BaseClass(){}
    
        template <class Archive>
        void serialize(Archive & archive){
            archive(CEREAL_NVP(name), CEREAL_NVP(baseMember));
        }
    protected:
        BaseClass(const std::string &a_name):
            name(a_name){
        }
    
        std::string name;
        int baseMember; //let this have random junk so we can see if it saves right.
    };
    
    class DerivedClass : public BaseClass {
        friend cereal::access;
    public:
        static std::shared_ptr<DerivedClass> make(const std::string &a_name, int a_derivedMember){
            return std::shared_ptr<DerivedClass>(new DerivedClass(a_name, a_derivedMember));
        }
    
        template <class Archive>
        void serialize(Archive & archive){
            archive(CEREAL_NVP(derivedMember), cereal::make_nvp("base", cereal::base_class<BaseClass>(this)));
        }
    private:
        DerivedClass(const std::string &a_name, int a_derivedMember):
            BaseClass(a_name),
            derivedMember(a_derivedMember){
        }
    
        template <class Archive>
        static DerivedClass * load_and_allocate(Archive &archive){
            int derivedMember;
            archive(CEREAL_NVP(derivedMember));
            DerivedClass* object = new DerivedClass("", derivedMember);
            archive(cereal::make_nvp("base", cereal::base_class<BaseClass>(object)));
            return object;
        }
    
        int derivedMember;
    };
    
    CEREAL_REGISTER_TYPE(DerivedClass);
    
    void saveTest(){
        std::stringstream stream;
        {
            cereal::JSONOutputArchive archive(stream);
            auto testSave = DerivedClass::make("TestName", 4);
            archive(cereal::make_nvp("test", testSave));
        }
        std::cout << stream.str() << std::endl;
        std::shared_ptr<DerivedClass> loaded;
        {
            cereal::JSONInputArchive archive(stream);
            archive(cereal::make_nvp("test", loaded));
        }
        std::stringstream stream2;
        {
            cereal::JSONOutputArchive archive(stream2);
            archive(cereal::make_nvp("test", loaded));
        }
        std::cout << stream2.str() << std::endl;
        std::cout << "TA-DA!" << std::endl;
    }
    
    int main(){
        saveTest();
    }
    

    The error I get is related to the line: if( ar.isSharedPointerValid ) in memory.hpp:

    The following is what I get from my LIVE CODE, not from the above test. I'll go ahead and get the error for the above code this evening.

    1>  textures.cpp
    1>C:\git\external\cereal\include\cereal/types/memory.hpp(171): error C3867: 'cereal::InputArchive<cereal::JSONInputArchive,0>::isSharedPointerValid': function call missing argument list; use '&cereal::InputArchive<cereal::JSONInputArchive,0>::isSharedPointerValid' to create a pointer to member
    1>          C:\git\external\cereal\include\cereal/cereal.hpp(767) : see reference to function template instantiation 'void cereal::load<AA,MV::FileTextureDefinition>(Archive &,cereal::memory_detail::PtrWrapper<std::shared_ptr<MV::FileTextureDefinition> &> &)' being compiled
    1>          with
    1>          [
    1>              AA=cereal::JSONInputArchive
    1>  ,            Archive=cereal::JSONInputArchive
    1>          ]
    1>          C:\git\external\cereal\include\cereal/cereal.hpp(692) : see reference to function template instantiation 'cereal::JSONInputArchive &cereal::InputArchive<cereal::JSONInputArchive,0>::processImpl<T>(T &)' being compiled
    1>          with
    1>          [
    1>              T=cereal::memory_detail::PtrWrapper<std::shared_ptr<MV::FileTextureDefinition> &>
    1>          ]
    1>          C:\git\external\cereal\include\cereal/cereal.hpp(692) : see reference to function template instantiation 'cereal::JSONInputArchive &cereal::InputArchive<cereal::JSONInputArchive,0>::processImpl<T>(T &)' being compiled
    1>          with
    1>          [
    1>              T=cereal::memory_detail::PtrWrapper<std::shared_ptr<MV::FileTextureDefinition> &>
    1>          ]
    1>          C:\git\external\cereal\include\cereal/cereal.hpp(558) : see reference to function template instantiation 'void cereal::InputArchive<cereal::JSONInputArchive,0>::process<_Ty>(T &&)' being compiled
    1>          with
    1>          [
    1>              _Ty=cereal::memory_detail::PtrWrapper<std::shared_ptr<MV::FileTextureDefinition> &>
    1>  ,            T=cereal::memory_detail::PtrWrapper<std::shared_ptr<MV::FileTextureDefinition> &>
    1>          ]
    1>          C:\git\external\cereal\include\cereal/cereal.hpp(558) : see reference to function template instantiation 'void cereal::InputArchive<cereal::JSONInputArchive,0>::process<_Ty>(T &&)' being compiled
    1>          with
    1>          [
    1>              _Ty=cereal::memory_detail::PtrWrapper<std::shared_ptr<MV::FileTextureDefinition> &>
    1>  ,            T=cereal::memory_detail::PtrWrapper<std::shared_ptr<MV::FileTextureDefinition> &>
    1>          ]
    1>          C:\git\external\cereal\include\cereal/details/polymorphic_impl.hpp(160) : see reference to function template instantiation 'ArchiveType &cereal::InputArchive<ArchiveType,0>::operator ()<cereal::memory_detail::PtrWrapper<std::shared_ptr<MV::FileTextureDefinition> &>>(cereal::memory_detail::PtrWrapper<std::shared_ptr<MV::FileTextureDefinition> &> &&)' being compiled
    1>          with
    1>          [
    1>              ArchiveType=cereal::JSONInputArchive
    1>          ]
    1>          C:\git\external\cereal\include\cereal/details/polymorphic_impl.hpp(160) : see reference to function template instantiation 'ArchiveType &cereal::InputArchive<ArchiveType,0>::operator ()<cereal::memory_detail::PtrWrapper<std::shared_ptr<MV::FileTextureDefinition> &>>(cereal::memory_detail::PtrWrapper<std::shared_ptr<MV::FileTextureDefinition> &> &&)' being compiled
    1>          with
    1>          [
    1>              ArchiveType=cereal::JSONInputArchive
    1>          ]
    1>          C:\git\external\cereal\include\cereal/details/polymorphic_impl.hpp(150) : while compiling class template member function 'cereal::detail::InputBindingCreator<Archive,T>::InputBindingCreator(void)'
    1>          with
    1>          [
    1>              Archive=cereal::JSONInputArchive
    1>  ,            T=MV::FileTextureDefinition
    1>          ]
    1>          C:\git\external\cereal\include\cereal/details/static_object.hpp(56) : see reference to function template instantiation 'cereal::detail::InputBindingCreator<Archive,T>::InputBindingCreator(void)' being compiled
    1>          with
    1>          [
    1>              Archive=cereal::JSONInputArchive
    1>  ,            T=MV::FileTextureDefinition
    1>          ]
    1>          C:\git\external\cereal\include\cereal/details/polymorphic_impl.hpp(293) : see reference to class template instantiation 'cereal::detail::InputBindingCreator<Archive,T>' being compiled
    1>          with
    1>          [
    1>              Archive=cereal::JSONInputArchive
    1>  ,            T=MV::FileTextureDefinition
    1>          ]
    1>          C:\git\external\cereal\include\cereal/details/polymorphic_impl.hpp(290) : while compiling class template member function 'void cereal::detail::polymorphic_serialization_support<cereal::JSONInputArchive,T>::instantiate(void)'
    1>          with
    1>          [
    1>              T=MV::FileTextureDefinition
    1>          ]
    1>          C:\git\external\cereal\include\cereal/details/polymorphic_impl.hpp(307) : see reference to class template instantiation 'cereal::detail::polymorphic_serialization_support<cereal::JSONInputArchive,T>' being compiled
    1>          with
    1>          [
    1>              T=MV::FileTextureDefinition
    1>          ]
    1>          C:\git\external\cereal\include\cereal/details/polymorphic_impl.hpp(306) : while compiling class template member function 'void cereal::detail::bind_to_archives<MV::FileTextureDefinition>::bind(std::false_type) const'
    1>          C:\git\external\cereal\include\cereal/details/polymorphic_impl.hpp(321) : see reference to function template instantiation 'void cereal::detail::bind_to_archives<MV::FileTextureDefinition>::bind(std::false_type) const' being compiled
    1>          Source\Render\textures.cpp(13) : see reference to class template instantiation 'cereal::detail::bind_to_archives<MV::FileTextureDefinition>' being compiled
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    
    bug enhancement 
    opened by Devacor 21
  • Error With Nested Circular shared_ptr and weak_ptr References

    Error With Nested Circular shared_ptr and weak_ptr References

    I'm having issues with circular references. I'm not sure if this is another bug or if there's something I'm doing wrong. It seems like creating a nested pointer_wrapper to a node higher up the chain fails and simply returns 1. I'm getting an exception throwing on load because of this:

    throw Exception("Error while trying to deserialize a smart pointer. Could not find id " + std::to_string(id));
    

    Also, another oddity is that shared_ptr objects no matter if they are polymorphic or not seem to need to need CEREAL_REGISTER_TYPE which means I need to give them a virtual method as well. Trying to remove the CEREAL_REGISTER_TYPE and virtual destructor for ChildWithPointerToParent fails at compile time.

    #include <iostream>
    #include <sstream>
    #include <string>
    #include <map>
    
    #include "cereal/cereal.hpp"
    #include "cereal/types/map.hpp"
    #include "cereal/types/vector.hpp"
    #include "cereal/types/memory.hpp"
    #include "cereal/types/string.hpp"
    #include "cereal/types/base_class.hpp"
    
    #include "cereal/archives/json.hpp"
    #include <cereal/types/polymorphic.hpp>
    
    class ChildWithPointerToParent;
    
    class BaseClass : public std::enable_shared_from_this<BaseClass> {
    public:
        virtual ~BaseClass(){}
    
        template <class Archive>
        void serialize(Archive & archive){
            archive(CEREAL_NVP(name), CEREAL_NVP(baseMember), CEREAL_NVP(child));
        }
    
        void addChild(std::shared_ptr<ChildWithPointerToParent> a_child){
            child = a_child;
        }
    protected:
        BaseClass(const std::string &a_name):
            name(a_name){
        }
    
        std::weak_ptr<ChildWithPointerToParent> child;
        std::string name;
        int baseMember; //let this have random junk so we can see if it saves right.
    };
    
    class DerivedClass : public BaseClass {
        friend cereal::access;
    public:
        static std::shared_ptr<DerivedClass> make(const std::string &a_name, int a_derivedMember){
            return std::shared_ptr<DerivedClass>(new DerivedClass(a_name, a_derivedMember));
        }
    
        template <class Archive>
        void serialize(Archive & archive){
            archive(CEREAL_NVP(derivedMember), cereal::make_nvp("base", cereal::base_class<BaseClass>(this)));
        }
    private:
        DerivedClass(const std::string &a_name, int a_derivedMember):
            BaseClass(a_name),
            derivedMember(a_derivedMember){
        }
    
        template <class Archive>
        static DerivedClass * load_and_allocate(Archive &archive){
            return new DerivedClass("", 0); //values loaded in serialize (using work-around in memory.hpp)
        }
    
        int derivedMember;
    };
    
    class ChildWithPointerToParent {
        friend cereal::access;
    public:
        virtual ~ChildWithPointerToParent(){} //Why do I have to do this?  I get an error if I don't.
        static std::shared_ptr<ChildWithPointerToParent> make(std::shared_ptr<BaseClass> parent){
            return std::shared_ptr<ChildWithPointerToParent>(new ChildWithPointerToParent(parent));
        }
    
        template <class Archive>
        void serialize(Archive & archive){
            archive(CEREAL_NVP(parent));
        }
    
    private:
        ChildWithPointerToParent(std::shared_ptr<BaseClass> a_parent):
            parent(a_parent){
        }
    
        template <class Archive>
        static ChildWithPointerToParent * load_and_allocate(Archive &archive){
            return new ChildWithPointerToParent(nullptr); //values loaded in serialize (using work-around in memory.hpp)
        }
        std::shared_ptr<BaseClass> parent;
    };
    
    CEREAL_REGISTER_TYPE(DerivedClass);
    CEREAL_REGISTER_TYPE(ChildWithPointerToParent); //Why do I have to do this?  I get an error if I don't.
    
    void saveTest(){
        std::stringstream stream;
        {
            cereal::JSONOutputArchive archive(stream);
            std::shared_ptr<BaseClass> testSave = DerivedClass::make("TestName", 4);
            std::shared_ptr<ChildWithPointerToParent> child = ChildWithPointerToParent::make(testSave);
            testSave->addChild(child);
            archive(cereal::make_nvp("test", testSave));
        }
        std::cout << stream.str() << std::endl;
        std::shared_ptr<BaseClass> loaded;
        {
            cereal::JSONInputArchive archive(stream);
            archive(cereal::make_nvp("test", loaded));
        }
        std::stringstream stream2;
        {
            cereal::JSONOutputArchive archive(stream2);
            archive(cereal::make_nvp("test", loaded));
        }
        std::cout << stream2.str() << std::endl;
        std::cout << "TA-DA!" << std::endl;
    }
    
    int main(){
        saveTest
    }
    

    EXAMPLE OF REAL WORLD USE:


    I have a class of type TextureDefinition. A TextureDefinition is always created via shared_ptr. TextureDefinitions are typically stored in a map keyed by their "name" so that multiple identical TextureDefinitions don't exist, but optionally a TextureDefinition might be owned by a specific rendering object like a text character which manages its own dynamic texture. It's also possible that I only care about the TextureDefinition when loading a scene and won't want to have it owned by a central node at all, but just let it be owned by its TextureHandles (more on this later). Basically I don't have one draconic TextureManager class that deals with their lifespan.

    I have another class of type TextureHandle. A TextureHandle is created by a TextureDefinition always of type shared_ptr. When the first TextureHandle is created the TextureDefinition associated with it loads into memory. When the all TextureHandles are destroyed the TextureDefinition unloads, but if something still owns the TextureDefinition it remains possible to reload it by creating new handles.

    TextureDefinition maintains a list of weak_ptr's to TextureHandles (because they do not manage a TextureHandle's lifespan, something like Shape::Rectangle would have a shared_ptr).

    TextureHandle maintains a shared_ptr because it would be an error to have the TextureDefinition explode while there are any active TextureHandles.

    In this way, we can plot the object composition like this:

    ----> is weak_ptr
    ====> is shared_ptr
    TextureDefinition1|---->TextureHandle1===>TextureDefinition1
                      |---->TextureHandle2===>TextureDefinition1
                      |---->TextureHandle3===>TextureDefinition1
    

    The objects owning these could be a different shape for each TextureHandle and a scene manager owning the TextureDefinition so it can spawn new handles. If we don't care about spawning new handles (let's say we've loaded the whole scene already) that scene manager owned handle is optional, but the objects owning TextureHandles must still keep the TextureDefinition alive.

    bug 
    opened by Devacor 19
  • shared_from_this and members containing shared_ptr can cause issues with the destructor after saving.

    shared_from_this and members containing shared_ptr can cause issues with the destructor after saving.

    Seems to have an issue with the fact that we save drawListVector in the serialize method. If I comment out ar(CEREAL_NVP(drawListVector)); it stops crashing.

    It was not doing this prior to pulling the latest save_from_this fix for saving.

    #include <strstream>
    
    #include "cereal/cereal.hpp"
    #include "cereal/types/map.hpp"
    #include "cereal/types/vector.hpp"
    #include "cereal/types/memory.hpp"
    #include "cereal/types/string.hpp"
    #include "cereal/types/base_class.hpp"
    
    #include "cereal/archives/json.hpp"
    #include "cereal/types/polymorphic.hpp"
    
    #include <memory>
    
    struct A : std::enable_shared_from_this<A>
    {
        typedef std::vector<std::shared_ptr<A>> DrawListVectorType;
        DrawListVectorType drawListVector;
    
        template <class Archive>
        void serialize(Archive & ar)
        {
            ar(CEREAL_NVP(drawListVector)); //If we don't actually save the drawListVector it's fine.  If we do, we'll get a crash in the destructor.
        }
        virtual ~A(){
        }
    };
    
    struct B : A
    {
        template <class Archive>
        void serialize(Archive & ar)
        { }
    };
    
    CEREAL_REGISTER_TYPE(B);
    
    void saveTest(){
        {
            cereal::JSONOutputArchive ar(std::cout);
            std::shared_ptr<A> a = std::make_shared<A>();
            std::shared_ptr<A> b = std::make_shared<B>();
            std::shared_ptr<A> c = std::make_shared<A>();
            a->drawListVector.push_back(b);
    
            b->drawListVector.push_back(c);
    
            ar(a);
    
            auto x = a->shared_from_this();
            b.reset();
            a->drawListVector.clear();
            std::cout << "grood";
        }
        std::cout << "grood";
    }
    
    int main(){
        saveTest();
    }
    
    bug 
    opened by Devacor 14
  • Added a 'getNodeName' API to JSON/XML InputArchives

    Added a 'getNodeName' API to JSON/XML InputArchives

    If you are doing some pretty custom serialization/deserialization it can really help being able to know the current node key/tag.

    I couldn't really figure out where to put this into the unit tests - any hints? Would you want tests for this?

    discussion 
    opened by mattyclarkson 14
  • using type name attribute in XMLOutputArchive leaves undesired characters in type

    using type name attribute in XMLOutputArchive leaves undesired characters in type

    The problem is in this segment of code (in xml.hpp, at or around line 261)

      template <class T> inline
      void insertType()
      {
        if( !itsOutputType )
          return;
    
        // generate a name for this new node
        const auto nameString = util::demangledName<T>();
    
        // allocate strings for all of the data in the XML object
        auto namePtr = itsXML.allocate_string( nameString.data(), nameString.size() );
    
        itsNodes.top().node->append_attribute( itsXML.allocate_attribute( "type", namePtr ) );
      }
    

    Since the nameString parameter is mapped to a char ptr of length 99 issues arise. If the string is shorter, say 47 characters long, then what trails will be binary trash. If you open the resulting XML in your favorite browser it should fail to load, if you open it in an editor the trash should be obvious. To fix this problem you should explicitly let allocate_attribute know the size of "type" and "namePTR". The fix can be seen below.

    I have not checked to see if something similar has occurred elsewhere in the code.

      template <class T> inline
      void insertType()
      {
        if( !itsOutputType )
          return;
    
        // generate a name for this new node
        const auto nameString = util::demangledName<T>();
    
        // allocate strings for all of the data in the XML object
        auto namePtr = itsXML.allocate_string( nameString.data(), nameString.size() );
    
        itsNodes.top().node->append_attribute( itsXML.allocate_attribute( "type", namePtr , 4 , nameString.size() ) );
      }
    
    bug 
    opened by snoodleboot 13
  • JSON: unsigned long are base64 encoded

    JSON: unsigned long are base64 encoded

    When serializing an unsigned long to JSON, cereal outputs some non-human readable data which seems to be in base64. Indeed, looking at the source code (https://github.com/USCiLab/cereal/blob/master/include/cereal/archives/json.hpp#L110), any type with a size >= sizeof(long long) is considered 'exotic' and thus base64-encoded. Furthermore, the XML output is perfectly fine (by that, I mean readable).

    I fail to see why longs are base64 encoded. Is this a desired thing? Also, it means that when compiling the code in 32bits or 64 bits, we have a different output. Finally, it makes unnecessarily difficult to read the JSON output in another language (Python in my case)

    bug discussion 
    opened by ahamez 13
  • Allow capitalized `Serialize` functions

    Allow capitalized `Serialize` functions

    Currently cereal searches for serialize, load and save. If they could be made #defines, the user of the library could specify the name of the functions that cereal should be looking for.

    #ifndef CEREAL_SERIALIZE_FUNCTION_NAME
    #define CEREAL_SERIALIZE_FUNCTION_NAME serialize
    #endif
    #ifndef CEREAL_LOAD_FUNCTION_NAME
    #define CEREAL_LOAD_FUNCTION_NAME load
    #endif
    #ifndef CEREAL_SAVE_FUNCTION_NAME
    #define CEREAL_SAVE_FUNCTION_NAME save
    #endif
    

    This is because some styling guides require functions that are Capitalized and having Serialize, Load, Save would conform.

    How do you guys feel about this? Is this something that would be acceptable to create a pull request for?

    enhancement 
    opened by mattyclarkson 13
  • Disable unnecessary stuff if not main project

    Disable unnecessary stuff if not main project

    I had some problems while including cereal in my project using FetchContent, so I made some small modifications to the CMakeLists.txt:

    • renamed some options using the CEREAL_ prefix to make clear to which project they belong to and avoid conflicts
    • changed the default value of some options so that, when not the main project, doc, sandbox and performance comparisons are disabled by default
    • added a more complete check for main project

    I think this edits would make it easier to depend on cereal using FetchContent, including it as submodule or similar techniques. See this other pull request for more info.

    opened by LucaCiucci 1
  • Can I read cereal output with Python?

    Can I read cereal output with Python?

    Is there a way to read the cereal output (binary/XML/JSON) with Python? I would like to process the data from cereal in Python. Is there any convenient way?

    opened by yuxiang660 1
  • cereal::JSONOutputArchive serialize 1M large string cost more than 100ms

    cereal::JSONOutputArchive serialize 1M large string cost more than 100ms

    I use cereal::JSONOutputArchive serialize 1M large string, it takes more than 100ms. Is it a normal behavior ? Is there a solution to reduce the serialization time ?

    ` std::string str1 = std::string(100 * 1024, 'a'); oStr = std::ostringstream(); // 创建新ss对象 StopWatch sw; { cereal::JSONOutputArchive archive(oStr); archive(cereal::make_nvp("Test", str1)); } std::cout << "cereal::JSONOutputArchive 100k string cost time:" << sw.elapsed().count() << std::endl;

    std::string str2 = std::string(1024 * 1024, 'a');
    oStr = std::ostringstream();  // 创建新ss对象
    sw.reset();
    {
        cereal::JSONOutputArchive archive(oStr);
        archive(cereal::make_nvp("Test", str2));
    }
    std::cout << "cereal::JSONOutputArchive 1M string cost time:" << sw.elapsed().count() << std::endl;
    
    std::string str3 = std::string(10 * 1024 * 1024, 'a');
    oStr = std::ostringstream();  // 创建新ss对象
    sw.reset();
    {
        cereal::JSONOutputArchive archive(oStr);
        archive(cereal::make_nvp("Test", str3));
    }
    std::cout << "cereal::JSONOutputArchive 10M string cost time:" << sw.elapsed().count() << std::endl;
    

    `

    output log: cereal::JSONOutputArchive 100k string cost time:0.01547 cereal::JSONOutputArchive 1M string cost time:0.147921 cereal::JSONOutputArchive 10M string cost time:1.36517

    opened by zhenjing 2
  • How to name the outermost name tag in output XML?

    How to name the outermost name tag in output XML?

    Is there a way to change the outermost name tag of an XML output file? I have an XML output of a class like this: <?xml version="1.0" encoding="utf-8"?> <cereal> <Item> <ItemID>Item 1</ItemID> </Item> </cereal>

    Here instead of 'cereal', I would like to have a custom name for it.

    opened by sk-surya 0
  • deserialize json with cereal

    deserialize json with cereal

    I am trying to deserialize json file, the problem is that ifstream is not supported from what I have seen in another issue and tried myself. so this:

    std::ifstream input("config.json");
    cereal::JSONInputArchive archive(input);
    

    won't work.

    I have tried to read each line of the file into stringstream , which also isn't working because from what I have seen cereal::JSONInputArchive expect the format of the json to have quotation mark with escape characters like this - \" and stringstream isn't doing that while reading reading the file line by line.

    I have searched the net and Cereal docs but couldn't find a way to deserialize json.

    opened by yuvalco 0
  • handle trivially-copyable types correctly

    handle trivially-copyable types correctly

    Cereal has two implementations for contiguous standard library containers:

    1. serialise element-wise (default)
    2. serialise en-bloc

    The second implementation is only chosen for arithmetic element types when, in fact, it should be chosen for all trivially-copyable types; this is exactly what the trivially-copyable trait was made for 🙂

    This PR changes the behaviour. It reduces the deserialisation time in one of our applications by more than 5x!

    Note that the on-disk representation is not guaranteed to stay the same, although in many cases it will.

    opened by h-2 3
Releases(v1.3.2)
  • v1.3.2(Feb 28, 2022)

    This is a minor bug fix and build enhancement release for cereal.

    The primary reason for this release is to correctly increment the version for cereal in include/cereal/version.hpp.

    Bug fixes and enhancements

    • Make doxygen docs reproducible by @mr-c in https://github.com/USCiLab/cereal/pull/740
    • Add CMake options for building doc and sandbox by @AzothAmmo in https://github.com/USCiLab/cereal/pull/751
    • Correct patch version for 1.3.2 by @AzothAmmo in https://github.com/USCiLab/cereal/pull/750

    New Contributors

    • @mr-c made their first contribution in https://github.com/USCiLab/cereal/pull/740

    Full Changelog: https://github.com/USCiLab/cereal/compare/v1.3.1...v1.3.2

    Source code(tar.gz)
    Source code(zip)
  • v1.3.1(Jan 17, 2022)

    This is a bug fix and minor enhancement release for cereal.

    This release contains numerous quality of life improvements and bug fixes that improve support on newer compilers. Continuous integration testing has also been overhauled and cereal now uses github actions in place of travis for linux and mac testing.

    Many of these changes come from community contributions.

    Highlighted fixes and enhancements include:

    • Github actions in place of Travis CI (thanks to @isuruf, #727)
    • Doctest updates (and upstream patches!) to support all targeted compilers (#714, #736)
    • Cmake modernization (thanks to @ClausKlein, #659)

    Bug fixes and minor enhancements:

    • Fix typo in docs by @tankorsmash in https://github.com/USCiLab/cereal/pull/597
    • Add MSVC 2019 to build, default ctor for static object by @AzothAmmo in https://github.com/USCiLab/cereal/pull/593
    • Fix json.hpp compilation issue when int32_t is a long by @bblackham in https://github.com/USCiLab/cereal/pull/621
    • [cpp20] explicitly capture 'this' as copy by @lukaszgemborowski in https://github.com/USCiLab/cereal/pull/640
    • Fix rapidjson for Clang 10 by @groscoe2 in https://github.com/USCiLab/cereal/pull/645
    • Fixes to prevent clang-diagnostic errors by @johngladp in https://github.com/USCiLab/cereal/pull/643
    • cleanup cmake files to be a little more moderen by @ClausKlein in https://github.com/USCiLab/cereal/pull/659
    • CVE-2020-11105: Store a copy of each serialized shared_ptr within the archive to prevent the shared_ptr to be freed to early. by @serpedon in https://github.com/USCiLab/cereal/pull/667
    • add license files for components of cereal by @miartad in https://github.com/USCiLab/cereal/pull/676
    • Catch short documents in JSON input by @johnkeeping in https://github.com/USCiLab/cereal/pull/677
    • C++17: use inline globals for StaticObjects by @InBetweenNames in https://github.com/USCiLab/cereal/pull/657
    • Use std::variant::emplace when loading by @kepler-5 in https://github.com/USCiLab/cereal/pull/699
    • Use std::optional::emplace() when loading non-empty optional by @kepler-5 in https://github.com/USCiLab/cereal/pull/698
    • Fix itsNextName not clearing when not found + style change by @AzothAmmo in https://github.com/USCiLab/cereal/pull/715
    • Update doctest to 2.4.6 + local fixes slated for upstream by @AzothAmmo in https://github.com/USCiLab/cereal/pull/716
    • Fixed loading of std::vector by @Darred in https://github.com/USCiLab/cereal/pull/732
    • Update license to match BSD template by @AzothAmmo in https://github.com/USCiLab/cereal/pull/735
    • Update doctest to 2.4.7 by @AzothAmmo in https://github.com/USCiLab/cereal/pull/736
    • Use GNUInstallDirs instead of hard wiring install directories by @antonblanchard in https://github.com/USCiLab/cereal/pull/710

    This is not an exhaustive list of changes or individual contributions. See the closed issues or complete changelog for more information.

    New contributors

    • @tankorsmash made their first contribution in https://github.com/USCiLab/cereal/pull/597
    • @bblackham made their first contribution in https://github.com/USCiLab/cereal/pull/621
    • @lukaszgemborowski made their first contribution in https://github.com/USCiLab/cereal/pull/640
    • @groscoe2 made their first contribution in https://github.com/USCiLab/cereal/pull/645
    • @johngladp made their first contribution in https://github.com/USCiLab/cereal/pull/643
    • @ClausKlein made their first contribution in https://github.com/USCiLab/cereal/pull/659
    • @serpedon made their first contribution in https://github.com/USCiLab/cereal/pull/667
    • @miartad made their first contribution in https://github.com/USCiLab/cereal/pull/676
    • @johnkeeping made their first contribution in https://github.com/USCiLab/cereal/pull/677
    • @InBetweenNames made their first contribution in https://github.com/USCiLab/cereal/pull/657
    • @kepler-5 made their first contribution in https://github.com/USCiLab/cereal/pull/699
    • @Darred made their first contribution in https://github.com/USCiLab/cereal/pull/732
    • @antonblanchard made their first contribution in https://github.com/USCiLab/cereal/pull/710

    Want to contribute to cereal?

    Open source projects take a considerable amount of time to maintain! Contributions are always appreciated, especially when they can be easily integrated.

    Source code(tar.gz)
    Source code(zip)
  • v1.3.0(Oct 25, 2019)

    This is a feature and bug fix release for cereal.

    This release contains a few new features, numerous quality of life improvements, and bug fixes. Many of these come from community contributions.

    With this release, the develop branch is being removed in favor of a single default branch. This means that tagged releases should be used in favor of trusting the master branch as being stable. The development branch for documentation, gh-pages-develop, is also being removed. This change comes with two small side benefits: pull requests will always be against the correct branch, and it will be easy to see development activity at a glance.

    New features include:

    • Deferred serialization for smart pointers (#185)
    • Initial support for C++17 standard library variant and optional (thanks to @arximboldi, #448)
    • Support for std::atomic (thanks to @bluescarni, #277)

    Fixes and enhancements include:

    • Vastly improved continuous integration testing (#568, #569)
    • Fixed several issues related to compilation on newer compilers (#579, #587, #515)
    • Fixed warnings with -Wconversion and -Wdocumentation (thanks to @WSoptics, #423)
    • Performance improvements for polymorphic serialization (#354)

    Minor fixes and enhancements include:

    • Fixed a bug related to CEREAL_REGISTER_DYNAMIC_INIT with shared libraries (thanks to @M2tM, #523)
    • Avoid unnecessary undefined behavior with StaticObject (thanks to @erichkeane, #470)
    • New version.hpp file describes cereal version (#444)
    • Ability to disable size=dynamic attribute in the XML archive (thanks to @hoensr, #401)

    Other Notes

    • The static checking for minimal serialization has been relaxed as there were many legitimate cases it was interfering with (thanks to @h-2, #565)
    • The vs2013 directory has been removed in favor of generating solutions with CMake (#574)

    This is not an exhaustive list of changes or individual contributions. See the closed issues for more information.

    Want to contribute to cereal?

    Open source projects take a considerable amount of time to maintain! Contributions are always appreciated, especially when they can be easily integrated.

    Source code(tar.gz)
    Source code(zip)
  • v1.2.2(Feb 12, 2017)

    This is a minor feature and bug fix release for cereal.

    The majority of fixes and enhancements for this release come from the community. Thank you for your contributions!

    Fixes and enhancements include:

    • Polymorphic registrations should always occur as intended, especially on VS2015 (#356)
    • Unit testing overhauled to prepare for modules; dependency on boost test dropped in favor of doctest (#139)
    • Continuous integration testing for Windows using AppVeyor (thanks to @tusharpm, #373)

    Minor fixes and enhancements include:

    • Ongoing optimizations for polymorphism support (thanks in part to @dlardi, #335, also see #354 for continuing work)
    • cereal now uses local #include to make it easier to drop into a project (thanks to @kklouzal, #347)
    • Fixed a bug related to threading support (thanks to @auric, #331)
    • Fixed a bug related to loading bitsets (thanks to @drivehappy, #355)
    • Avoid conflict with the check macro on OSX (thanks to @erichkeane, #341, #342)
    • Removed remaining traces of hardcoded RapidJSON namespaces to avoid conflicting with system library (thanks to @Enhex, #351)
    • cereal::size_type can now be configured via macro (#379)
    • Improved traivs continuous integration testing (thanks to @tusharpm, #367)
    • cereal no longer uses c-style casts interanlly (thanks to @laudrup, #363)
    • Improved support for migrating from boost (thanks to @headupinclouds, #366)

    See the closed issues for more information.

    Known Issues

    Polymorphic registration for large numbers of classes is currently slower than it should be. See the ongoing progress towards this at #354.

    Want to contribute to cereal?

    Source code(tar.gz)
    Source code(zip)
  • v1.2.1(Aug 10, 2016)

    This is a minor feature and bug fix release for cereal.

    Notable changes include:

    • Support for g++ 6 (#300)
    • Enhancements to support optional thread safety (#315, #320, thanks to @ChrisBFX)

    Minor fixes and enhancements include:

    • Fixed compilation errors with g++ 4.7.3 (#311)
    • New documentation for the PIMPL idiom (#324) as well as threading (#322)

    See the closed issues for more information.

    Source code(tar.gz)
    Source code(zip)
  • v1.2.0(Jun 30, 2016)

    This is a minor feature and bug fix release for cereal.

    This release sat around (much) longer than expected - note that the develop branch can always be used to access the latest changes to cereal.

    Notable changes include:

    • RapidJSON updated to a recent version (#121)
    • load_and_construct now supports versioning (#216)
    • Bug fixes for polymorphism and multiple inheritance (#188, #281). See the documentation regarding the new requirement for paths between base and derived classes and read the breaking changes below for more information.

    Minor fixes and enhancements include:

    • Improved control over endianness for portable binary archive (#115)
    • Improved documentation (#201, #269, others)
    • Polymorphic support pulled in automatically with <memory> (#193)
    • RapidJSON and RapidXML placed in cereal namespace (#121)
    • Various CMAKE improvements (#222 thanks to @robiwano, #239 and #254 thanks to @tamaskenez)

    See the closed issues for more information.

    Breaking Changes:

    • As part of improving support for polymorphic serialization, we have introduced a requirement for explicit relations between polymorphic class hierarchies. Whenever you serialize a smart pointer to a polymorphic type, cereal must be able to find a path from the derived type to the base type. cereal is able to do this automatically if you serialize the base class using cereal::base_class or cereal::virtual_base_class. If you do not do this, you must explicitly tell cereal about the relationship using the new macro CEREAL_REGISTER_POLYMORPHIC_RELATION, found in <cereal/types/polymorphic.hpp>.
    • std::bitset has been optimized for binary archives to avoid conversion to a string representation (see #236, thanks to @lyager). As a result of this, any bitset long enough to previously use the string output will not be compatible with the new serialization.

    Known Issues

    There is currently an error in the compile-time type checking that cereal performs on non-member load_minimal functions that will cause a static_assertion to mistakenly prevent compilation from succeeding. This only affects users using non-member load_minimal functions where the type to support load_minimal requires an unknown template parameter. See #132 for more information and workarounds.

    Source code(tar.gz)
    Source code(zip)
  • v1.1.2(Jun 8, 2015)

    This is a minor release for cereal

    New Features

    • Added support for std::valarray (thanks to @ilerik, #184)

    Minor fixes and enhancements include:

    • Fixed an issue with partial matching for NVP lookup (#167)

    See the closed issues for more information.

    To see what else is upcoming in the next release, check out milestone 1.2.

    Source code(tar.gz)
    Source code(zip)
  • v1.1.1(Apr 6, 2015)

    This is a minor bug fix release for cereal

    We're moving to more rapid intermediate releases between feature versions of cereal to make it easier for users to take advantage of bug fixes and various improvements. Although these fixes were and will continue to be available in the develop branch, many users are more comfortable using an official released version.

    Minor fixes and enhancements include:

    • Compliance with MSVC warning level 4 (#151, #178)
    • Bug fixes related to tuples (thanks to @eschnett and @erichkeane, #175, #176)
    • Empty string fixes for XML archives (#182)
    • Fixes related to polymorphism and serialization function specialization (#180)

    See the closed issues for more information.

    Potential Breaking Changes

    In fixing #180, the type traits is_input_serializable and is_output_serializable were changed to accurately reflect their names. Prior to this release, these traits would return false if a type had more than one serialization function but was restricted to use only one of them through specialization. With this release, these traits base their decision on whether a type is either specialized for exactly one serialization method or has exactly one non-specialized serialization method available. If you relied on the previous (incorrect) behavior in any custom type traits, you may need to make appropriate changes.

    Upcoming Changes

    We next plan to fix some compilation issues with NVCC for users of cuda 7.0 and then move on to core 1.2 features, which will mainly focus on modules and various enhancements to cereal.

    To see what else is upcoming in the next release, check out milestone 1.2.

    Source code(tar.gz)
    Source code(zip)
  • v1.1.0(Jan 19, 2015)

    This is a minor feature and bug fix release for cereal.

    This is our first release since 1.0, and the first release with significant contribution from the community, which will only increase with 1.2. cereal would like to thank its users and contributors for helping make this release possible.

    Notable changes include:

    • cereal serialization functions (e.g. load/save/serialize) can now be easily renamed via macros in cereal/macros.hpp (thanks to @mattyclarkson, #60)
    • XML archives properly handle whitespace in text (thanks to @volo-zyko, #109)
    • Class versioning and polymorphic registration work properly with shared libraries (thanks in part to @ImplOfAnImpl, #113, #137)

    Minor fixes and enhancements include:

    • Fixed issues related to long serialization on OSX using libc++ (#81)
    • Fixed support of char serialization for XML archives (#116)
    • Fixes and enhancements related to minimal serialization (#79, #80)
    • Properly utilizing R-values in various internal containers (#96)
    • Improved support for ICC (Intel C++ compiler) (#120)
    • Tuple elements are now serialized in proper order with unique names in text archives (thanks in part to @erichkeane, #143). See breaking changes for a special note on this.
    • Additional miscellaneous bug fixes and code refactoring.

    See the closed issues for more information.

    Breaking Changes:

    This release introduces two breaking changes. The first will affect any user that created a custom serialization archive and utilizes minimal serialization functions with that archive:

    In fixing #79, we introduced the concept of relating input and output archives using type traits. You now need to use the macro CEREAL_SETUP_ARCHIVE_TRAITS(InArchive, OutArchive) for your custom archives if you wish to support minimal serialization. You can look at the source of any of the cereal provided archives to see an example of this.

    In addition, in fixing #80, we introduced a traits class that text based archives should inherit from. This has been applied to JSON and XML archives, but any users with custom text based archives are encouraged to have their text archive inherit from cereal::traits::TextArchive. This is not currently used internally by cereal but may be used by users with the new cereal::traits::is_text_archive traits class.

    The second breaking change has to do with tuple serialization. We fixed the order of tuple serialization to go in ascending (get<0>(), get<1>()) instead of descending order. See #143 for more information.

    Known Issues

    There is currently an error in the compile-time type checking that cereal performs on non-member load_minimal functions that will cause a static_assertion to mistakenly prevent compilation from succeeding. This only affects users using non-member load_minimal functions where the type to support load_minimal requires an unknown template parameter. See #132 for more information and workarounds. This is scheduled to be fixed in the next release.

    Various cereal macros such as CEREAL_REGISTER_TYPE do not work properly when used with templated class arguments (e.g. MyClass<OtherType>). You can use a typedef (e.g. using SingleName = MyClass<OtherType>) to avoid the issue. See #141 for the future solution we will use.

    Upcoming Changes

    The next version of cereal will introduce cereal modules, which will be collections of serialization functions or archives for types outside of the standard library. These will exist outside of the main cereal distribution to avoid cluttering the core of cereal. See https://github.com/USCiLab/cereal/labels/module for more information.

    To see what else is upcoming in the next release, check out milestone 1.2.

    Source code(tar.gz)
    Source code(zip)
  • v1.0.0(Mar 22, 2014)

    This is a major feature release for cereal. Notable changes include:

    • Support for Visual Studio 2013 (#11)
    • Support for out of order loading in text (XML/JSON) archives (#13, #14)
    • Full API compatibility with Boost serialization (#8)
    • Support for class versioning (#8)
    • New API for types with no default constructor (#43, #44, #59)
    • New minimal serialization functions (#23)
    • Compliance with the compiler flags -Wextra, -Wshadow, and -pedantic (#17)
    • Fixes related to libc++ compliance, especially on OSX (#49, #51, #72)
    • Support for std::enable_shared_from_this (cereal hall of fame for most annoying standard library feature to support) (#47)
    • Miscellaneous bug fixes, documentation updates, small improvements, and code refactoring

    See the closed issues for more information.

    cereal is not designed to be inherently backwards compatible across significant releases. There are a few changes in this release that may break some existing use cases:

    • The constructors for XML and JSON archives accept options in a different manner (#64)
    • Types with no default constructor have a new API and new names for required functions
    • Some built in types may have had their serialization format changed, especially in regards to text archives using name-value-pairs.
    • Enums use the new minimal serialization (#23)
    • JSON archives now serialize large types in base 10 instead of base 64 (#72)
    Source code(tar.gz)
    Source code(zip)
  • v0.9.1(Aug 26, 2013)

    This release introduces a few new features which can be found in detail here. In summary, they are:

    • Making archives more portable by switching away from size_t internally
    • Adding a portable_binary.hpp archive that handles little vs big endian machines (NOTE: this still needs more testing across architectures. It passes unit tests and simulated endian swaps)
    • GCC 4.7.3 is supported as the minimum GCC version
    • Supports compiling using libc++
    Source code(tar.gz)
    Source code(zip)
  • v0.9.0(Jul 10, 2013)

Owner
iLab @ USC
iLab @ USC
A C++11 library for serialization

cereal - A C++11 library for serialization cereal is a header-only C++11 serialization library. cereal takes arbitrary data types and reversibly turns

iLab @ USC 3.4k Jan 3, 2023
FlatBuffers: Memory Efficient Serialization Library

FlatBuffers FlatBuffers is a cross platform serialization library architected for maximum memory efficiency. It allows you to directly access serializ

Google 19.7k Jan 9, 2023
Simple C++ 20 Serialization Library that works out of the box with aggregate types!

BinaryLove3 Simple C++ 20 Serialization Library that works out of the box with aggregate types! Requirements BinaryLove3 is a c++20 only library.

RedSkittleFox 14 Sep 2, 2022
Zmeya is a header-only C++11 binary serialization library designed for games and performance-critical applications

Zmeya Zmeya is a header-only C++11 binary serialization library designed for games and performance-critical applications. Zmeya is not even a serializ

Sergey Makeev 99 Dec 24, 2022
CppSerdes is a serialization/deserialization library designed with embedded systems in mind

A C++ serialization/deserialization library designed with embedded systems in mind

Darren V Levine 79 Nov 5, 2022
Header-only library for automatic (de)serialization of C++ types to/from JSON.

fuser 1-file header-only library for automatic (de)serialization of C++ types to/from JSON. how it works The library has a predefined set of (de)seria

null 51 Dec 17, 2022
C++17 library for all your binary de-/serialization needs

blobify blobify is a header-only C++17 library to handle binary de-/serialization in your project. Given a user-defined C++ struct, blobify can encode

Tony Wasserka 247 Dec 8, 2022
Yet another JSON/YAML/BSON serialization library for C++.

ThorsSerializer Support for Json Yaml Bson NEW Benchmark Results Conformance mac linux Performance max linux For details see: JsonBenchmark Yet anothe

Loki Astari 281 Dec 10, 2022
Cista is a simple, high-performance, zero-copy C++ serialization & reflection library.

Simple C++ Serialization & Reflection. Cista++ is a simple, open source (MIT license) C++17 compatible way of (de-)serializing C++ data structures. Si

Felix Gündling 1.1k Jan 2, 2023
Microsoft 2.5k Dec 31, 2022
Fast Binary Encoding is ultra fast and universal serialization solution for C++, C#, Go, Java, JavaScript, Kotlin, Python, Ruby, Swift

Fast Binary Encoding (FBE) Fast Binary Encoding allows to describe any domain models, business objects, complex data structures, client/server request

Ivan Shynkarenka 654 Jan 2, 2023
Yet Another Serialization

YAS Yet Another Serialization - YAS is created as a replacement of boost.serialization because of its insufficient speed of serialization (benchmark 1

niXman 596 Jan 7, 2023
Binary Serialization

Binn Binn is a binary data serialization format designed to be compact, fast and easy to use. Performance The elements are stored with their sizes to

null 383 Dec 23, 2022
An implementation of the MessagePack serialization format in C / msgpack.org[C]

CMP CMP is a C implementation of the MessagePack serialization format. It currently implements version 5 of the MessagePack Spec. CMP's goal is to be

Charlie Gunyon 290 Dec 31, 2022
MPack - A C encoder/decoder for the MessagePack serialization format / msgpack.org[C]

Introduction MPack is a C implementation of an encoder and decoder for the MessagePack serialization format. It is: Simple and easy to use Secure agai

Nicholas Fraser 419 Jan 1, 2023
Serialization framework for Unreal Engine Property System that just works!

DataConfig Serialization framework for Unreal Engine Property System that just works! Unreal Engine features a powerful Property System which implemen

null 81 Dec 19, 2022
Yet Another Serialization

YAS Yet Another Serialization - YAS is created as a replacement of boost.serialization because of its insufficient speed of serialization (benchmark 1

niXman 455 Sep 7, 2021
universal serialization engine

A Universal Serialization Engine Based on compile-time Reflection iguana is a modern, universal and easy-to-use serialization engine developed in c++1

qicosmos 711 Jan 7, 2023
A lightweight C++20 serialization framework

zpp::bits A modern C++20 binary serialization library, with just one header file. This library is a successor to zpp::serializer. The library tries to

Eyal Z 299 Dec 31, 2022