GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Categories
  • Newsletter
  • Submit
  • Login
  • Awesome C++
  • Serialization

This view

  • Original page
  • New address

GeezerVison is showing cpp.libhunt.com — cppbor Alternatives - C++ Serialization | LibHunt

  • Subscribe
  • Submit
  • Categories
  • About
  • Login

cppbor

An implementation of cbor using C++ 17 variants

RantyDave logo
Source Code    Changelog
Suggest Changes
Take the C++ Developer Survey - About 6 minutes on the tools, libraries and AI you use with C++. You get the results by email. Take the survey »
Popularity
1.5
Growing
Activity
0.0
Stable
Stars 15
Watchers 3
Forks 3
Last Commit almost 5 years ago

Description

This implementation focusses on:

* A clean API * A simple implementation and * Being unit tested * (including interoperability with cbor on Python)

It makes heavy use of C++17 variants to act as 'universal object' for both POD and object data types. Just like dynamic languages do (under the hood). In this case, the variant can hold int, float, monostate (like None in Python), unicode strings, binary data, arrays of other variants, or maps from strings to variants.

Programming language: C++
License: BSD 2-clause "Simplified" License
Tags: Inter-process Communication     Serialization     Rpc     C++17    

cppbor alternatives and similar libraries

Based on the "Serialization" category.
Alternatively, view cppbor alternatives based on common mentions on social networks and blogs.

  • protobuf

    10.0 9.9 L1 cppbor VS protobuf
    Protocol Buffers - Google's data interchange format
    protocolbuffers logo
  • FlatBuffers

    9.6 8.0 L1 cppbor VS FlatBuffers
    FlatBuffers: Memory Efficient Serialization Library
    google logo
  • SaaSHub - Software Alternatives and Reviews

    SaaSHub helps you find the best software and product alternatives
    Promo www.saashub.com
    SaaSHub Logo
  • Magic Enum C++

    8.3 8.7 cppbor VS Magic Enum C++
    Static reflection for enums (to string, from string, iteration) for modern C++, work with any enum type without any macro or boilerplate code
    Neargye logo
  • cereal

    8.1 4.6 L2 cppbor VS cereal
    A C++11 library for serialization
    USCiLab logo
  • MessagePack

    7.8 2.7 L1 cppbor VS MessagePack
    MessagePack implementation for C and C++ / msgpack.org[C/C++]
    msgpack logo
  • SimpleBinaryEncoding

    7.7 9.0 L1 cppbor VS SimpleBinaryEncoding
    Simple Binary Encoding (SBE) - High Performance Message Codec
    aeron-io logo
  • protobuf-c

    7.5 0.0 L2 cppbor VS protobuf-c
    Protocol Buffers implementation in C
    protobuf-c logo
  • Bond

    7.2 7.0 L3 cppbor VS Bond
    DISCONTINUED. Bond was a cross-platform framework for working with schematized data. The open-source project ended on March 31, 2025.
    microsoft logo
  • Nameof C++

    6.6 8.7 cppbor VS Nameof C++
    Nameof operator for modern C++, simply obtain the name of a variable, type, function, macro, and enum
    Neargye logo
  • Simple C++ Serialization & Reflection.

    6.5 6.6 cppbor VS Simple C++ Serialization & Reflection.
    Cista is a simple, high-performance, zero-copy C++ serialization & reflection library.
    felixguendling logo
  • Bitsery

    5.4 5.0 cppbor VS Bitsery
    Your binary serialization library
    fraillt logo
  • cppcodec

    4.7 0.0 L2 cppbor VS cppcodec
    Header-only C++11 library to encode/decode base64, base64url, base32, base32hex and hex (a.k.a. base16) as specified in RFC 4648, plus Crockford's base32. MIT licensed with consistent, flexible API.
    tplgy logo
  • The IOD Library

    4.6 0.0 L2 cppbor VS The IOD Library
    Meta programming utilities for C++14. Merged in matt-42/lithium
    matt-42 logo
  • smf

    4.6 0.0 cppbor VS smf
    Fastest RPC in the west
    smfrpc logo
  • protozero

    4.4 7.2 L2 cppbor VS protozero
    Minimalist protocol buffer decoder and encoder in C++
    mapbox logo
  • Boost.Serialization

    3.6 8.3 L3 cppbor VS Boost.Serialization
    Boost.org serialization module
    boostorg logo
  • config-loader

    3.3 2.0 cppbor VS config-loader
    Simple C++ Config Loader Framework(Serialization & Reflection)
    netcan logo
  • LeapSerial

    2.5 0.0 L4 cppbor VS LeapSerial
    The Leap Motion cross-format, cross-platform declarative serialization library
    leapmotion logo
  • JsonFusion

    1.4 8.7 cppbor VS JsonFusion
    Map structures to/from json
    tucher logo

* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.

Do you think we are missing an alternative of cppbor or a related project?

Add another 'Serialization' Library

Popular Comparisons

  • cppbor
    vs
    Magic Enum C++
  • cppbor
    vs
    cppcodec
  • cppbor
    vs
    FlatBuffers
  • cppbor
    vs
    Boost.Serialization
  • cppbor
    vs
    protobuf

README

What's this about then?

cbor is a marshalling (pickling) protocol designed to be compact both in representation and implementation. I first encountered it when looking for a fast json implementation for Python, and discovered it can do useful things that json can't such as:

  • Treat binary data and unicode strings as separate types
  • Encode 'None'

Why another implementation?

There are other C++ implementations but are generally streamed with callbacks (like a SAX parser) and that all looked a bit messy. This implementation focusses on:

  • A clean API
  • A simple implementation and
  • Being unit tested
  • (including interoperability with cbor on Python)

It makes heavy use of C++17 variants to act as 'universal object' for both POD and object data types. Just like dynamic languages do (under the hood). In this case, the variant can hold int, float, monostate (like None in Python), unicode strings, binary data, arrays of other variants, or maps from strings to variants.

Clean eh?

There are (effectively) only two calls in the API and they both act on a specialisation of the base class variant. They either construct a variant from a vector of bytes, or encode a variant onto one:

    // construct a variant from a vector of bytes
    static cbor_variant construct_from(const std::vector<cbor_byte>& in);

    // encode this variant onto the end of the passed vector
    void encode_onto(std::vector<cbor_byte>* in) const;

(cbor_byte is just typdef'd to unsigned char for clarity) Variants can be created 'from scratch' by just constructing them with the appropriate class in their initialiser list. You can find type by calling .index() where the result will be one of these enumerations. Your best guide, other than that, is to look at the unit tests.

Many variants

There are two techniques for putting many variants into a single buffer - either create a single variant that is an array of other variants, or just place them sequentially in a buffer. To support this case there is a second factory method:

    static cbor_variant construct_from(const std::vector<cbor_byte>& in, unsigned int* offset);

To use, initialise an unsigned int to zero and pass a pointer to it. Once the call has returned the offset will now be the index of the first byte not used. If that is not off the end of the buffer, the next variant can be constructed by just making the call again. You can see this being used as part of the implementation of arrays.

Performance

Has not been a concern although efforts have been made to ensure move semantics (for example) are correctly used. I imagine it's plenty fast, but probably not a candidate for tight space embedded projects.

Caveats

The cbor spec is quite wide so there are some omissions and shortcuts:

  • Maps can only use strings as keys.
  • 64 bit integers are not supported for either read or write.
  • Incoming floats can be of any width but will be coerced to a 32 bit float. Only 32 bit floats will be written.
  • Tagging is not supported (and ignored on ingestion).

Do not miss the trending, libraries, news and articles with our weekly report.

Awesome C++ is part of the LibHunt network. Terms. Privacy Policy.

(CC)
BY-SA
Spin The Wheel Of Names for a cryptographically secure random name picker.
Schedule a when to meet poll.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.