aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/types
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2024-01-22 21:18:53 +0100
committer GitHub <noreply@github.com>2024-01-22 21:18:53 +0100
commit10f1f250883529e809d18a369f3668cfacd3bfd1 (patch)
tree7cd8a379963af18c24f8dabfe7525b39f2333e0c /src/openvic-simulation/types
parent8205732a1b95f018f0898a2a4bc62e22f5bee0d3 (diff)
parentcaa2f31d536f568e485f15537db5e2f79f7616d5 (diff)
Merge pull request #135 from OpenVicProject/misc-changes
Miscellaneous bug fixes and format cleanup
Diffstat (limited to 'src/openvic-simulation/types')
-rw-r--r--src/openvic-simulation/types/EnumBitfield.hpp18
-rw-r--r--src/openvic-simulation/types/IdentifierRegistry.hpp22
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 \