123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- #include "rttr/enumeration.h"
- #include "rttr/detail/enumeration/enumeration_wrapper_base.h"
- #include "rttr/argument.h"
- #include <utility>
- using namespace std;
- namespace rttr
- {
- namespace detail
- {
- template<>
- enumeration create_item(const enumeration_wrapper_base* wrapper)
- {
- return enumeration(wrapper);
- }
- template<>
- enumeration create_invalid_item()
- {
- static const enumeration_wrapper_base invalid_wrapper;
- return enumeration(&invalid_wrapper);
- }
- }
- enumeration::enumeration(const detail::enumeration_wrapper_base* wrapper) RTTR_NOEXCEPT
- : m_wrapper(wrapper)
- {
- }
- bool enumeration::is_valid() const RTTR_NOEXCEPT
- {
- return m_wrapper->is_valid();
- }
- enumeration::operator bool() const RTTR_NOEXCEPT
- {
- return m_wrapper->is_valid();
- }
- string_view enumeration::get_name() const RTTR_NOEXCEPT
- {
- return m_wrapper->get_type().get_name();
- }
- type enumeration::get_underlying_type() const RTTR_NOEXCEPT
- {
- return m_wrapper->get_underlying_type();
- }
- type enumeration::get_type() const RTTR_NOEXCEPT
- {
- return m_wrapper->get_type();
- }
- type enumeration::get_declaring_type() const RTTR_NOEXCEPT
- {
- return m_wrapper->get_declaring_type();
- }
- variant enumeration::get_metadata(const variant& key) const
- {
- return m_wrapper->get_metadata(key);
- }
- array_range<string_view> enumeration::get_names() const RTTR_NOEXCEPT
- {
- return m_wrapper->get_names();
- }
- array_range<variant> enumeration::get_values() const RTTR_NOEXCEPT
- {
- return m_wrapper->get_values();
- }
- string_view enumeration::value_to_name(argument value) const
- {
- return m_wrapper->value_to_name(value);
- }
- variant enumeration::name_to_value(string_view name) const
- {
- return m_wrapper->name_to_value(name);
- }
- bool enumeration::operator==(const enumeration& other) const RTTR_NOEXCEPT
- {
- return (m_wrapper == other.m_wrapper);
- }
- bool enumeration::operator!=(const enumeration& other) const RTTR_NOEXCEPT
- {
- return (m_wrapper != other.m_wrapper);
- }
- }
|