diff options
author | Spartan322 <Megacake1234@gmail.com> | 2023-09-30 10:04:55 +0200 |
---|---|---|
committer | Spartan322 <Megacake1234@gmail.com> | 2023-09-30 10:15:52 +0200 |
commit | eb1b575b1d9a9a4dd7e6d39e4647c182ed90f87d (patch) | |
tree | 82f48726c7df56eb343b5de3dd8f12628be31c3c /include/openvic-dataloader | |
parent | 84b3bab4612f99d44bc17d97c9bd821b456f8d8d (diff) |
Unify conditional Constexprs to one filepoc/escape-behavior
Add OVDL_STRING_CONSTEXPR
Add OVDL_STR_OPT_CONSTEXPR
Diffstat (limited to 'include/openvic-dataloader')
6 files changed, 35 insertions, 24 deletions
diff --git a/include/openvic-dataloader/csv/LineObject.hpp b/include/openvic-dataloader/csv/LineObject.hpp index b9ee9a5..99c79c6 100644 --- a/include/openvic-dataloader/csv/LineObject.hpp +++ b/include/openvic-dataloader/csv/LineObject.hpp @@ -14,7 +14,7 @@ #include <vector> #include <openvic-dataloader/csv/ValueNode.hpp> -#include <openvic-dataloader/detail/VectorConstexpr.hpp> +#include <openvic-dataloader/detail/Constexprs.hpp> namespace ovdl::csv { /// LineObject should be able to recognize the differences between: @@ -57,7 +57,7 @@ namespace ovdl::csv { /// Special Functionality /// Retrieves value, produces "" for empty values - constexpr std::string get_value_for(std::size_t position) const { + OVDL_STRING_CONSTEXPR std::string get_value_for(std::size_t position) const { if (position < _prefix_end || position >= _suffix_end) return ""; for (const auto& object : *this) { if (object.get_position() == position) return object.make(); @@ -65,7 +65,7 @@ namespace ovdl::csv { return ""; } /// Tries to retrieve string, produces nullopt for empty values - constexpr std::optional<const std::string> try_get_string_at(std::size_t position) const { + OVDL_STR_OPT_CONSTEXPR std::optional<const std::string> try_get_string_at(std::size_t position) const { if (position < _prefix_end || position >= _suffix_end) return std::nullopt; for (const auto& object : *this) { if (object.get_position() == position) return object.make(); @@ -89,7 +89,7 @@ namespace ovdl::csv { return ""; } /// Tries to retrieve string, produces nullopt for empty values - constexpr std::optional<const std::string> try_get_string_at(std::size_t position, const IsMap<std::string> auto& map) const { + OVDL_STR_OPT_CONSTEXPR std::optional<const std::string> try_get_string_at(std::size_t position, const IsMap<std::string> auto& map) const { if (position < _prefix_end || position >= _suffix_end) return std::nullopt; for (const auto& object : *this) { if (object.get_position() == position) return object.make_from_map(map); diff --git a/include/openvic-dataloader/csv/ValueNode.hpp b/include/openvic-dataloader/csv/ValueNode.hpp index e66dac0..786f218 100644 --- a/include/openvic-dataloader/csv/ValueNode.hpp +++ b/include/openvic-dataloader/csv/ValueNode.hpp @@ -10,6 +10,8 @@ #include <variant> #include <vector> +#include <openvic-dataloader/detail/Constexprs.hpp> + #include <fmt/compile.h> #include <fmt/core.h> #include <fmt/format.h> @@ -54,7 +56,7 @@ namespace ovdl::csv { void add_to_list(internal_value_type value); bool list_is_empty() const; - inline std::string make_from_map(const IsMap<std::string> auto& map) const { + OVDL_STRING_CONSTEXPR std::string make_from_map(const IsMap<std::string> auto& map) const { std::vector<std::string_view> pre_joined(_value_list.size()); for (auto&& value : _value_list) { diff --git a/include/openvic-dataloader/detail/Constexprs.hpp b/include/openvic-dataloader/detail/Constexprs.hpp new file mode 100644 index 0000000..ade1bfa --- /dev/null +++ b/include/openvic-dataloader/detail/Constexprs.hpp @@ -0,0 +1,27 @@ +#pragma once + +// THANK YOU APPLE FOR YOUR UTTER DISREGARD FOR C++20 + +#if defined(__cpp_lib_optional) && __cpp_lib_optional >= 202106L +#define OVDL_OPTIONAL_CONSTEXPR constexpr +#else +#define OVDL_OPTIONAL_CONSTEXPR inline +#endif + +#if defined(__cpp_lib_constexpr_string) && __cpp_lib_constexpr_string >= 201907L +#define OVDL_STRING_CONSTEXPR constexpr +#else +#define OVDL_STRING_CONSTEXPR inline +#endif + +#if defined(__cpp_lib_optional) && __cpp_lib_optional >= 202106L && defined(__cpp_lib_constexpr_string) && __cpp_lib_constexpr_string >= 201907L +#define OVDL_STR_OPT_CONSTEXPR constexpr +#else +#define OVDL_STR_OPT_CONSTEXPR inline +#endif + +#if defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L +#define OVDL_VECTOR_CONSTEXPR constexpr +#else +#define OVDL_VECTOR_CONSTEXPR inline +#endif
\ No newline at end of file diff --git a/include/openvic-dataloader/detail/OptionalConstexpr.hpp b/include/openvic-dataloader/detail/OptionalConstexpr.hpp deleted file mode 100644 index bcb12a7..0000000 --- a/include/openvic-dataloader/detail/OptionalConstexpr.hpp +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -// THANK YOU APPLE FOR YOUR UTTER DISREGARD FOR C++20 - -#if __cpp_lib_optional >= 202106L -#define OVDL_OPTIONAL_CONSTEXPR constexpr -#else -#define OVDL_OPTIONAL_CONSTEXPR inline -#endif
\ No newline at end of file diff --git a/include/openvic-dataloader/detail/VectorConstexpr.hpp b/include/openvic-dataloader/detail/VectorConstexpr.hpp deleted file mode 100644 index 7e7fa34..0000000 --- a/include/openvic-dataloader/detail/VectorConstexpr.hpp +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -// THANK YOU APPLE FOR YOUR UTTER DISREGARD FOR C++20 - -#if __cpp_lib_constexpr_vector >= 201907L -#define OVDL_VECTOR_CONSTEXPR constexpr -#else -#define OVDL_VECTOR_CONSTEXPR inline -#endif
\ No newline at end of file diff --git a/include/openvic-dataloader/v2script/AbstractSyntaxTree.hpp b/include/openvic-dataloader/v2script/AbstractSyntaxTree.hpp index 8e39bd9..181a254 100644 --- a/include/openvic-dataloader/v2script/AbstractSyntaxTree.hpp +++ b/include/openvic-dataloader/v2script/AbstractSyntaxTree.hpp @@ -10,7 +10,7 @@ #include <utility> #include <vector> -#include <openvic-dataloader/detail/OptionalConstexpr.hpp> +#include <openvic-dataloader/detail/Constexprs.hpp> #include <openvic-dataloader/detail/SelfType.hpp> #include <openvic-dataloader/detail/TypeName.hpp> |