dxFeed Graal CXX API v9.0.0
Loading...
Searching...
No Matches
Enum< Child, Code > Struct Template Reference

A base of the enums that emulate Java enums. More...

#include <Enum.hpp>

Public Member Functions

constexpr Code getCode () const noexcept
 Returns code that is used in flag bits.
std::string getName () const
 Returns the enum element name.
std::string toString () const
 Returns a string representation of an enum element.

Static Public Member Functions

template<Integral OtherCodeType>
static const Child & valueOf (OtherCodeType code) noexcept
 Returns enum element by integer code bit pattern.

Protected Member Functions

template<Integral OtherCodeType>
constexpr Enum (OtherCodeType code, std::string_view name) noexcept
 Creates an element of the enum.

Friends

template<dxfcpp::ConvertibleTo< Enum< Child, Code > > E>
bool operator== (const E &e1, const E &e2)
 Compares two elements of an enum.
template<typename OStream, dxfcpp::ConvertibleTo< Enum< Child, Code > > E>
OStream & operator<< (OStream &os, const E &e)
 Puts the string representation of an enum element to the output stream.

Detailed Description

template<typename Child, typename Code>
struct Enum< Child, Code >

A base of the enums that emulate Java enums.

The elements are constant-initialized (constinit), so they and valueOf() can be used in the dynamic initialization of global variables.

Template Parameters
ChildThe enum type: declares static const std::span<const std::reference_wrapper<const Child>> ALL, all elements of the enum, one of them with code 0 (the default of the bit field of an event).
CodeThe type of the element code.

Constructor & Destructor Documentation

◆ Enum()

template<typename Child, typename Code>
template<Integral OtherCodeType>
Enum< Child, Code >::Enum ( OtherCodeType code,
std::string_view name )
inlineconstexprprotectednoexcept

Creates an element of the enum.

Parameters
codeThe element code.
nameThe element name with static storage duration (a string literal).

Member Function Documentation

◆ getCode()

template<typename Child, typename Code>
Code Enum< Child, Code >::getCode ( ) const
inlinenodiscardconstexprnoexcept

Returns code that is used in flag bits.

Returns
code.

◆ getName()

template<typename Child, typename Code>
std::string Enum< Child, Code >::getName ( ) const
inlinenodiscard

Returns the enum element name.

Returns
name

◆ toString()

template<typename Child, typename Code>
std::string Enum< Child, Code >::toString ( ) const
inlinenodiscard

Returns a string representation of an enum element.

Returns
a string representation

◆ valueOf()

template<typename Child, typename Code>
template<Integral OtherCodeType>
const Child & Enum< Child, Code >::valueOf ( OtherCodeType code)
inlinestaticnoexcept

Returns enum element by integer code bit pattern.

Parameters
codeinteger code.
Returns
enum element; the element with code 0 when no element has the specified code, as the Java API reads the bit fields of the events.

◆ operator<<

template<typename Child, typename Code>
template<typename OStream, dxfcpp::ConvertibleTo< Enum< Child, Code > > E>
OStream & operator<< ( OStream & os,
const E & e )
friend

Puts the string representation of an enum element to the output stream.

Template Parameters
OStreamA type of the output stream
EType convertible to enum Enum<Child, Code>
Parameters
osThe output stream
eThe element of the enum
Returns
The output stream

◆ operator==

template<typename Child, typename Code>
template<dxfcpp::ConvertibleTo< Enum< Child, Code > > E>
bool operator== ( const E & e1,
const E & e2 )
friend

Compares two elements of an enum.

Template Parameters
EType convertible to enum Enum<Child, Code>
Parameters
e1The first element of the enum to be compared
e2The second element of the enum to be compared
Returns
true if the elements are the same