-
Notifications
You must be signed in to change notification settings - Fork 5
Home
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.
- Introduction
- API Reference
- Download and install
- Supported environments
- Known issues
- Contributing to Cereal
- Other resources (examples, tools, code snippets...)
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.
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
andstd::string
-
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 x86 architecture). The data types it can store are:
bool
,char
,byte
,short
,int
,long long
,float
anddouble
- 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.
To use the library, download this repository and add the header files inside Cereal/Cereal
to your project. You should have the following items:
Cereal.h
src/Array.h
src/Buffer.h
src/Database.h
src/Field.h
src/Header.h
src/Internal.h
src/Object.h
src/Reader.h
src/Writer.h
Once all those files are linked to your project, now you only have to include Cereal.h
and start using it! All the clases are inside the namespace Cereal
, so you might consider adding a using namespace Cereal;
on the top of your code.
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 | - |
As far as we know, there isn't any issues with the library. If you discover a bug, please open an issue here and we will fix it as soon as possible.
Home | About Cereal | Setup Guide | Technical Docs | API Reference | Copyright © 2016 - 2019 The Cereal Team