Enum.hpp

This File On Github
Ask A Question

API: latest
module: oatpp
#include "oatpp/core/data/mapping/type/Enum.hpp"

EnumInterpreterError

Errors of enum interpretation.

namespace oatpp { namespace data { namespace mapping { namespace type { 
  enum class EnumInterpreterError : v_int32;
}}}}

EnumInterpreterError::OK

The interpretation was successful.

OK = 0

EnumInterpreterError::TYPE_MISMATCH_ENUM

Wrong Interpreter is used to interpret the variable.
This may also occur if for example:
oatpp::Enum<T> is passed to interpreter of oatpp::Enum<T>::NotNull.

TYPE_MISMATCH_ENUM = 1

EnumInterpreterError::TYPE_MISMATCH_ENUM_VALUE

Wrong oatpp::data::mapping::type::Primitive is passed to interpreter.

TYPE_MISMATCH_ENUM_VALUE = 2

EnumInterpreterError::CONSTRAINT_NOT_NULL

Interpreter constraint is violated.
The constraint was set to NotNull but interpretation to/from nullptr is requested.

CONSTRAINT_NOT_NULL = 3

EnumInterpreterError::ENTRY_NOT_FOUND

Enum entry not found.

ENTRY_NOT_FOUND = 4

AbstractEnum

Abstract Enum class.

namespace oatpp { namespace data { namespace mapping { namespace type { namespace __class { 
  class AbstractEnum {}
}}}}}

EnumValueInfo

Enum value info.

  • @tparam T - underlying enum type.

namespace oatpp { namespace data { namespace mapping { namespace type { 
  template<typename T>
  struct EnumValueInfo {}
}}}}

Fields

Type Name Summary
const T value Entry value. T - enum type.
const v_int32 index Index of the entry.
const data::share::StringKeyLabel name Name of the enum entry or name-qualifier, if qualifier was specified.
oatpp::data::share::StringKeyLabel.
const data::share::StringKeyLabel description Description of the enum etry.
oatpp::data::share::StringKeyLabel.

EnumValueInfo::value

Entry value. T - enum type.

const T value

EnumValueInfo::index

Index of the entry.

const v_int32 index

EnumValueInfo::name

Name of the enum entry or name-qualifier, if qualifier was specified.
oatpp::data::share::StringKeyLabel.

const data::share::StringKeyLabel name

EnumValueInfo::description

Description of the enum etry.
oatpp::data::share::StringKeyLabel.

const data::share::StringKeyLabel description

EnumInterpreterAsString

Enum interpreter AsString

  • @tparam T
  • @tparam notnull

namespace oatpp { namespace data { namespace mapping { namespace type { 
  template<class T, bool notnull>
  class EnumInterpreterAsString {}
}}}}

EnumInterpreterAsNumber

Enum interpreter AsNumber

  • @tparam T
  • @tparam notnull

namespace oatpp { namespace data { namespace mapping { namespace type { 
  template<class T, bool notnull>
  class EnumInterpreterAsNumber {}
}}}}

EnumObjectWrapper

Template class for oatpp::Enum<T>.

  • @tparam T - enum type.
  • @tparam EnumInterpreter - enum interpreter.

namespace oatpp { namespace data { namespace mapping { namespace type { 
  template<class T, class EnumInterpreter>
  class EnumObjectWrapper : public ObjectWrapper<T, __class::Enum<T, EnumInterpreter>> {}
}}}}

Typedefs

Type Name Summary
EnumInterpreter Interpreter Template parameter - Interpreter.
EnumObjectWrapper<T, EnumInterpreterAsString<T, EnumInterpreter::notNull>> AsString Enum interpreted AsString.
EnumObjectWrapper<T, EnumInterpreterAsNumber<T, EnumInterpreter::notNull>> AsNumber Enum interpreted AsNumber.
EnumObjectWrapper<T, typenameEnumInterpreter::templateInterpreterType<true>> NotNull Enum with NotNull interpretation constraint.

Methods

Return Type Name Summary
[none] EnumObjectWrapper Multiple implementations:
  1. Default constructor.
  2. Nullptr constructor.
  3. Constructor.
  4. Constructor.
  5. Copy-constructor.
  6. Move-constructor.
  7. Constructor by value.
const EnumValueInfo<T>& getEntryByName Get EnumValueInfo<T> by name.
const EnumValueInfo<T>& getEntryByValue Get EnumValueInfo<T> by enum value.
const EnumValueInfo<T>& getEntryByUnderlyingValue Get EnumValueInfo<T> by integer value.
const EnumValueInfo<T>& getEntryByIndex Get EnumValueInfo<T> by index.
const std::vector<EnumValueInfo<T>>& getEntries Get std::vector of EnumValueInfo<T>.

EnumObjectWrapper::Interpreter

Template parameter - Interpreter.

typedef EnumInterpreter Interpreter

EnumObjectWrapper::AsString

Enum interpreted AsString.

typedef EnumObjectWrapper<T, EnumInterpreterAsString<T, EnumInterpreter::notNull>> AsString

EnumObjectWrapper::AsNumber

Enum interpreted AsNumber.

typedef EnumObjectWrapper<T, EnumInterpreterAsNumber<T, EnumInterpreter::notNull>> AsNumber

EnumObjectWrapper::NotNull

Enum with NotNull interpretation constraint.

typedef EnumObjectWrapper<T, typename EnumInterpreter::template InterpreterType<true>> NotNull

EnumObjectWrapper::EnumObjectWrapper

  1. Default constructor.
    EnumObjectWrapper()
    
  2. Nullptr constructor.
    EnumObjectWrapper(std::nullptr_t)
    
  3. Constructor.
    • @param ptr
    EnumObjectWrapper(const std::shared_ptr<T>& ptr)
      : type::ObjectWrapper<T, EnumObjectClass>(ptr)
    
  4. Constructor.
    • @param ptr
    EnumObjectWrapper(std::shared_ptr<T>&& ptr)
      : type::ObjectWrapper<T, EnumObjectClass>(std::forward<std::shared_ptr<T>>(ptr))
    
  5. Copy-constructor.
    • @tparam OtherInter
    • @param other
    template<class OtherInter>
    EnumObjectWrapper(const EnumObjectWrapper<T, OtherInter>& other)
      : type::ObjectWrapper<T, EnumObjectClass>(other.getPtr())
    
  6. Move-constructor.
    • @tparam OtherInter
    • @param other
    template<class OtherInter>
    EnumObjectWrapper(EnumObjectWrapper<T, OtherInter>&& other)
      : type::ObjectWrapper<T, EnumObjectClass>(std::move(other.getPtr()))
    
  7. Constructor by value.
    • @param value
    EnumObjectWrapper(T value)
      : type::ObjectWrapper<T, EnumObjectClass>(std::make_shared<T>(value))
    

EnumObjectWrapper::getEntryByName

Get EnumValueInfo<T> by name.

  • @param name - name or name-qualifier of the enum entry.
  • @return - EnumValueInfo<T>.
  • @throws - std::runtime_error if not found.

static const EnumValueInfo<T>& getEntryByName(const String& name)

EnumObjectWrapper::getEntryByValue

Get EnumValueInfo<T> by enum value.

  • @param value - enum value.
  • @return - EnumValueInfo<T>.
  • @throws - std::runtime_error if not found.

static const EnumValueInfo<T>& getEntryByValue(T value)

EnumObjectWrapper::getEntryByUnderlyingValue

Get EnumValueInfo<T> by integer value.

  • @param value - integer value.
  • @return - EnumValueInfo<T>.
  • @throws - std::runtime_error if not found.

static const EnumValueInfo<T>& getEntryByUnderlyingValue(UnderlyingEnumType value)

EnumObjectWrapper::getEntryByIndex

Get EnumValueInfo<T> by index.

  • @param index - index of the entry in the enum.
  • @return - EnumValueInfo<T>.
  • @throws - std::runtime_error if not found.

static const EnumValueInfo<T>& getEntryByIndex(v_int32 index)

EnumObjectWrapper::getEntries

Get std::vector of EnumValueInfo<T>.

static const std::vector<EnumValueInfo<T>>& getEntries()

Enum

Namespace: oatpp::data::mapping::type

Mapping-enabled Enum. See EnumObjectWrapper.

template <class T>
using Enum = EnumObjectWrapper<T, EnumInterpreterAsString<T, false>>