JSON Voorhees
Killer JSON for C++
jsonv::version Struct Reference

Represents a version used to extract and encode JSON objects from C++ classes. More...

#include <jsonv/serialization.hpp>

Public Types

using version_element = std::uint32_t
 

Public Member Functions

constexpr version (version_element major=0, version_element minor=0)
 Initialize an instance with the given major and minor version info. More...
 
constexpr bool empty () const
 Check if this version is an "empty" value – meaning major and minor are both 0. More...
 
constexpr operator std::uint64_t () const
 Convert this instance into a uint64_t. More...
 
constexpr bool operator== (const version &other) const
 Test for equality with other. More...
 
constexpr bool operator!= (const version &other) const
 Test for inequality with other. More...
 
constexpr bool operator< (const version &other) const
 Check that this version is less than other. More...
 
constexpr bool operator<= (const version &other) const
 Check that this version is less than or equal to other. More...
 
constexpr bool operator> (const version &other) const
 Check that this version is greater than other. More...
 
constexpr bool operator>= (const version &other) const
 Check that this version is greater than or equal to other. More...
 

Public Attributes

version_element major
 
version_element minor
 

Detailed Description

Represents a version used to extract and encode JSON objects from C++ classes.

This is useful for API versioning: if you need certain fields to be serialized only after a certain version or only before a different one.

Definition at line 45 of file serialization.hpp.

Constructor & Destructor Documentation

constexpr jsonv::version::version ( version_element  major = 0,
version_element  minor = 0 
)
inline

Initialize an instance with the given major and minor version info.

Definition at line 52 of file serialization.hpp.

Member Function Documentation

constexpr bool jsonv::version::empty ( ) const
inline

Check if this version is an "empty" value – meaning major and minor are both 0.

Definition at line 58 of file serialization.hpp.

constexpr jsonv::version::operator std::uint64_t ( ) const
inlineexplicit

Convert this instance into a uint64_t.

The major version will be in the higher-order bits, while minor will be in the lower-order bits.

Definition at line 66 of file serialization.hpp.

constexpr bool jsonv::version::operator!= ( const version other) const
inline

Test for inequality with other.

Definition at line 79 of file serialization.hpp.

constexpr bool jsonv::version::operator< ( const version other) const
inline

Check that this version is less than other.

The comparison is done lexicographically.

Definition at line 85 of file serialization.hpp.

constexpr bool jsonv::version::operator<= ( const version other) const
inline

Check that this version is less than or equal to other.

The comparison is done lexicographically.

Definition at line 91 of file serialization.hpp.

constexpr bool jsonv::version::operator== ( const version other) const
inline

Test for equality with other.

Definition at line 73 of file serialization.hpp.

constexpr bool jsonv::version::operator> ( const version other) const
inline

Check that this version is greater than other.

The comparison is done lexicographically.

Definition at line 97 of file serialization.hpp.

constexpr bool jsonv::version::operator>= ( const version other) const
inline

Check that this version is greater than or equal to other.

The comparison is done lexicographically.

Definition at line 103 of file serialization.hpp.


The documentation for this struct was generated from the following file: