JSON Voorhees
Killer JSON for C++
Loading...
Searching...
No Matches
jsonv::version Struct Reference

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

#include <jsonv/version.hpp>

Public Types

using version_element = std::uint32_t
 

Public Member Functions

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

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 23 of file version.hpp.

Member Typedef Documentation

◆ version_element

using jsonv::version::version_element = std::uint32_t

Definition at line 26 of file version.hpp.

Constructor & Destructor Documentation

◆ version()

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

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

Definition at line 30 of file version.hpp.

Member Function Documentation

◆ empty()

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

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

Definition at line 36 of file version.hpp.

◆ operator std::uint64_t()

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

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 43 of file version.hpp.

◆ operator!=()

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

Test for inequality with other.

Definition at line 56 of file version.hpp.

◆ operator<()

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

Check that this version is less than other. The comparison is done lexicographically.

Definition at line 62 of file version.hpp.

◆ operator<=()

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

Check that this version is less than or equal to other. The comparison is done lexicographically.

Definition at line 68 of file version.hpp.

◆ operator==()

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

Test for equality with other.

Definition at line 50 of file version.hpp.

◆ operator>()

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

Check that this version is greater than other. The comparison is done lexicographically.

Definition at line 74 of file version.hpp.

◆ operator>=()

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

Check that this version is greater than or equal to other. The comparison is done lexicographically.

Definition at line 80 of file version.hpp.

Member Data Documentation

◆ major

version_element jsonv::version::major

Definition at line 86 of file version.hpp.

◆ minor

version_element jsonv::version::minor

Definition at line 87 of file version.hpp.


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