|
Object | zakero::messagepack::deserialize (const std::vector< uint8_t > &data) noexcept |
| Deserialize MessagePack data. More...
|
|
Object | zakero::messagepack::deserialize (const std::vector< uint8_t > &data, size_t &index) noexcept |
| Deserialize MessagePack data. More...
|
|
Object | zakero::messagepack::deserialize (const std::vector< uint8_t > &data, size_t &index, std::error_code &error) noexcept |
| Deserialize MessagePack data. More...
|
|
Object | zakero::messagepack::deserialize (const std::vector< uint8_t > &data, std::error_code &error) noexcept |
| Deserialize MessagePack data. More...
|
|
bool | zakero::messagepack::extensionTimestampCheck (const Object &object) noexcept |
| Timestamp Extension Check. More...
|
|
struct timespec | zakero::messagepack::extensionTimestampConvert (const Object &object) noexcept |
| Convert MessagePack Timestamp extension into a struct timespec . More...
|
|
Object | zakero::messagepack::extensionTimestampConvert (const struct timespec &ts) noexcept |
| Convert a struct timespec into a MessagePack Timestamp extension. More...
|
|
bool | operator!= (const zakero::messagepack::Object &lhs, const zakero::messagepack::Object &rhs) noexcept |
| Compare two Objects for inequality. More...
|
|
std::ostream & | operator<< (std::ostream &stream, const zakero::messagepack::Array &array) noexcept |
| OStream operator. More...
|
|
std::ostream & | operator<< (std::ostream &stream, const zakero::messagepack::Ext &ext) noexcept |
| OStream operator. More...
|
|
std::ostream & | operator<< (std::ostream &stream, const zakero::messagepack::Map &map) noexcept |
| OStream operator. More...
|
|
std::ostream & | operator<< (std::ostream &stream, const zakero::messagepack::Object &object) noexcept |
| OStream operator. More...
|
|
bool | operator== (const zakero::messagepack::Object &lhs, const zakero::messagepack::Object &rhs) noexcept |
| Compare two Objects for equality. More...
|
|
std::vector< uint8_t > | zakero::messagepack::serialize (const Array &array) noexcept |
| Serialize Array data. More...
|
|
std::vector< uint8_t > | zakero::messagepack::serialize (const Array &array, std::error_code &error) noexcept |
| Serialize Array data. More...
|
|
std::vector< uint8_t > | zakero::messagepack::serialize (const Ext &ext) noexcept |
| Serialize Ext data. More...
|
|
std::vector< uint8_t > | zakero::messagepack::serialize (const Ext &ext, std::error_code &error) noexcept |
| Serialize Ext data. More...
|
|
std::vector< uint8_t > | zakero::messagepack::serialize (const Map &map) noexcept |
| Serialize Map data. More...
|
|
std::vector< uint8_t > | zakero::messagepack::serialize (const Map &map, std::error_code &error) noexcept |
| Serialize Map data. More...
|
|
std::vector< uint8_t > | zakero::messagepack::serialize (const Object &object) noexcept |
| Serialize Object data. More...
|
|
std::vector< uint8_t > | zakero::messagepack::serialize (const Object &object, std::error_code &error) noexcept |
| Serialize Object data. More...
|
|
std::string | zakero::messagepack::to_string (const messagepack::Array &array) noexcept |
| Convert to a JSON formatted string. More...
|
|
std::string | zakero::messagepack::to_string (const messagepack::Ext &ext) noexcept |
| Convert to a JSON formatted string. More...
|
|
std::string | zakero::messagepack::to_string (const messagepack::Map &map) noexcept |
| Convert to a JSON formatted string. More...
|
|
std::string | zakero::messagepack::to_string (const messagepack::Object &object) noexcept |
| Convert to a JSON formatted string. More...
|
|
|
#define | X(name_, val_, mesg_) |
| Generate Code.
|
|
#define | X(name_, val_, mesg_) |
| Generate Code.
|
|
#define | X(type_, id_, mask_, size_, text_) |
| Generate Code.
|
|
#define | X(type_, id_, mask_, size_, text_) |
| Generate Code.
|
|
#define | X(type_, id_, mask_, size_, text_) |
| Generate Code.
|
|
#define | X(type_, id_, mask_, size_, text_) |
| Generate Code.
|
|
The Zakero_MessagePack will serialize and deserialize data using the MessagePack specification.
- Dependencies
-
- TL;DR:
This library makes it very easy to use the MessagePack data format.
To use:
- Add the implementation to a source code file:
#define ZAKERO_MESSAGEPACK_IMPLEMENTATION
#include "Zakero_MessagePack.h"
- Add the library to where it is used:
- What Is It?
- The Zakero_MessagePack library provides a way to serialize data for storage or transport over a network. Deserialization is also available so that the data may be accessed. The MessagePack specification provides a format that allows many different types of data to be packed with very little overhead.
- Why Use It?
There are many libraries available to do the same thing, however the Zakero_MessagePack library offers the following:
Benefits
- Single Header Library
- Small compile size
- Easy to add data
- Access to existing data
- Modify existing data
- Uses native C++ types
Draw Backs
- Memory Usage: Serialization makes a copy of the contents
Instead of attempting to interface with other libraries or provide a dynamic interface, basic C++ types are used. It is expected that this approach will make using the library with other code bases easier and less volatile.
- How To Use It?
Step 0
Your compiler must support at least the C++20 standard. The location of the Zakero_MessagePack.h
header files must be in your compiler's include path.
Step 1
The first step is to select which C++ source code file will contain the Zakero MessagePack implementation. Once the location has been determined, add the following to that file:
#define ZAKERO_MESSAGEPACK_IMPLEMENTATION
#include "Zakero_MessagePack.h"
The macro ZAKERO_MESSAGEPACK_IMPLEMENTATION tells the header file to include the implementation of the MessagePack.
In all other files that will use the MessagePack, they need to include the header.
Step 2
Create MessagePack Objects to store data. Use containers to store more objects. Then serialize the data.
MessagePack Objects can also be created by deserializing data.
Add data manually
array.
append({std::string(
"Hello, World!")});
An array of Objects.
Definition: Zakero_MessagePack.h:272
size_t append(const bool) noexcept
Append a boolean value.
Definition: Zakero_MessagePack.h:1425
A Data Object.
Definition: Zakero_MessagePack.h:337
Deserialize data
std::vector<uint8_t> data = load_data();
Object deserialize(const std::vector< uint8_t > &) noexcept
Deserialize MessagePack data.
Definition: Zakero_MessagePack.h:4678
The data in the MessagePack can be modified:
if(object.isArray())
{
array.
object(2) = {std::string(
"Good Bye!")};
}
Object & object(const size_t index) noexcept
Access a data object.
Definition: Zakero_MessagePack.h:291
Then the MessagePack can be (re)serialized:
std::vector< uint8_t > serialize(const messagepack::Array &) noexcept
Serialize Array data.
Definition: Zakero_MessagePack.h:5943
- Version
v0.9.1
- Beta Release 2
- Restricted Map key types to improve performance.
v0.9.0
- Beta Release
- Added error checks to the deserializer
v0.3.1
- Fixed issues found by CLang++
v0.3.0
- Alpha Release
- Added support for Ext
- Added support for Maps
- Added support for the Timestamp extension
- Complete rewrite
v0.2.0
v0.1.0
- The initial implementation
- Copyright
- Mozilla Public License v2
- Author
- Andrew "Zakero" Moore