generated from userver-framework/service_template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
458f048
commit b434b32
Showing
24 changed files
with
1,514 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
// Используйте IntelliSense, чтобы узнать о возможных атрибутах. | ||
// Наведите указатель мыши, чтобы просмотреть описания существующих атрибутов. | ||
// Для получения дополнительной информации посетите: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "lldb", | ||
"request": "launch", | ||
"name": "Debug", | ||
"program": "${workspaceFolder}/<executable file>", | ||
"args": [], | ||
"cwd": "${workspaceFolder}" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
|
||
#include <optional> | ||
#include <vector> | ||
|
||
#include "property_base.hpp" | ||
|
||
namespace timetable_vsu_backend::openapi | ||
{ | ||
template <typename T, typename Traits = EmptyTraits> | ||
struct ArrayProperty : public PropertyBase<std::vector<T>, Traits> | ||
{ | ||
}; | ||
|
||
template <typename T, typename Traits> | ||
struct Property<std::vector<T>, Traits> : public ArrayProperty<T, Traits> | ||
{ | ||
}; | ||
|
||
} // namespace timetable_vsu_backend::openapi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
#pragma once | ||
|
||
#include "array_property.hpp" | ||
#include "named_traits.hpp" | ||
#include "preferences.hpp" | ||
#include "utils/constexpr_optional.hpp" | ||
#include "utils/constexpr_string.hpp" | ||
namespace timetable_vsu_backend::openapi | ||
{ | ||
namespace checks | ||
{ | ||
template <typename T> | ||
concept HasMin = requires | ||
{ | ||
{ | ||
T::kMin | ||
} | ||
->std::convertible_to<utils::ConstexprOptional<size_t>>; | ||
}; | ||
|
||
template <typename T> | ||
concept HasMax = requires | ||
{ | ||
{ | ||
T::kMax | ||
} | ||
->std::convertible_to<utils::ConstexprOptional<size_t>>; | ||
}; | ||
|
||
template <typename T> | ||
concept HasUniqueItems = requires | ||
{ | ||
{ | ||
T::kUniqueItems | ||
} | ||
->std::convertible_to<utils::ConstexprOptional<bool>>; | ||
}; | ||
|
||
template <typename T> | ||
concept HasNotMin = !HasMin<T>; | ||
|
||
template <typename T> | ||
concept HasNotMax = !HasMax<T>; | ||
|
||
template <typename T> | ||
concept HasNotUniqueItems = !HasUniqueItems<T>; | ||
} // namespace checks | ||
|
||
namespace detail | ||
{ | ||
template <checks::HasMin T> | ||
constexpr auto _getMin() | ||
{ | ||
return T::kMin; | ||
} | ||
|
||
template <checks::HasNotMin T> | ||
constexpr auto _getMin() | ||
{ | ||
return utils::ConstexprOptional<size_t>{utils::kNull}; | ||
} | ||
|
||
template <checks::HasMax T> | ||
constexpr auto _getMax() | ||
{ | ||
return T::kMax; | ||
} | ||
|
||
template <checks::HasNotMax T> | ||
constexpr auto _getMax() | ||
{ | ||
return utils::ConstexprOptional<size_t>{utils::kNull}; | ||
} | ||
|
||
template <checks::HasUniqueItems T> | ||
constexpr auto _getUniqueItems() | ||
{ | ||
return T::kUniqueItems; | ||
} | ||
|
||
template <checks::HasNotUniqueItems T> | ||
constexpr auto _getUniqueItems() | ||
{ | ||
return utils::ConstexprOptional<bool>{utils::kNull}; | ||
} | ||
} // namespace detail | ||
|
||
namespace traits | ||
{ | ||
template <typename T> | ||
constexpr utils::ConstexprOptional<size_t> GetMin() | ||
{ | ||
return detail::_getMin<T>(); | ||
} | ||
template <typename T> | ||
constexpr utils::ConstexprOptional<size_t> GetMax() | ||
{ | ||
return detail::_getMax<T>(); | ||
} | ||
template <typename T> | ||
constexpr utils::ConstexprOptional<bool> GetUniqueItems() | ||
{ | ||
return detail::_getUniqueItems<T>(); | ||
} | ||
|
||
template <typename Traits> | ||
struct ArrayHelperTraits : NamedHelperTraits<Traits> | ||
{ | ||
static constexpr utils::ConstexprOptional<size_t> min = | ||
traits::GetMin<Traits>(); | ||
static constexpr utils::ConstexprOptional<size_t> max = | ||
traits::GetMax<Traits>(); | ||
static constexpr utils::ConstexprOptional<bool> unique_items = | ||
traits::GetUniqueItems<Traits>(); | ||
constexpr ArrayHelperTraits() | ||
{ | ||
} | ||
}; | ||
|
||
} // namespace traits | ||
} // namespace timetable_vsu_backend::openapi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
|
||
#include <optional> | ||
#include <vector> | ||
|
||
#include "property_base.hpp" | ||
#include "userver/formats/json/value.hpp" | ||
|
||
namespace timetable_vsu_backend::openapi | ||
{ | ||
template <checks::IsReflective T, typename Traits = EmptyTraits> | ||
struct ExtendedObjectProperty : public PropertyBase<T, Traits> | ||
{ | ||
userver::formats::json::Value additional_properties{}; | ||
const userver::formats::json::Value& GetAdditionalProperties() | ||
{ | ||
return additional_properties; | ||
} | ||
}; | ||
|
||
} // namespace timetable_vsu_backend::openapi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#pragma once | ||
#include <concepts> | ||
#include <type_traits> | ||
|
||
#include "property_base.hpp" | ||
#include "utils/constexpr_optional.hpp" | ||
#include "utils/constexpr_string.hpp" | ||
|
||
namespace timetable_vsu_backend::openapi | ||
{ | ||
template <utils::ConstexprString Name> | ||
struct NamedTraits | ||
{ | ||
static constexpr auto kName = Name; | ||
}; | ||
|
||
namespace checks | ||
{ | ||
template <typename T> | ||
concept HasName = requires | ||
{ | ||
{ | ||
decltype(T::kName)::kSize | ||
} | ||
->std::convertible_to<std::size_t>; | ||
requires std::is_same_v<utils::ConstexprString<decltype(T::kName)::kSize>, | ||
std::remove_cv_t<decltype(T::kName)>>; | ||
{ | ||
T::kName | ||
} | ||
->std::convertible_to<utils::ConstexprString<decltype(T::kName)::kSize>>; | ||
}; | ||
|
||
template <typename T> | ||
concept HasNotName = !HasName<T>; | ||
} // namespace checks | ||
|
||
namespace details | ||
{ | ||
template <checks::HasName T> | ||
constexpr auto _getName() | ||
{ | ||
return T::kName; | ||
} | ||
|
||
template <checks::HasNotName T> | ||
constexpr auto _getName() | ||
{ | ||
using Type = utils::ConstexprString<1>; | ||
return Type{""}; | ||
} | ||
} // namespace details | ||
|
||
|
||
struct ConstexprSetString{ | ||
std::array<std::string_view, 256> test; | ||
}; | ||
|
||
consteval ConstexprSetString foo (){ | ||
return {}; | ||
} | ||
|
||
namespace traits | ||
{ | ||
// returns ConstexprOptional<ConstexprString> | ||
template <typename T> | ||
constexpr auto GetName() | ||
{ | ||
return details::_getName<T>(); | ||
} | ||
|
||
template <typename Traits> | ||
struct NamedHelperTraits | ||
{ | ||
static constexpr auto name = traits::GetName<Traits>(); | ||
}; | ||
} // namespace traits | ||
} // namespace timetable_vsu_backend::openapi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#pragma once |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
|
||
#include <optional> | ||
#include <vector> | ||
|
||
#include "property_base.hpp" | ||
|
||
namespace timetable_vsu_backend::openapi | ||
{ | ||
template <checks::IsReflective T, typename Traits = EmptyTraits> | ||
struct ObjectProperty : public PropertyBase<T, Traits> | ||
{ | ||
}; | ||
|
||
template <checks::IsReflective T, typename Traits> | ||
struct Property<T, Traits> : public ObjectProperty<T, Traits> | ||
{ | ||
}; | ||
|
||
} // namespace timetable_vsu_backend::openapi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#pragma once | ||
|
||
#include "extended_object_property.hpp" | ||
#include "named_traits.hpp" | ||
#include "object_property.hpp" | ||
#include "preferences.hpp" | ||
#include "utils/constexpr_optional.hpp" | ||
#include "utils/constexpr_string.hpp" | ||
namespace timetable_vsu_backend::openapi | ||
{ | ||
namespace checks | ||
{ | ||
template <typename T> | ||
concept HasAdditionalProperties = requires | ||
{ | ||
{ | ||
T::kAdditionalProperties | ||
} | ||
->std::convertible_to<utils::ConstexprOptional<bool>>; | ||
}; | ||
|
||
template <typename T> | ||
concept HasUseRoot = requires | ||
{ | ||
{ | ||
T::kUseRoot | ||
} | ||
->std::convertible_to<utils::ConstexprOptional<bool>>; | ||
}; | ||
|
||
} // namespace checks | ||
|
||
namespace detail | ||
{ | ||
template <typename T> | ||
requires checks::HasAdditionalProperties<T> constexpr utils::ConstexprOptional< | ||
bool> | ||
_getAdditionalProperties() | ||
{ | ||
return T::kAdditionalProperties; | ||
} | ||
|
||
template <typename T> | ||
requires(!checks::HasAdditionalProperties< | ||
T>) constexpr utils::ConstexprOptional<bool> _getAdditionalProperties() | ||
{ | ||
return utils::kNull; | ||
} | ||
|
||
template <typename T> | ||
requires checks::HasUseRoot<T> constexpr utils::ConstexprOptional<bool> | ||
_getUseRoot() | ||
{ | ||
return T::kUseRoot; | ||
} | ||
|
||
template <typename T> | ||
requires(!checks::HasUseRoot<T>) constexpr utils::ConstexprOptional< | ||
bool> _getUseRoot() | ||
{ | ||
return utils::kNull; | ||
} | ||
|
||
} // namespace detail | ||
|
||
namespace traits | ||
{ | ||
template <typename T> | ||
constexpr utils::ConstexprOptional<bool> GetAdditionalProperties() | ||
{ | ||
return detail::_getAdditionalProperties<T>(); | ||
} | ||
template <typename T> | ||
constexpr utils::ConstexprOptional<bool> GetUseRoot() | ||
{ | ||
return detail::_getUseRoot<T>(); | ||
} | ||
|
||
template <typename Traits> | ||
struct ObjectHelperTraits : NamedHelperTraits<Traits> | ||
{ | ||
static constexpr utils::ConstexprOptional<bool> use_root = | ||
traits::GetUseRoot<Traits>(); | ||
static constexpr utils::ConstexprOptional<bool> additional_properties = | ||
traits::GetAdditionalProperties<Traits>(); | ||
constexpr ObjectHelperTraits() | ||
{ | ||
} | ||
}; | ||
|
||
} // namespace traits | ||
} // namespace timetable_vsu_backend::openapi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#pragma once | ||
#include "property_base.hpp" | ||
|
||
namespace timetable_vsu_backend::openapi | ||
{ | ||
template <typename T, typename Traits = EmptyTraits> | ||
struct OptionalProperty : public PropertyBase<std::optional<T>, Traits> | ||
{ | ||
}; | ||
|
||
template <typename T, typename Traits> | ||
struct Property<std::optional<T>, Traits> : public OptionalProperty<T, Traits> | ||
{ | ||
}; | ||
|
||
} // namespace timetable_vsu_backend::openapi |
Oops, something went wrong.