CommonLib
Loading...
Searching...
No Matches
expr.h
Go to the documentation of this file.
1#pragma once
2
3#include <tuple>
4#include <type_traits>
5
6namespace hedgedev::csl::ut::expr
7{
8 ///
9 /// Gets the type of an element inside a parameter pack.
10 ///
11 /// \tparam index The index of the element.
12 /// \tparam T_args The parameter pack.
13 ///
14 template <size_t index, typename... T_args>
16
17 ///
18 /// Checks if an enum instance has a bit flag set.
19 ///
20 /// \tparam T The enum type.
21 ///
22 /// \param in_mask The enum instance.
23 /// \param in_flag The flag to check.
24 ///
25 template <class T, typename = std::enable_if_t<std::is_enum_v<T>>>
26 inline constexpr bool has_flag(T in_mask, T in_flag);
27
28 ///
29 /// Checks if all of the specified template types are the same type.
30 ///
31 /// \tparam T_first The first type.
32 /// \tparam T_args The remaining types.
33 ///
34 /// \returns `true` if all of the specified template types are the same.
35 /// Otherwise, `false`.
36 ///
37 template <typename T_first, typename... T_args>
39
40 ///
41 /// Checks if a template type supports specific template parameters.
42 ///
43 /// \tparam T_base The template type to check.
44 ///
45 template <typename, template <typename...> class T_base>
46 inline constexpr bool is_supported_template_v = false;
47
48 ///
49 /// Checks if a template type supports specific template parameters.
50 ///
51 /// \tparam T_base The template type to check.
52 /// \tparam T_args The template parameters to check.
53 ///
54 template <template <typename...> class T_base, typename... T_args>
55 inline constexpr bool is_supported_template_v<T_base<T_args...>, T_base> = true;
56
57 ///
58 /// Gets a fundamental size type inferred from the specified size.
59 ///
60 /// \tparam size The size of the type to get.
61 ///
62 /// \remarks For unsigned types, use the `unsigned` keyword before the declaration.
63 ///
64 template <size_t size = sizeof(size_t), bool is_signed = false>
65 requires (size <= 8)
68 std::conditional_t<(size > 1 && size <= 2),
70 std::conditional_t<(size > 2 && size <= 4),
72 std::conditional_t<(size > 4 && size <= 8),
74 size_t>>>>;
75}
76
77#include "expr.inl"
78#include "container_expr.h"
79#include "encoding_expr.h"
80#include "string_expr.h"
Definition string_expr.h:92
Definition string_expr.h:116
Definition string_expr.h:122
Definition string_expr.h:110
Definition string_expr.h:104
Definition string_expr.h:98
Definition container_expr.h:21
Definition string_expr.h:74
Definition string_expr.h:38
Definition string_expr.h:56
Definition string_expr.h:62
Definition string_expr.h:50
Definition string_expr.h:44
Definition container_expr.h:15
Definition this_process_win32.inl:13
std::filesystem::path get_executable_root()
Definition this_process.inl:7
bool is_neighbour(const std::filesystem::path &in_path)
Definition this_process.inl:12
constexpr bool is_all_same_v
Definition expr.h:38
constexpr bool is_same_underlying_char_type_v
Definition string_expr.h:128
constexpr size_t get_string_type_precedence()
Definition string_expr.inl:23
constexpr T_result create_inferred_string(const T_str &in_str)
Definition string_expr.inl:6
constexpr bool is_supported_template_v
Definition expr.h:46
Definition filesystem.h:6
std::error_code truncate_files_by_age(const std::filesystem::path &in_path, std::string_view in_extension, size_t in_max=10)
Definition filesystem.inl:46
bool is_neighbour(const std::filesystem::path &in_left, const std::filesystem::path &in_right)
Definition filesystem.inl:7
std::error_code truncate_files(const std::filesystem::path &in_path, std::string_view in_extension, size_t in_max, T &&in_compare_func)
Definition filesystem.inl:13
Definition string.h:11
expr::inferred_string_t< T_str > trim_start(const T_str &in_str, std::optional< std::vector< T_trim_chars > > in_trim_chars={})
Definition string.inl:326
expr::inferred_string_t< T > format(const T in_str,...)
Definition string.inl:82
expr::inferred_string_t< T > lower(const T &in_str)
Definition string.inl:288
expr::inferred_string_t< T_str > trim(const T_str &in_str, std::optional< std::vector< T_trim_chars > > in_trim_chars={})
Definition string.inl:365
bool is_null_or_empty(const T &in_str)
Definition string.inl:160
T_result hyperlink(const T_str &in_str, const T_url &in_url)
Definition string.inl:140
expr::inferred_string_t< T_str > remove_xml_tags(const T_str &in_str)
Definition string.inl:247
bool is_null_or_whitespace(const T &in_str)
Definition string.inl:172
expr::inferred_string_t< T_str > trim_end(const T_str &in_str, std::optional< std::vector< T_trim_chars > > in_trim_chars={})
Definition string.inl:345
expr::inferred_string_t< T_str > wrap(const T_str &in_str, size_t in_max_width)
Definition string.inl:505
bool compare(const T_left &in_left, const T_right &in_right, bool in_case_sensitive=true)
Definition string.inl:18
T_result join(const T_delimiter &in_delimiter, const T_args &... in_args)
Definition string.inl:214
std::vector< T_result > split(const T_str &in_str, const T_delimiter &in_delimiter)
Definition string.inl:257
expr::inferred_string_t< T > upper(const T &in_str)
Definition string.inl:307
bool try_parse(const T_str &in_str, T_result &out_result)
Definition string.inl:447
expr::inferred_string_t< T_str > escape(const T_str &in_str, T_str_char in_search_char, T_str_char in_escape_char=T_str_char('\\'))
Definition string.inl:66
bool contains(const T_str &in_str, const T_substr &in_substr, bool in_case_sensitive=true)
Definition string.inl:35
T_result pad(const T_str &in_str, const T_pad_str &in_pad_str)
Definition string.inl:222
T_result hex(T_value in_value, size_t in_max_length=sizeof(size_t) *2, bool in_prefix=true)
Definition string.inl:420
T_result parse(const T_str &in_str)
Definition string.inl:237
size_t get_width(const T &in_str)
Definition string.inl:126
expr::inferred_string_t< T > truncate(const T &in_str, size_t in_max_length, bool in_truncate_end=true, bool in_ellipsis=true)
Definition string.inl:371
expr::inferred_string_t< T_strings > join(const T_delimiter &in_delimiter, const std::vector< T_strings > &in_strings)
Definition string.inl:186
Definition expr.h:7
Definition string_expr.h:19
Definition string_expr.h:65