MySQL 9.1.0
Source Code Documentation
Enum_parser< Enum, Default_value > Class Template Reference

std::optional-like wrapper for simple bitmaps (usually enums of binary flags) More...

#include <parser_yystype.h>

Public Member Functions

void init ()
 Constructor-like function. More...
 
bool is_set () const
 False if the wrapped Enum value is not assigned. More...
 
Enum get () const
 Return the wrapped Enum value. More...
 
Enum get_or_default () const
 Return the wrapped Enum value (if any) or the Default_value. More...
 
void set (Enum value)
 Assign the wrapped Enum value. More...
 
void merge (const Enum_parser &x)
 Merge the x bit set into the wrapped Enum value (if any), or replace it. More...
 

Private Attributes

bool m_is_set
 True if m_enum is assigned with some value. More...
 
Enum m_enum
 The wrapped Enum value. More...
 

Detailed Description

template<typename Enum, Enum Default_value>
class Enum_parser< Enum, Default_value >

std::optional-like wrapper for simple bitmaps (usually enums of binary flags)

This template wraps trivial bitmap implementations to add two features:

std::optional-like behavior – the "unset" flag, so we don't have to inject a special "invalid" value into existent enum types, this wrapper class does that for us.

the merge() function to merge two bitmap values in a type-safe way.

Template Parameters
EnumUsually a enum type which simulates a bit set.
Default_valueA default Enum value for "unset" variables.

Member Function Documentation

◆ get()

template<typename Enum , Enum Default_value>
Enum Enum_parser< Enum, Default_value >::get ( ) const
inline

Return the wrapped Enum value.

Note
The wrapped value must be assigned.

◆ get_or_default()

template<typename Enum , Enum Default_value>
Enum Enum_parser< Enum, Default_value >::get_or_default ( ) const
inline

Return the wrapped Enum value (if any) or the Default_value.

◆ init()

template<typename Enum , Enum Default_value>
void Enum_parser< Enum, Default_value >::init ( )
inline

Constructor-like function.

The Enum_parser<> class is designed for use as a field of restricted unions, so it can't have C++ constructors.

◆ is_set()

template<typename Enum , Enum Default_value>
bool Enum_parser< Enum, Default_value >::is_set ( ) const
inline

False if the wrapped Enum value is not assigned.

◆ merge()

template<typename Enum , Enum Default_value>
void Enum_parser< Enum, Default_value >::merge ( const Enum_parser< Enum, Default_value > &  x)
inline

Merge the x bit set into the wrapped Enum value (if any), or replace it.

◆ set()

template<typename Enum , Enum Default_value>
void Enum_parser< Enum, Default_value >::set ( Enum  value)
inline

Assign the wrapped Enum value.

Member Data Documentation

◆ m_enum

template<typename Enum , Enum Default_value>
Enum Enum_parser< Enum, Default_value >::m_enum
private

The wrapped Enum value.

◆ m_is_set

template<typename Enum , Enum Default_value>
bool Enum_parser< Enum, Default_value >::m_is_set
private

True if m_enum is assigned with some value.


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