diff --git a/.gitignore b/.gitignore index e3452839..5aa71532 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ Makefile.local merged_api.yaml tests/results Makefile.local +log_build.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 35913f8e..b3ee9a40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,7 @@ add_library(${PROJECT_NAME}_objs OBJECT ) target_include_directories(${PROJECT_NAME}_objs PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) target_link_libraries(${PROJECT_NAME}_objs PUBLIC userver-core userver-postgresql) +# target_compile_options(${PROJECT_NAME}_objs PRIVATE -Wfatal-errors) # The Service diff --git a/Makefile b/Makefile index 3d2a7f3f..fa74fe33 100644 --- a/Makefile +++ b/Makefile @@ -200,6 +200,10 @@ gen: $(MAKE) gen-sources $(MAKE) gen-all-headers +.PHONY: build-log +build-log: + $(MAKE) -s test-debug > log_build.txt 2>&1 + # # Internal hidden targets that are used only in docker environment # --in-docker-start-debug --in-docker-start-release: --in-docker-start-%: install-% # @sed -i 's/config_vars.yaml/config_vars.docker.yaml/g' /home/user/.local/etc/timetable_vsu_backend/static_config.yaml diff --git a/src/openapi/base/traits/array.hpp b/src/openapi/base/traits/array.hpp index 768ade49..7e5ad782 100644 --- a/src/openapi/base/traits/array.hpp +++ b/src/openapi/base/traits/array.hpp @@ -13,8 +13,7 @@ concept HasMin = requires { { T::kMin - } - ->std::convertible_to>; + }; }; template @@ -22,8 +21,7 @@ concept HasMax = requires { { T::kMax - } - ->std::convertible_to>; + }; }; template @@ -31,75 +29,37 @@ concept HasUniqueItems = requires { { T::kUniqueItems - } - ->std::convertible_to>; + }; }; -template -concept HasNotMin = !HasMin; - -template -concept HasNotMax = !HasMax; - -template -concept HasNotUniqueItems = !HasUniqueItems; } // namespace checks -namespace detail -{ -template -constexpr auto _getMin() -{ - return T::kMin; -} - -template -constexpr auto _getMin() -{ - return utils::ConstexprOptional{utils::kNull}; -} - -template -constexpr auto _getMax() -{ - return T::kMax; -} - -template -constexpr auto _getMax() -{ - return utils::ConstexprOptional{utils::kNull}; -} - -template -constexpr auto _getUniqueItems() -{ - return T::kUniqueItems; -} - -template -constexpr auto _getUniqueItems() -{ - return utils::ConstexprOptional{utils::kNull}; -} -} // namespace detail namespace traits { template constexpr utils::ConstexprOptional GetMin() { - return detail::_getMin(); + if constexpr (checks::HasMin){ + return T::kMin; + } + else return utils::kNull; } template constexpr utils::ConstexprOptional GetMax() { - return detail::_getMax(); + if constexpr (checks::HasMax){ + return T::kMax; + } + else return utils::kNull; } template constexpr utils::ConstexprOptional GetUniqueItems() { - return detail::_getUniqueItems(); + if constexpr (checks::HasUniqueItems){ + return T::kUniqueItems; + } + else return utils::kNull; } template diff --git a/src/openapi/base/traits/optional.hpp b/src/openapi/base/traits/optional.hpp index 99cfa9b2..990fd5db 100644 --- a/src/openapi/base/traits/optional.hpp +++ b/src/openapi/base/traits/optional.hpp @@ -12,36 +12,20 @@ concept HasUseNullOnFail = requires { { T::kUseNullOnFail - } - ->std::convertible_to>; + }; }; } // namespace checks -namespace detail -{ -template -requires checks::HasUseNullOnFail constexpr utils::ConstexprOptional -_getUseNullOnFail() -{ - return T::kUseNullOnFail; -} - -template -requires(!checks::HasUseNullOnFail) constexpr utils::ConstexprOptional< - bool> _getUseNullOnFail() -{ - return utils::kNull; -} - -} // namespace detail - namespace traits { template constexpr utils::ConstexprOptional GetUseNullOnFail() { - return detail::_getUseNullOnFail(); + if constexpr (checks::HasUseNullOnFail){ + return T::kUseNullOnFail; + } + else return utils::kNull; } template diff --git a/src/openapi/base/traits/string.hpp b/src/openapi/base/traits/string.hpp index b715d747..464d214a 100644 --- a/src/openapi/base/traits/string.hpp +++ b/src/openapi/base/traits/string.hpp @@ -12,42 +12,21 @@ namespace checks template concept HasPattern = requires { - { - decltype(T::kPattern)::kSize - } - ->std::convertible_to; - requires std::is_same_v< - utils::ConstexprString, - std::remove_cv_t>; { T::kPattern - } - ->std::convertible_to>; + }; }; } // namespace checks -namespace detail -{ -template -requires checks::HasPattern constexpr auto _getPattern() -{ - return T::kPattern; -} - -template -requires(!checks::HasPattern) constexpr auto _getPattern() -{ - using Type = utils::ConstexprString<1>; - return Type{""}; -} -} // namespace detail - namespace traits { template constexpr auto GetPattern() { - return detail::_getPattern(); + if constexpr (checks::HasPattern){ + return T::kPattern; + } + else return utils::kEmptyString; } template diff --git a/src/utils/constexpr_optional.hpp b/src/utils/constexpr_optional.hpp index f3f7a5e3..02c360ad 100644 --- a/src/utils/constexpr_optional.hpp +++ b/src/utils/constexpr_optional.hpp @@ -29,6 +29,10 @@ struct ConstexprOptional using value_type = T; T value_; bool has_value_; + constexpr ConstexprOptional() noexcept + : value_(T{}), has_value_(false) + { + } constexpr ConstexprOptional(const T& value) noexcept : value_(value), has_value_(true) { diff --git a/src/utils/constexpr_string.hpp b/src/utils/constexpr_string.hpp index d102d617..18627026 100644 --- a/src/utils/constexpr_string.hpp +++ b/src/utils/constexpr_string.hpp @@ -69,6 +69,9 @@ struct ConstexprString return string == lhs; } }; + +constexpr ConstexprString<1> kEmptyString{}; + template ConstexprString(char const (&)[n]) -> ConstexprString; diff --git a/utests/openapi/json/parse/datetime.cpp b/utests/openapi/json/parse/datetime.cpp index f26d9992..422a0689 100644 --- a/utests/openapi/json/parse/datetime.cpp +++ b/utests/openapi/json/parse/datetime.cpp @@ -12,7 +12,7 @@ using namespace openapi; -UTEST(Openapi_Json_Parse, BasicUuid) +UTEST(Openapi_Json_Parse, BasicDatetime) { //2011-08-12T20:17:46.384Z