Skip to content

Commit 299e704

Browse files
committed
Removed U8() to raw string
1 parent 6dbe849 commit 299e704

81 files changed

Lines changed: 504 additions & 531 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/abi/memory.ixx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
* THE SOFTWARE.
2121
*/
2222

23+
module;
24+
2325
#include <essence/compat.hpp>
2426

2527
export module essence.basic:abi.memory;

src/cli/arg_parser.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ namespace essence::cli {
3434
constexpr meta::fingerprint boolean_type_id{std::type_identity<bool>{}};
3535

3636
const auto help_option = option<bool>{}
37-
.set_bound_name(U8("help"))
38-
.set_description(U8("Show this help."))
39-
.add_aliases(U8("h"), U8("?"))
37+
.set_bound_name("help")
38+
.set_description("Show this help.")
39+
.add_aliases("h", "?")
4040
.as_abstract();
4141

4242
constexpr std::pair<bool, bool> check_option_prefix(std::string_view name) noexcept {
@@ -100,12 +100,12 @@ namespace essence::cli {
100100

101101
void show_help() const {
102102
on_output_.try_invoke(common_tokens::fixed_help_content);
103-
on_output_.try_invoke(format(common_tokens::help_option_header_pattern, U8("Option"), U8("Value"),
104-
U8("Default"), U8("Description")));
103+
on_output_.try_invoke(
104+
format(common_tokens::help_option_header_pattern, "Option", "Value", "Default", "Description"));
105105

106106
for (auto&& item : options_) {
107107
on_output_.try_invoke(format(common_tokens::help_option_header_pattern, item.name_hints(),
108-
item.value_hints(), item.default_value_str().value_or(U8("`mandatory`")), item.description()));
108+
item.value_hints(), item.default_value_str().value_or("`mandatory`"), item.description()));
109109
}
110110
}
111111

@@ -163,7 +163,7 @@ namespace essence::cli {
163163
for (auto&& item : adapter) {
164164
// Outputs the missing options.
165165
if (!item.default_value_str()) {
166-
on_error_.try_invoke(format(U8("Missing mandatory option: {}."), item.name_hints()));
166+
on_error_.try_invoke(format("Missing mandatory option: {}.", item.name_hints()));
167167
success_ = false;
168168
}
169169

@@ -213,7 +213,7 @@ namespace essence::cli {
213213
bool validate_option(std::string_view& value, bool single, bool boolean, const abstract::option& option) const {
214214
// If combined abbreviations are specified, all types of the options must be bool.
215215
if (!single && !boolean) {
216-
on_error_.try_invoke(U8("All types of combined abbreviations must be bool."));
216+
on_error_.try_invoke("All types of combined abbreviations must be bool.");
217217

218218
return false;
219219
}
@@ -235,7 +235,7 @@ namespace essence::cli {
235235
const auto index = arg.find(common_tokens::equal);
236236

237237
return std::pair{
238-
trim(arg.substr(0, index)), index == std::string_view::npos ? U8("") : trim(arg.substr(index + 1))};
238+
trim(arg.substr(0, index)), index == std::string_view::npos ? "" : trim(arg.substr(index + 1))};
239239
}();
240240

241241
auto&& [has_option_prefix, has_option_abbreviation_prefix] = check_option_prefix(name);
@@ -250,7 +250,7 @@ namespace essence::cli {
250250
// Options like -xyz=abc is illegal.
251251
if (has_option_abbreviation_prefix && name.size() > 2 && !value.empty()) {
252252
on_error_.try_invoke(
253-
format(U8("Explicitly assigning values to combined abbreviations is not allowed: {}."), arg));
253+
format("Explicitly assigning values to combined abbreviations is not allowed: {}.", arg));
254254

255255
return args_.size();
256256
}
@@ -272,16 +272,16 @@ namespace essence::cli {
272272

273273
// --option true/false is omitted.
274274
if (any_boolean && next_as_value) {
275-
value = U8("");
275+
value = "";
276276
}
277277

278278
if (!validate_option(value, single, boolean, option)) {
279279
return args_.size();
280280
}
281281

282282
if (!option.parse_value_and_cache(value)) {
283-
on_error_.try_invoke(format(U8("When parsing the command line argument: {}."), arg));
284-
on_error_.try_invoke(format(U8("Matched option: {}."), option.name_hints()));
283+
on_error_.try_invoke(format("When parsing the command line argument: {}.", arg));
284+
on_error_.try_invoke(format("Matched option: {}.", option.name_hints()));
285285

286286
return args_.size();
287287
}

src/cli/common_tokens.cxx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ import std;
3030

3131
namespace essence::cli {
3232
struct common_tokens {
33-
static constexpr std::string_view underscore{U8("_")};
34-
static constexpr std::string_view option_name_prefix{U8("--")};
35-
static constexpr std::string_view option_abbreviation_prefix{U8("-")};
36-
static constexpr std::string_view equal{U8("=")};
37-
static constexpr std::string_view fixed_help_content{U8(R"(Passing parameters:
33+
static constexpr std::string_view underscore{"_"};
34+
static constexpr std::string_view option_name_prefix{"--"};
35+
static constexpr std::string_view option_abbreviation_prefix{"-"};
36+
static constexpr std::string_view equal{"="};
37+
static constexpr std::string_view fixed_help_content{R"(Passing parameters:
3838
3939
--opt1[=]<value>
4040
--opt2[=]<value1>,<value2>,<value>,...
@@ -44,7 +44,7 @@ namespace essence::cli {
4444
-s3[[=]true|false]
4545
4646
Available options:
47-
)")};
48-
static constexpr std::string_view help_option_header_pattern{U8("{:<32} {:<28} {:<28} {:<32}")};
47+
)"};
48+
static constexpr std::string_view help_option_header_pattern{"{:<32} {:<28} {:<28} {:<32}"};
4949
};
5050
} // namespace essence::cli

src/cli/option.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ namespace essence::cli {
112112
}
113113

114114
[[nodiscard]] abi::string name_hints() const {
115-
return aliases_ | std::views::join_with(std::string_view{U8(",")}) | std::ranges::to<abi::string>();
115+
return aliases_ | std::views::join_with(std::string_view{","}) | std::ranges::to<abi::string>();
116116
}
117117

118118
[[nodiscard]] static abi::string value_hints() {

src/cli/option.ixx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ export namespace essence::cli {
5252
using element_type = std::conditional_t<std_basic_string<T>, T, range_value_t_or_self_t<T>>;
5353
using set_hash_type = std::conditional_t<std_basic_string<element_type>, string_hash, std::hash<element_type>>;
5454

55-
static constexpr std::string_view delimiter{U8(",")};
56-
static constexpr std::string_view optional_pattern{U8("[]")};
57-
static constexpr std::string_view keyword_pattern{U8("``")};
55+
static constexpr std::string_view delimiter{","};
56+
static constexpr std::string_view optional_pattern{"[]"};
57+
static constexpr std::string_view keyword_pattern{"``"};
5858
static constexpr meta::fingerprint type_id{std::type_identity<T>{}};
5959

6060
/**
@@ -159,7 +159,7 @@ export namespace essence::cli {
159159
}
160160

161161
if (!success) {
162-
raise_error(U8("Invalid value."));
162+
raise_error("Invalid value.");
163163

164164
return success;
165165
}
@@ -291,8 +291,8 @@ export namespace essence::cli {
291291
const auto values =
292292
valid_value_strs_ | std::views::join_with(delimiter) | std::ranges::to<abi::string>();
293293

294-
raise_error(U8("The value was out of range."));
295-
raise_error(U8("One of the following values is allowed:"));
294+
raise_error("The value was out of range.");
295+
raise_error("One of the following values is allowed:");
296296
raise_error(values);
297297
}
298298
}
@@ -302,7 +302,7 @@ export namespace essence::cli {
302302
if ((success = inner.has_value())) {
303303
validate_range(*inner, success);
304304
} else {
305-
raise_error(U8("Invalid value."));
305+
raise_error("Invalid value.");
306306
}
307307

308308
return success;

src/crypto/asymmetric_key.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ namespace essence::crypto {
5050
EVP_PKEY* load_key_impl(Tag, BIO* bio, const password_request_handler& handler) {
5151
static constexpr auto pair = [] {
5252
if constexpr (std::same_as<Tag, use_public_tag>) {
53-
return std::pair{U8("Public Key"), &PEM_read_bio_PUBKEY};
53+
return std::pair{"Public Key", &PEM_read_bio_PUBKEY};
5454
} else {
55-
return std::pair{U8("Private Key"), &PEM_read_bio_PrivateKey};
55+
return std::pair{"Private Key", &PEM_read_bio_PrivateKey};
5656
}
5757
}();
5858

@@ -83,14 +83,14 @@ namespace essence::crypto {
8383
return result;
8484
}
8585

86-
throw crypto_error{U8("Category"), pair.first, U8("Message"), U8("Failed to load the key from the BIO.")};
86+
throw crypto_error{"Category", pair.first, "Message", "Failed to load the key from the BIO."};
8787
}
8888

8989
template <typename Tag>
9090
void save_key_impl(
9191
Tag, BIO* bio, const EVP_PKEY* blob, conditional_encrypted_key_info<Tag> encrypted_key_info) {
9292
static constexpr std::string_view category{
93-
std::same_as<Tag, use_public_tag> ? U8("Public Key") : U8("Private Key")};
93+
std::same_as<Tag, use_public_tag> ? "Public Key" : "Private Key"};
9494

9595
// The write routines return 1 for success or 0 for failure.
9696
if (auto code =
@@ -108,18 +108,18 @@ namespace essence::crypto {
108108
static_cast<std::int32_t>(encrypted_key_info->password.size()), nullptr, nullptr);
109109
}
110110

111-
throw crypto_error{U8("Category"), category, U8("Cipher"), encrypted_key_info->cipher_name,
112-
U8("Message"), U8("Failed to find the symmetric cipher.")};
111+
throw crypto_error{"Category", category, "Cipher", encrypted_key_info->cipher_name,
112+
"Message", "Failed to find the symmetric cipher."};
113113
}
114114
}();
115115
code != 1) {
116-
throw crypto_error{U8("Category"), category, U8("Message"), U8("Failed to save the key into the BIO.")};
116+
throw crypto_error{"Category", category, "Message", "Failed to save the key into the BIO."};
117117
}
118118
}
119119

120120
template <typename Tag>
121121
EVP_PKEY* load_key(Tag tag, zstring_view path, const password_request_handler& handler) {
122-
const auto bio = make_file_bio_unique(path, U8("rb"));
122+
const auto bio = make_file_bio_unique(path, "rb");
123123

124124
return load_key_impl(tag, bio.get(), handler);
125125
}
@@ -134,7 +134,7 @@ namespace essence::crypto {
134134
template <typename Tag>
135135
void save_key(
136136
Tag tag, zstring_view path, const EVP_PKEY* blob, conditional_encrypted_key_info<Tag> cipher_info = {}) {
137-
const auto bio = make_file_bio_unique(path, U8("wb"));
137+
const auto bio = make_file_bio_unique(path, "wb");
138138

139139
save_key_impl(tag, bio.get(), blob, cipher_info);
140140
}
@@ -155,8 +155,8 @@ namespace essence::crypto {
155155
class asymmetric_key::impl {
156156
public:
157157
explicit impl(void* blob)
158-
: blob_{blob ? static_cast<EVP_PKEY*>(blob)
159-
: throw formatted_runtime_error{U8("The blob must be non-null.")}} {}
158+
: blob_{blob ? static_cast<EVP_PKEY*>(blob) : throw formatted_runtime_error{"The blob must be non-null."}} {
159+
}
160160

161161
[[nodiscard]] EVP_PKEY* blob() const noexcept {
162162
return blob_.get();

src/crypto/chunk_processing_helper.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace essence::crypto {
4444
check_error(
4545
raw_update(context, reinterpret_cast<std::uint8_t*>(output.data()), &size,
4646
reinterpret_cast<const std::uint8_t*>(input.data()), static_cast<std::int32_t>(input.size())),
47-
U8("An error occurred during the update."));
47+
"An error occurred during the update.");
4848

4949
output = output.subspan(0, size);
5050
}
@@ -60,7 +60,7 @@ namespace essence::crypto {
6060
}
6161
}();
6262

63-
check_error(result, U8("An error occurred during the finalization."));
63+
check_error(result, "An error occurred during the finalization.");
6464
output = output.subspan(0, size);
6565
}
6666
};

src/crypto/chunk_processor.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,16 @@ namespace essence::crypto {
4242
class chain_processor {
4343
public:
4444
explicit chain_processor(std::span<abstract::chunk_processor> processors)
45-
: buffer_pair_{processors.size() < 2
46-
? throw formatted_runtime_error{U8(
47-
"At least two processors are required to be chained together.")}
48-
: calculate_max_buffer_size(processors)},
45+
: buffer_pair_{processors.size() < 2 ? throw formatted_runtime_error{"At least two processors are "
46+
"required to be chained together."}
47+
: calculate_max_buffer_size(processors)},
4948
finalization_buffer_{make_unique_array<std::byte>(buffer_pair_.buffer->size())},
5049
swapper_{buffer_pair_.in, buffer_pair_.out} {
5150
if (std::ranges::adjacent_find(
5251
processors, std::not_equal_to{}, [](const auto& inner) { return inner.transformer(); })
5352
!= processors.end()) {
5453
throw formatted_runtime_error{
55-
U8("All processors must be either transformers or inverse transformers at the same time.")};
54+
"All processors must be either transformers or inverse transformers at the same time."};
5655
}
5756

5857
processors_.reserve(processors.size());
@@ -64,7 +63,7 @@ namespace essence::crypto {
6463
}
6564

6665
[[nodiscard]] [[maybe_unused]] static abi::string cipher_name() {
67-
return U8("chain");
66+
return "chain";
6867
}
6968

7069
[[nodiscard]] [[maybe_unused]] std::size_t buffer_size() const noexcept {

src/crypto/chunk_processor_base64.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ namespace essence::crypto {
3737
constexpr auto encode_ctx_deleter = [](EVP_ENCODE_CTX* inner) { EVP_ENCODE_CTX_free(inner); };
3838

3939
const cipher_error_builder encoding_builder{
40-
.cipher_name = U8("base64"),
41-
.routine_name = U8("Encoding"),
40+
.cipher_name = "base64",
41+
.routine_name = "Encoding",
4242
};
4343

4444
const cipher_error_builder decoding_builder{
45-
.cipher_name = U8("base64"),
46-
.routine_name = U8("Decoding"),
45+
.cipher_name = "base64",
46+
.routine_name = "Decoding",
4747
};
4848

4949
const chunk_processing_helper base64_encoding_helper{
@@ -71,7 +71,7 @@ namespace essence::crypto {
7171
return context;
7272
}
7373

74-
throw formatted_runtime_error{U8("Failed to allocate the base64 encoding context.")};
74+
throw formatted_runtime_error{"Failed to allocate the base64 encoding context."};
7575
}()},
7676
helper_{[]() -> const auto& {
7777
if constexpr (Encoder) {

src/crypto/chunk_processor_symmetric_cipher.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace essence::crypto {
4242
: encryption_{encryption}, padding_mode_{padding_mode},
4343
builder_{
4444
.cipher_name = abi::string{cipher_name},
45-
.routine_name = encryption ? U8("Encrytion") : U8("Decryption"),
45+
.routine_name = encryption ? "Encrytion" : "Decryption",
4646
},
4747
helper_{
4848
.raw_update = &EVP_CipherUpdate,
@@ -53,31 +53,30 @@ namespace essence::crypto {
5353
context_{EVP_CIPHER_CTX_new()} {
5454

5555
if (builder_.cipher_name.empty()) {
56-
builder_.raise_error(U8("The cipher name must be non-empty."));
56+
builder_.raise_error("The cipher name must be non-empty.");
5757
}
5858

5959
auto cipher_info = get_symmetric_cipher_info(cipher_name);
6060

6161
if (!cipher_info) {
62-
builder_.raise_error(U8("Could not find the cipher name."));
62+
builder_.raise_error("Could not find the cipher name.");
6363
}
6464

6565
if (key.size() != cipher_info->key_length) {
66-
builder_.raise_error(U8("Expected Key Length"), cipher_info->key_length, U8("Actual Key Length"),
67-
key.size(), U8("Message"),
68-
U8("The actual key length must be equal to the expected key length of the cipher."));
66+
builder_.raise_error("Expected Key Length", cipher_info->key_length, "Actual Key Length",
67+
key.size(), "Message",
68+
"The actual key length must be equal to the expected key length of the cipher.");
6969
}
7070

7171
if (iv.size() != cipher_info->iv_length) {
72-
builder_.raise_error(U8("Expected IV Length"), cipher_info->iv_length, U8("Actual IV Length"),
73-
iv.size(), U8("Message"),
74-
U8("The actual IV length must be equal to the expected IV length of the cipher."));
72+
builder_.raise_error("Expected IV Length", cipher_info->iv_length, "Actual IV Length", iv.size(),
73+
"Message", "The actual IV length must be equal to the expected IV length of the cipher.");
7574
}
7675

7776
builder_.check_error(EVP_CipherInit_ex(context_.get(), static_cast<const EVP_CIPHER*>(cipher_info->id),
7877
nullptr, reinterpret_cast<const std::uint8_t*>(key.data()),
7978
reinterpret_cast<const std::uint8_t*>(iv.data()), encryption),
80-
U8("An error occurred during the initialization."));
79+
"An error occurred during the initialization.");
8180
}
8281

8382
[[nodiscard]] [[maybe_unused]] bool transformer() const noexcept {
@@ -102,7 +101,7 @@ namespace essence::crypto {
102101

103102
[[maybe_unused]] void init() const {
104103
builder_.check_error(EVP_CipherInit_ex(context_.get(), nullptr, nullptr, nullptr, nullptr, encryption_),
105-
U8("An error occurred during the re-initialization."));
104+
"An error occurred during the re-initialization.");
106105

107106
// Always succeeds.
108107
// https://www.openssl.org/docs/man1.0.2/man3/EVP_CIPHER_CTX_set_padding.html

0 commit comments

Comments
 (0)