summaryrefslogtreecommitdiff
path: root/src/gen_ugc.cc
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2025-09-15 21:15:53 +0200
committerJoel Klinghed <the_jk@spawned.biz>2025-09-15 21:15:53 +0200
commitaa49abdf239bae6065fddd0839ec67a404c9748c (patch)
tree631fbb2df58aa35df3d60c65c037ef74b1807114 /src/gen_ugc.cc
parentbf41a601fd0447bcf3a2937a595a1cd8ca5c1633 (diff)
Add .clang-format
Make it easier to keep a consistent style
Diffstat (limited to 'src/gen_ugc.cc')
-rw-r--r--src/gen_ugc.cc60
1 files changed, 30 insertions, 30 deletions
diff --git a/src/gen_ugc.cc b/src/gen_ugc.cc
index 7583272..bc7c91b 100644
--- a/src/gen_ugc.cc
+++ b/src/gen_ugc.cc
@@ -165,17 +165,17 @@ std::expected<std::pair<uint32_t, u::GeneralCategory>, std::string> parse_row(
auto category_col = row[2];
uint32_t code;
- auto [ptr, ec] = std::from_chars(code_col.data(),
- code_col.data() + code_col.size(), code,
- /* base */ 16);
+ auto [ptr, ec] =
+ std::from_chars(code_col.data(), code_col.data() + code_col.size(), code,
+ /* base */ 16);
if (ec != std::errc() || ptr != code_col.data() + code_col.size()) {
return std::unexpected(std::format("Invalid code value {}", code_col));
}
u::GeneralCategory category;
auto it = str2gc.find(category_col);
if (it == str2gc.end()) {
- return std::unexpected(std::format("Invalid general category {}",
- category_col));
+ return std::unexpected(
+ std::format("Invalid general category {}", category_col));
}
category = it->second;
@@ -186,9 +186,9 @@ std::expected<std::map<uint32_t, u::GeneralCategory>, std::string> read(
std::string_view filename) {
auto maybe_reader = io::open(std::string(filename));
if (!maybe_reader.has_value()) {
- return std::unexpected(std::format(
- "Unable to open {} for reading: {}",
- filename, ioerr2str(maybe_reader.error())));
+ return std::unexpected(std::format("Unable to open {} for reading: {}",
+ filename,
+ ioerr2str(maybe_reader.error())));
}
auto reader = std::move(maybe_reader.value());
if (filename.ends_with(".gz")) {
@@ -202,17 +202,17 @@ std::expected<std::map<uint32_t, u::GeneralCategory>, std::string> read(
while (true) {
auto row = csv_reader->read();
if (!row.has_value()) {
- return std::unexpected(std::format(
- "{}:{}: Error reading file: {}",
- filename, csv_reader->number(), ioerr2str(row.error())));
+ return std::unexpected(std::format("{}:{}: Error reading file: {}",
+ filename, csv_reader->number(),
+ ioerr2str(row.error())));
}
if (row->empty())
break;
auto pair = parse_row(row.value());
if (!pair.has_value()) {
- return std::unexpected(std::format(
- "{}:{}: {}", filename, csv_reader->number(), pair.error()));
+ return std::unexpected(std::format("{}:{}: {}", filename,
+ csv_reader->number(), pair.error()));
}
auto name_col = (*row)[1];
@@ -220,15 +220,15 @@ std::expected<std::map<uint32_t, u::GeneralCategory>, std::string> read(
std::string prefix(name_col.substr(0, name_col.size() - 8));
row = csv_reader->read();
if (!row.has_value()) {
- return std::unexpected(std::format(
- "{}:{}: Error reading file: {}",
- filename, csv_reader->number(), ioerr2str(row.error())));
+ return std::unexpected(std::format("{}:{}: Error reading file: {}",
+ filename, csv_reader->number(),
+ ioerr2str(row.error())));
}
auto second_pair = parse_row(row.value());
if (!pair.has_value()) {
- return std::unexpected(std::format(
- "{}:{}: {}", filename, csv_reader->number(), pair.error()));
+ return std::unexpected(std::format("{}:{}: {}", filename,
+ csv_reader->number(), pair.error()));
}
name_col = (*row)[1];
@@ -236,29 +236,29 @@ std::expected<std::map<uint32_t, u::GeneralCategory>, std::string> read(
name_col.substr(0, name_col.size() - 7) == prefix) {
if (pair->second != second_pair->second) {
return std::unexpected(std::format(
- "{}:{}: Invalid range, general category doesn't match",
- filename, csv_reader->number()));
+ "{}:{}: Invalid range, general category doesn't match", filename,
+ csv_reader->number()));
}
for (uint32_t c = pair->first; c <= second_pair->first; ++c) {
auto emplace_ret = ret.emplace(c, pair->second);
if (!emplace_ret.second) {
- return std::unexpected(std::format(
- "{}:{}: Duplicate value for {:#08x}",
- filename, csv_reader->number(), c));
+ return std::unexpected(
+ std::format("{}:{}: Duplicate value for {:#08x}", filename,
+ csv_reader->number(), c));
}
}
} else {
- return std::unexpected(std::format(
- "{}:{}: Invalid range, {} doesn't match {}",
- filename, csv_reader->number(), prefix, name_col));
+ return std::unexpected(
+ std::format("{}:{}: Invalid range, {} doesn't match {}", filename,
+ csv_reader->number(), prefix, name_col));
}
} else {
auto emplace_ret = ret.emplace(std::move(pair.value()));
if (!emplace_ret.second) {
- return std::unexpected(std::format(
- "{}:{}: Duplicate value for {:#08x}",
- filename, csv_reader->number(), emplace_ret.first->first));
+ return std::unexpected(std::format("{}:{}: Duplicate value for {:#08x}",
+ filename, csv_reader->number(),
+ emplace_ret.first->first));
}
}
}
@@ -310,7 +310,7 @@ int main(int argc, char** argv) {
print_footer(std::cout, prefix);
} else {
std::fstream out{std::string(arguments[1]),
- std::fstream::trunc | std::fstream::out};
+ std::fstream::trunc | std::fstream::out};
print_header(out, prefix);
print_body(out, general_categories.value());
print_footer(out, prefix);