From d39c0913120299a0eaeae61b0a9c00b3f38fe985 Mon Sep 17 00:00:00 2001 From: lzwdgc Date: Thu, 10 Sep 2020 13:34:07 +0300 Subject: [PATCH] Update to C++20. --- src/db_add_language/db_add_language.cpp | 4 ++-- src/mmm_extractor/mmm_extractor.cpp | 2 +- src/mmo_extractor/mmo_extractor.cpp | 4 ++-- src/mmp_extractor/mmp.cpp | 4 ++-- src/mod_converter/mod_converter.cpp | 10 +++++----- sw.cpp | 8 ++++---- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/db_add_language/db_add_language.cpp b/src/db_add_language/db_add_language.cpp index 326932e..975f13c 100644 --- a/src/db_add_language/db_add_language.cpp +++ b/src/db_add_language/db_add_language.cpp @@ -219,7 +219,7 @@ static void process_lang(polygon4::Storage &s, const path &p, polygon4::String p AimKV kv1; if (db.number_of_values) { - kv1 = ::get_kv(db, get_cp(p.filename().u8string())); + kv1 = ::get_kv(db, get_cp(to_printable_string(p.filename()))); kvm.insert(kv1.begin(), kv1.end()); } }; @@ -315,7 +315,7 @@ int main(int argc, char *argv[]) #undef ADD_LANGUAGE else { - std::cerr << "No such lang: " << p.filename().u8string() << "\n"; + std::cerr << "No such lang: " << to_printable_string(p.filename()) << "\n"; continue; } } diff --git a/src/mmm_extractor/mmm_extractor.cpp b/src/mmm_extractor/mmm_extractor.cpp index 95eeb60..9d9e798 100644 --- a/src/mmm_extractor/mmm_extractor.cpp +++ b/src/mmm_extractor/mmm_extractor.cpp @@ -63,7 +63,7 @@ mmm read_mmm(const path &fn) void process_mmm(const path &fn) { auto m = read_mmm(fn); - write_mat_bmp(fn.u8string() + ".bmp", m.data.unpack_mmm()); + write_mat_bmp(path(fn) += ".bmp", m.data.unpack_mmm()); } int main(int argc, char *argv[]) diff --git a/src/mmo_extractor/mmo_extractor.cpp b/src/mmo_extractor/mmo_extractor.cpp index 5c69d4b..e46232f 100644 --- a/src/mmo_extractor/mmo_extractor.cpp +++ b/src/mmo_extractor/mmo_extractor.cpp @@ -105,7 +105,7 @@ mmo_storage read_mmo(const path &fn) void write_mmo(Storage *storage, const mmo_storage &s) { - std::string map_name = s.name.filename().stem().u8string(); + std::string map_name = to_printable_string(s.name.filename().stem()); if (!prefix.empty()) map_name = prefix + "." + map_name; std::transform(map_name.begin(), map_name.end(), map_name.begin(), ::tolower); @@ -303,7 +303,7 @@ int main(int argc, char *argv[]) std::cout << mg.name; std::cout << " " << mg.org; std::cout << " " << mg.mechanoids.size(); - std::cout << " " << file.filename().stem().u8string(); + std::cout << " " << to_printable_string(file.filename().stem()); std::cout << "\n"; } }); diff --git a/src/mmp_extractor/mmp.cpp b/src/mmp_extractor/mmp.cpp index 5e6aba5..aeb7cf9 100644 --- a/src/mmp_extractor/mmp.cpp +++ b/src/mmp_extractor/mmp.cpp @@ -393,7 +393,7 @@ void mmp::writeHeightMap() fclose(f); }; - cv::imwrite((path(filename) += ".heightmap16.png").u8string(), toCvMat(heightmap)); + cv::imwrite((const char *)to_path_string(path(filename) += ".heightmap16.png").c_str(), toCvMat(heightmap)); //write_hm(".heightmap16.r16", heightmap, sizeof(decltype(heightmap)::type)); write_hm(".heightmap32.r32", heightmap32, sizeof(decltype(heightmap32)::type)); @@ -471,7 +471,7 @@ void mmp::writeSplitColormap() const for (auto &pixel : m) pixel = pixel == color ? 0x0000FF00 : 0; std::cout << "\r[" << i << "/" << colors.size() << "] Processing color " << ss.str(); - cv::imwrite(fn.u8string(), toCvMat(m)); + cv::imwrite((const char *)to_path_string(fn).c_str(), toCvMat(m)); } } diff --git a/src/mod_converter/mod_converter.cpp b/src/mod_converter/mod_converter.cpp index 5b8106a..0cd9caa 100644 --- a/src/mod_converter/mod_converter.cpp +++ b/src/mod_converter/mod_converter.cpp @@ -87,7 +87,7 @@ auto read_model(const path &fn) if (fn.extension() == ".mod") // single block file from m2 sdk viewer { block bl; - bl.h.name = fn.stem().u8string(); + bl.h.name = to_printable_string(fn.stem()); bl.loadPayload(b); m.blocks.push_back(bl); } @@ -112,8 +112,8 @@ void convert_model(const model &m, const path &fn) { // write all if (all_formats) - m.print(fn.u8string(), AS); - m.printFbx(fn.u8string(), AS); + m.print(to_printable_string(fn), AS); + m.printFbx(to_printable_string(fn), AS); } void convert_model(const path &fn) @@ -122,7 +122,7 @@ void convert_model(const path &fn) if (stats) { - m.save(root[fn.filename().u8string()]); + m.save(root[to_printable_string(fn.filename())]); return; } @@ -159,7 +159,7 @@ int main(int argc, char *argv[]) } } else - throw std::runtime_error("No such file or directory: " + normalize_path(p)); + throw std::runtime_error("No such file or directory: " + to_printable_string(normalize_path(p))); if (stats) { diff --git a/sw.cpp b/sw.cpp index f5b87ab..75fc775 100644 --- a/sw.cpp +++ b/sw.cpp @@ -6,7 +6,7 @@ void build(Solution &s) tools += Git("https://github.com/aimrebirth/tools", "", "{v}"); auto &common = tools.addStaticLibrary("common"); - common.CPPVersion = CPPLanguageStandard::CPP17; + common += cpp20; common.setRootDirectory("src/common"); common.Public += "pub.egorpugin.primitives.filesystem-master"_dep; common.Public += "pub.egorpugin.primitives.sw.main-master"_dep; @@ -14,7 +14,7 @@ void build(Solution &s) auto add_exe = [&tools](const String &name) -> decltype(auto) { auto &t = tools.addExecutable(name); - t.CPPVersion = CPPLanguageStandard::CPP17; + t += cpp20; t.setRootDirectory("src/" + name); return t; }; @@ -47,14 +47,14 @@ void build(Solution &s) // not so simple targets auto &script2txt = tools.addStaticLibrary("script2txt"); - script2txt.CPPVersion = CPPLanguageStandard::CPP17; + script2txt += cpp20; script2txt.setRootDirectory("src/script2txt"); script2txt += "pub.lzwdgc.Polygon4.DataManager.schema-master"_dep; gen_flex_bison_pair("org.sw.demo.lexxmark.winflexbison"_dep, script2txt, "LALR1_CPP_VARIANT_PARSER", "script2txt"); script2txt.CompileOptions.push_back("/Zc:__cplusplus"); auto &model = tools.addStaticLibrary("model"); - model.CPPVersion = CPPLanguageStandard::CPP17; + model += cpp20; model.setRootDirectory("src/model"); model.Public += common, "org.sw.demo.unicode.icu.i18n"_dep,