DelegateMQ
Loading...
Searching...
No Matches
msg_serialize.h File Reference

A robust, header-only C++ binary serialization library. More...

#include <stdint.h>
#include <string.h>
#include <type_traits>
#include <typeinfo>
#include <iostream>
#include <memory>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <string>
#include <deque>
#include <forward_list>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>

Go to the source code of this file.

Classes

struct  serialize_traits::is_shared_ptr< T >
 
struct  serialize_traits::is_shared_ptr< std::shared_ptr< T > >
 
struct  serialize_traits::is_unsupported_container< U >
 
struct  serialize_traits::is_unsupported_container< std::multiset< U > >
 
struct  serialize_traits::is_unsupported_container< std::pair< U, V > >
 
struct  serialize_traits::is_unsupported_container< std::deque< T, Alloc > >
 
struct  serialize_traits::is_unsupported_container< std::forward_list< T, Alloc > >
 
struct  serialize_traits::is_unsupported_container< std::priority_queue< T, std::vector< T, Alloc > > >
 
struct  serialize_traits::is_unsupported_container< std::queue< T, Alloc > >
 
struct  serialize_traits::is_unsupported_container< std::stack< T, Alloc > >
 
struct  serialize_traits::is_unsupported_container< std::unordered_multiset< T, Hash, KeyEqual, Alloc > >
 
struct  serialize_traits::is_unsupported_container< std::unordered_map< Key, T, Hash, KeyEqual, Alloc > >
 
struct  serialize_traits::is_unsupported_container< std::unordered_multimap< Key, T, Hash, KeyEqual, Alloc > >
 
class  serialize
 The serialize class binary serializes and deserializes C++ objects. More...
 
class  serialize::I
 Abstract interface that all serialized user defined classes inherit. More...
 

Namespaces

namespace  serialize_traits
 

Macros

#define CHECK_UNSUPPORTED_CONTAINER
 

Detailed Description

A robust, header-only C++ binary serialization library.

See also
https://github.com/endurodave/MessageSerialize
Author
David Lafreniere
Date
2024

This library provides a framework for marshaling C++ objects, primitives, and STL containers into binary streams (std::ostream) and demarshaling them back (std::istream). It is designed for network communication and data persistence where binary compatibility and protocol evolution are required.

Key Features:

  • Single Header: A self-contained, header-only library with no external dependencies beyond the standard C++ library (STL).
  • Endianness Handling: Automatic endianness detection and byte-swapping to ensure compatibility between Big-Endian and Little-Endian architectures.
  • STL Container Support: Native serialization for std::vector, std::list, std::map, std::set, std::string, and std::wstring.
  • Protocol Versioning: Supports "Forward/Backward Compatibility" by handling size mismatches. If a received user-defined object is larger than expected (newer version), the parser safely discards the extra data.
  • Type Safety: Uses SFINAE and compile-time static assertions to prevent serialization of unsupported types or unsafe pointers.
  • Deep Copying: Supports serializing containers of pointers, automatically allocating memory upon deserialization.
  • Error Handling: Includes a callback-based error reporting mechanism for stream errors, type mismatches, and boundary violations.

Usage: User-defined classes must inherit from serialize::I and implement the read() and write() methods.

Macro Definition Documentation

◆ CHECK_UNSUPPORTED_CONTAINER

#define CHECK_UNSUPPORTED_CONTAINER