CommonLib
Loading...
Searching...
No Matches
string_expr.h
Go to the documentation of this file.
1#pragma once
2
3#include <concepts>
4#include <fstream>
5#include <ranges>
6#include <sstream>
7#include <string>
8#include <tuple>
9#include <type_traits>
10
11#include "container_expr.h"
12
13namespace hedgedev::csl::ut::expr
14{
15 ///
16 /// Gets the character type of a non-range type.
17 ///
18 template <typename T>
20
21 ///
22 /// Gets the character type of a range type.
23 ///
24 template <typename T>
26 struct get_char_type<T> { using type = std::ranges::range_value_t<T>; };
27
28 ///
29 /// Gets the character type of a string container.
30 ///
31 template <typename T>
33
34 ///
35 /// A multibyte C string type.
36 ///
37 template <typename T>
39
40 ///
41 /// A wide C string type.
42 ///
43 template <typename T>
45
46 ///
47 /// An 8-bit C string type.
48 ///
49 template <typename T>
51
52 ///
53 /// A 16-bit C string type.
54 ///
55 template <typename T>
57
58 ///
59 /// A 32-bit C string type.
60 ///
61 template <typename T>
63
64 template <typename T>
66
67 template <typename T_char, typename T_traits, typename T_alloc>
68 struct is_basic_string<std::basic_string<T_char, T_traits, T_alloc>> : std::true_type {};
69
70 ///
71 /// An `std::basic_string` type.
72 ///
73 template <typename T>
75
76 template <typename T>
78
79 template <typename T_char, typename T_traits>
81
82 ///
83 /// An `std::basic_string_view` type.
84 ///
85 template <typename T>
87
88 ///
89 /// Any raw string type.
90 ///
91 template <typename T>
93
94 ///
95 /// Any string type.
96 ///
97 template <typename T>
99
100 ///
101 /// A wide C string or `std::wstring` type.
102 ///
103 template <typename T>
105
106 ///
107 /// An 8-bit C string or `std::u8string` type.
108 ///
109 template <typename T>
111
112 ///
113 /// A 16-bit C string or `std::u16string` type.
114 ///
115 template <typename T>
117
118 ///
119 /// A 32-bit C string or `std::u32string` type.
120 ///
121 template <typename T>
123
124 ///
125 /// Checks if the underlying type of two given string types are the same.
126 ///
129
130 ///
131 /// An `std::basic_string` inferred from any string type.
132 ///
133 template <any_string T>
135
136 ///
137 /// An `std::basic_string_view` inferred from any string type.
138 ///
139 template <any_string T>
141
142 ///
143 /// An `std::basic_stringstream` inferred from any string type.
144 ///
145 template <any_string T>
147
148 ///
149 /// An `std::basic_fstream` inferred from any string type.
150 ///
151 template <any_string T>
153
154 ///
155 /// Creates a string inferred from a string literal at compile time.
156 ///
157 /// \tparam T_result The string type to create.
158 /// \tparam T_str The string type to convert from.
159 ///
160 /// \param in_str The string to create.
161 ///
162 /// \returns The input string in the destination format.
163 ///
164 template <any_string T_result, any_string T_str>
165 inline constexpr T_result create_inferred_string(const T_str& in_str);
166
167 ///
168 /// Determines which string type has the largest character size.
169 ///
170 /// \returns The index of the string type with the largest character size.
171 ///
172 template <any_string... T_args>
173 inline constexpr size_t get_string_type_precedence();
174
175 ///
176 /// Evaluates the string type with the largest character size.
177 ///
178 template <any_string... T_args>
180
181 ///
182 /// An `std::basic_string` inferred from the string type with the largest
183 /// character size.
184 ///
185 template <any_string... T_args>
187
188 ///
189 /// An `std::basic_string_view` inferred from the string type with the largest
190 /// character size.
191 ///
192 template <any_string... T_args>
194
195 ///
196 /// An `std::basic_stringstream` inferred from the string type with the largest
197 /// character size.
198 ///
199 template <any_string... T_args>
201}
202
203#include "string_expr.inl"
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 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 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_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
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