diff options
Diffstat (limited to 'src/openvic-simulation/types')
-rw-r--r-- | src/openvic-simulation/types/EnumBitfield.hpp | 18 | ||||
-rw-r--r-- | src/openvic-simulation/types/IdentifierRegistry.hpp | 22 |
2 files changed, 30 insertions, 10 deletions
diff --git a/src/openvic-simulation/types/EnumBitfield.hpp b/src/openvic-simulation/types/EnumBitfield.hpp index 2b0a1cf..8753449 100644 --- a/src/openvic-simulation/types/EnumBitfield.hpp +++ b/src/openvic-simulation/types/EnumBitfield.hpp @@ -27,58 +27,58 @@ namespace OpenVic { } template<OpenVic::EnumSupportBitfield T> -[[nodiscard]] constexpr inline auto operator|(const T lhs, const T rhs) noexcept { +[[nodiscard]] inline constexpr auto operator|(const T lhs, const T rhs) noexcept { using underlying_type = std::underlying_type_t<T>; return static_cast<T>(static_cast<underlying_type>(lhs) | static_cast<underlying_type>(rhs)); } template<OpenVic::EnumSupportBitfield T> -[[nodiscard]] constexpr inline auto operator&(const T lhs, const T rhs) noexcept { +[[nodiscard]] inline constexpr auto operator&(const T lhs, const T rhs) noexcept { using underlying_type = std::underlying_type_t<T>; return static_cast<T>(static_cast<underlying_type>(lhs) & static_cast<underlying_type>(rhs)); } template<OpenVic::EnumSupportBitfield T> -[[nodiscard]] constexpr inline auto operator^(const T lhs, const T rhs) noexcept { +[[nodiscard]] inline constexpr auto operator^(const T lhs, const T rhs) noexcept { using underlying_type = std::underlying_type_t<T>; return static_cast<T>(static_cast<underlying_type>(lhs) ^ static_cast<underlying_type>(rhs)); } template<OpenVic::EnumSupportBitfield T> -[[nodiscard]] constexpr inline auto operator~(const T lhs) noexcept { +[[nodiscard]] inline constexpr auto operator~(const T lhs) noexcept { using underlying_type = std::underlying_type_t<T>; return static_cast<T>(~static_cast<underlying_type>(lhs)); } template<OpenVic::EnumSupportBitfield T> -constexpr inline decltype(auto) operator|=(T& lhs, const T rhs) noexcept { +inline constexpr decltype(auto) operator|=(T& lhs, const T rhs) noexcept { using underlying_type = std::underlying_type_t<T>; lhs = static_cast<T>(static_cast<underlying_type>(lhs) | static_cast<underlying_type>(rhs)); return lhs; } template<OpenVic::EnumSupportBitfield T> -constexpr inline decltype(auto) operator&=(T& lhs, const T rhs) noexcept { +inline constexpr decltype(auto) operator&=(T& lhs, const T rhs) noexcept { using underlying_type = std::underlying_type_t<T>; lhs = static_cast<T>(static_cast<underlying_type>(lhs) & static_cast<underlying_type>(rhs)); return lhs; } template<OpenVic::EnumSupportBitfield T> -constexpr inline decltype(auto) operator^=(T& lhs, const T rhs) noexcept { +inline constexpr decltype(auto) operator^=(T& lhs, const T rhs) noexcept { using underlying_type = std::underlying_type_t<T>; lhs = static_cast<T>(static_cast<underlying_type>(lhs) ^ static_cast<underlying_type>(rhs)); return lhs; } template<OpenVic::EnumSupportBitfield T> -[[nodiscard]] constexpr inline bool operator<<(const T lhs, const T rhs) noexcept { +[[nodiscard]] inline constexpr bool operator<<(const T lhs, const T rhs) noexcept { using underlying_type = std::underlying_type_t<T>; return (lhs & rhs) == rhs; } template<OpenVic::EnumSupportBitfield T> -[[nodiscard]] constexpr inline bool operator>>(const T lhs, const T rhs) noexcept { +[[nodiscard]] inline constexpr bool operator>>(const T lhs, const T rhs) noexcept { using underlying_type = std::underlying_type_t<T>; return (lhs & rhs) == lhs; } diff --git a/src/openvic-simulation/types/IdentifierRegistry.hpp b/src/openvic-simulation/types/IdentifierRegistry.hpp index 251632b..68013d5 100644 --- a/src/openvic-simulation/types/IdentifierRegistry.hpp +++ b/src/openvic-simulation/types/IdentifierRegistry.hpp @@ -258,7 +258,7 @@ namespace OpenVic { if (item != nullptr) { \ return callback(*item); \ } \ - return NodeTools::warn_or_error(warn, "Invalid ", name, ": ", identifier); \ + return NodeTools::warn_or_error(warn, "Invalid ", name, " identifier: ", identifier); \ }; \ } \ constexpr NodeTools::NodeCallback auto expect_item_identifier( \ @@ -266,6 +266,16 @@ namespace OpenVic { ) CONST { \ return NodeTools::expect_identifier(expect_item_str(callback, warn)); \ } \ + constexpr NodeTools::NodeCallback auto expect_item_string( \ + NodeTools::Callback<value_type CONST&> auto callback, bool warn \ + ) CONST { \ + return NodeTools::expect_string(expect_item_str(callback, warn)); \ + } \ + constexpr NodeTools::NodeCallback auto expect_item_identifier_or_string( \ + NodeTools::Callback<value_type CONST&> auto callback, bool warn \ + ) CONST { \ + return NodeTools::expect_identifier_or_string(expect_item_str(callback, warn)); \ + } \ constexpr NodeTools::NodeCallback auto expect_item_assign_and_default( \ NodeTools::KeyValueCallback auto default_callback, \ NodeTools::Callback<value_type CONST&, ast::NodeCPtr> auto callback \ @@ -506,6 +516,16 @@ private: ) const_kw { \ return registry.expect_item_identifier(callback, warn); \ } \ + constexpr NodeTools::NodeCallback auto expect_##singular##_string( \ + NodeTools::Callback<decltype(registry)::value_type const_kw&> auto callback, bool warn = false \ + ) const_kw { \ + return registry.expect_item_string(callback, warn); \ + } \ + constexpr NodeTools::NodeCallback auto expect_##singular##_identifier_or_string( \ + NodeTools::Callback<decltype(registry)::value_type const_kw&> auto callback, bool warn = false \ + ) const_kw { \ + return registry.expect_item_identifier_or_string(callback, warn); \ + } \ constexpr NodeTools::NodeCallback auto expect_##singular##_assign_and_default( \ NodeTools::KeyValueCallback auto default_callback, \ NodeTools::Callback<decltype(registry)::value_type const_kw&, ast::NodeCPtr> auto callback \ |