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

◆ operator!=()

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

Test for inequality with other.

Definition at line 60 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 67 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 74 of file version.hpp.

◆ operator==()

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

Test for equality with other.

Definition at line 53 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 81 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 88 of file version.hpp.

Member Data Documentation

◆ major

version_element jsonv::version::major

Definition at line 94 of file version.hpp.

◆ minor

version_element jsonv::version::minor

Definition at line 95 of file version.hpp.


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