Skip to content
Marc edited this page Jan 3, 2017 · 52 revisions

Cereal (pronounced Serial) is a serialization library written by raresica1234 and marcizhu. The library is based on TheCherno's serialization library for Java. The library is really simple and fully customizable to fit all your needs.

Resources

Introduction

Cereal allows you to read and write serialized data from both memory and files, so you can use it store anything your program needs into a single file.
The main purpose of this library was to be used in games to store player data and make multiplayer support much easier, but it can be used for any pupose.

API Reference

Cereal is made up of small clases that work toghether. The classes you will find inside the library are the following:

  • Field: A field is the simplest serialized data object. It has a name, and stores a single data type. The valid data types are: bool, char, byte, short, int, long long, float, double and std::string (C++) / string (C#)
  • Array: An array also has a name, but it can store up to 4.294.967.296 items in it (theoretically, in reality the maximum is 1.073.741.824 items because of the x86 architecture). The data types it can store are: bool, char, byte, short, int, long long, float, double and std::string (C++) / string (C#)
  • Object: An object is a bit more advanced. It has a name, and can store up to 65536 fields plus 65536 arrays.
  • Database: A database is a collection of objects. It can store up to 65536 objects, but keep in mind that the maximum size of a database is 4 gigabytes, and here's why.
  • Header: Headers are completely optional. Headers allow to store up to 255 databases in a single file or memory block, so if you need more than a single database, this is definitely a solution to that.
  • Buffer: Buffers don't store data. Instead, they can be used as a temporary storage while serializing or deserializing data. Also they are able of reading or writing to files.
  • Reader/Writer: Those classes are used internally by the code. They allow to serialize and deserialize basic data types. You don't have to use them, but you definitely can.

Supported environments

The library was entirely made in Microsoft Visual Studio 2015 Community Edition, but it should work in any other environment, as it only uses standard C++ code. If you have tested it in other environments, please edit this page.

Environment Supported? Notes
Microsoft Visual Studio 2015 Community Edition Yes -

Supported languages

The library was originally made for C++, but we both needed to serialize some data in C#, and we needed that data to be compatible with the C++ version of Cereal, so we ported the library to C#. Right now, it works on both C++ and C# without any problems, but the C# version still needs some improvements.

We recommend you to wait until the next official release before you start using Cereal-C#, but you can use it now if you really need/want to. Just be careful and please, report all issues you find in this port.

Known issues

If you discover a bug, please open an issue here and we will fix it as soon as possible.

ID Title Description
#3 Doubles don't work in Cereal-CSharp Right now, reading float fields makes the library crash in the C# port of the lib