add is_string security

This commit is contained in:
chatlanin 2022-06-29 12:36:48 +03:00
parent bb49c6f96b
commit 7ec159ac5f
3 changed files with 26 additions and 0 deletions

View File

@ -17,6 +17,7 @@
#include "utils/utils.hpp" #include "utils/utils.hpp"
#include "security/validate_email.hpp" #include "security/validate_email.hpp"
#include "security/generate_uuid.hpp" #include "security/generate_uuid.hpp"
#include "security/is_string.hpp"
// for example // for example
int f(int a) int f(int a)
@ -200,4 +201,14 @@ int main(int argc, char *argv[])
// ec: security::generate_uuid // ec: security::generate_uuid
hack::log()(hack::security::generate_uuid()); hack::log()(hack::security::generate_uuid());
} }
{
// ec: security::is_string
std::string s {"test"};
hack::log()(hack::security::is_string<decltype ("test_string")>::value);
hack::log()(hack::security::is_string<decltype (s)>::value);
hack::log()(hack::security::is_string<decltype (123)>::value);
hack::log()(hack::security::is_string<decltype ('c')>::value);
hack::log()(hack::security::is_string<decltype ("c")>::value);
}
} }

View File

@ -2,6 +2,7 @@
namespace hack::range namespace hack::range
{ {
// являются ли числа максимум и минимум последовательности
template<typename T, typename... Args> template<typename T, typename... Args>
bool within(const T min, const T max, Args... args) bool within(const T min, const T max, Args... args)
{ {

View File

@ -0,0 +1,14 @@
#pragma once
#include <string>
#include <variant>
#include <type_traits>
namespace hack::security
{
template<typename T>
struct is_string : public std::disjunction<
std::is_same<char*, typename std::decay_t<T>>,
std::is_same<const char*, typename std::decay_t<T>>,
std::is_same<std::string, typename std::decay_t<T>>> {};
}