Rename expected::get_or_exit() to expected::value_or_exit()
MODIFY
include/expected.h
include/expected.h
@@ -40,13 +40,13 @@ namespace vcpkg
return this->m_error_code;
}
- T&& get_or_exit(const LineInfo& line_info) &&
+ T&& value_or_exit(const LineInfo& line_info) &&
{
exit_if_error(line_info);
return std::move(this->m_t);
}
- const T& get_or_exit(const LineInfo& line_info) const &
+ const T& value_or_exit(const LineInfo& line_info) const &
{
exit_if_error(line_info);
return this->m_t;

MODIFY
src/BinaryParagraph.cpp
src/BinaryParagraph.cpp
@@ -31,7 +31,7 @@ namespace vcpkg
const std::string architecture = details::remove_required_field(&fields, BinaryParagraphRequiredField::ARCHITECTURE);
const triplet target_triplet = triplet::from_canonical_name(architecture);
- this->spec = package_spec::from_name_and_triplet(name, target_triplet).get_or_exit(VCPKG_LINE_INFO);
+ this->spec = package_spec::from_name_and_triplet(name, target_triplet).value_or_exit(VCPKG_LINE_INFO);
this->version = details::remove_required_field(&fields, BinaryParagraphRequiredField::VERSION);
this->description = details::remove_optional_field(&fields, BinaryParagraphOptionalField::DESCRIPTION);
@@ -46,7 +46,7 @@ namespace vcpkg
BinaryParagraph::BinaryParagraph(const SourceParagraph& spgh, const triplet& target_triplet)
{
- this->spec = package_spec::from_name_and_triplet(spgh.name, target_triplet).get_or_exit(VCPKG_LINE_INFO);
+ this->spec = package_spec::from_name_and_triplet(spgh.name, target_triplet).value_or_exit(VCPKG_LINE_INFO);
this->version = spgh.version;
this->description = spgh.description;
this->maintainer = spgh.maintainer;

MODIFY
src/commands_ci.cpp
src/commands_ci.cpp
@@ -20,7 +20,7 @@ namespace vcpkg::Commands::CI
std::vector<package_spec> specs;
for (const SourceParagraph& p : ports)
{
- specs.push_back(package_spec::from_name_and_triplet(p.name, target_triplet).get_or_exit(VCPKG_LINE_INFO));
+ specs.push_back(package_spec::from_name_and_triplet(p.name, target_triplet).value_or_exit(VCPKG_LINE_INFO));
}
return specs;
@@ -74,7 +74,7 @@ namespace vcpkg::Commands::CI
System::println(System::color::error, Build::create_error_message(result, action.spec));
continue;
}
- const BinaryParagraph bpgh = Paragraphs::try_load_cached_package(paths, action.spec).get_or_exit(VCPKG_LINE_INFO);
+ const BinaryParagraph bpgh = Paragraphs::try_load_cached_package(paths, action.spec).value_or_exit(VCPKG_LINE_INFO);
Install::install_package(paths, bpgh, &status_db);
System::println(System::color::success, "Package %s is installed", action.spec);
}

MODIFY
src/commands_install.cpp
src/commands_install.cpp
@@ -227,7 +227,7 @@ namespace vcpkg::Commands::Install
System::println(Build::create_user_troubleshooting_message(action.spec));
Checks::exit_fail(VCPKG_LINE_INFO);
}
- const BinaryParagraph bpgh = Paragraphs::try_load_cached_package(paths, action.spec).get_or_exit(VCPKG_LINE_INFO);
+ const BinaryParagraph bpgh = Paragraphs::try_load_cached_package(paths, action.spec).value_or_exit(VCPKG_LINE_INFO);
install_package(paths, bpgh, &status_db);
System::println(System::color::success, "Package %s is installed", action.spec);
}

MODIFY
src/tests_paragraph.cpp
src/tests_paragraph.cpp
@@ -153,14 +153,14 @@ namespace UnitTest1
TEST_METHOD(parse_paragraphs_empty)
{
const char* str = "";
- auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).get_or_exit(VCPKG_LINE_INFO);
+ auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
Assert::IsTrue(pghs.empty());
}
TEST_METHOD(parse_paragraphs_one_field)
{
const char* str = "f1: v1";
- auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).get_or_exit(VCPKG_LINE_INFO);
+ auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
Assert::AreEqual(size_t(1), pghs.size());
Assert::AreEqual(size_t(1), pghs[0].size());
Assert::AreEqual("v1", pghs[0]["f1"].c_str());
@@ -171,7 +171,7 @@ namespace UnitTest1
const char* str =
"f1: v1\n"
"f2: v2";
- auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).get_or_exit(VCPKG_LINE_INFO);
+ auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
Assert::AreEqual(size_t(1), pghs.size());
Assert::AreEqual(size_t(2), pghs[0].size());
Assert::AreEqual("v1", pghs[0]["f1"].c_str());
@@ -186,7 +186,7 @@ namespace UnitTest1
"\n"
"f3: v3\n"
"f4: v4";
- auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).get_or_exit(VCPKG_LINE_INFO);
+ auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
Assert::AreEqual(size_t(2), pghs.size());
Assert::AreEqual(size_t(2), pghs[0].size());
Assert::AreEqual("v1", pghs[0]["f1"].c_str());
@@ -204,7 +204,7 @@ namespace UnitTest1
"F:\n"
"0:\n"
"F-2:\n";
- auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).get_or_exit(VCPKG_LINE_INFO);
+ auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
Assert::AreEqual(size_t(1), pghs.size());
Assert::AreEqual(size_t(5), pghs[0].size());
}
@@ -218,7 +218,7 @@ namespace UnitTest1
"\n"
"f3: v3\n"
"f4: v4";
- auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).get_or_exit(VCPKG_LINE_INFO);
+ auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
Assert::AreEqual(size_t(2), pghs.size());
}
@@ -227,7 +227,7 @@ namespace UnitTest1
const char* str =
"f1:\n"
"f2: ";
- auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).get_or_exit(VCPKG_LINE_INFO);
+ auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
Assert::AreEqual(size_t(1), pghs.size());
Assert::AreEqual(size_t(2), pghs[0].size());
Assert::AreEqual("", pghs[0]["f1"].c_str());
@@ -243,7 +243,7 @@ namespace UnitTest1
"f2:\r\n"
" f2\r\n"
" continue\r\n";
- auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).get_or_exit(VCPKG_LINE_INFO);
+ auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
Assert::AreEqual(size_t(1), pghs.size());
Assert::AreEqual("simple\n f1", pghs[0]["f1"].c_str());
Assert::AreEqual("\n f2\n continue", pghs[0]["f2"].c_str());
@@ -257,7 +257,7 @@ namespace UnitTest1
"\r\n"
"f3: v3\r\n"
"f4: v4";
- auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).get_or_exit(VCPKG_LINE_INFO);
+ auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
Assert::AreEqual(size_t(2), pghs.size());
Assert::AreEqual(size_t(2), pghs[0].size());
Assert::AreEqual("v1", pghs[0]["f1"].c_str());
@@ -277,7 +277,7 @@ namespace UnitTest1
{"Multi-Arch", "same"},
});
ss << pgh;
- auto pghs = vcpkg::Paragraphs::parse_paragraphs(ss.str()).get_or_exit(VCPKG_LINE_INFO);
+ auto pghs = vcpkg::Paragraphs::parse_paragraphs(ss.str()).value_or_exit(VCPKG_LINE_INFO);
Assert::AreEqual(size_t(1), pghs.size());
Assert::AreEqual(size_t(4), pghs[0].size());
Assert::AreEqual("zlib", pghs[0]["Package"].c_str());
@@ -299,7 +299,7 @@ namespace UnitTest1
{"Multi-Arch", "same"},
});
ss << pgh;
- auto pghs = vcpkg::Paragraphs::parse_paragraphs(ss.str()).get_or_exit(VCPKG_LINE_INFO);
+ auto pghs = vcpkg::Paragraphs::parse_paragraphs(ss.str()).value_or_exit(VCPKG_LINE_INFO);
Assert::AreEqual(size_t(1), pghs.size());
Assert::AreEqual(size_t(7), pghs[0].size());
Assert::AreEqual("zlib", pghs[0]["Package"].c_str());
@@ -321,7 +321,7 @@ namespace UnitTest1
{"Depends", "a, b, c"},
});
ss << pgh;
- auto pghs = vcpkg::Paragraphs::parse_paragraphs(ss.str()).get_or_exit(VCPKG_LINE_INFO);
+ auto pghs = vcpkg::Paragraphs::parse_paragraphs(ss.str()).value_or_exit(VCPKG_LINE_INFO);
Assert::AreEqual(size_t(1), pghs.size());
Assert::AreEqual("a, b, c", pghs[0]["Depends"].c_str());
}

MODIFY
src/vcpkg.cpp
src/vcpkg.cpp
@@ -60,7 +60,7 @@ static void inner(const vcpkg_cmd_arguments& args)
const expected<vcpkg_paths> expected_paths = vcpkg_paths::create(vcpkg_root_dir);
Checks::check_exit(VCPKG_LINE_INFO, !expected_paths.error_code(), "Error: Invalid vcpkg root directory %s: %s", vcpkg_root_dir.string(), expected_paths.error_code().message());
- const vcpkg_paths paths = expected_paths.get_or_exit(VCPKG_LINE_INFO);
+ const vcpkg_paths paths = expected_paths.value_or_exit(VCPKG_LINE_INFO);
int exit_code = _wchdir(paths.root.c_str());
Checks::check_exit(VCPKG_LINE_INFO, exit_code == 0, "Changing the working dir failed");

MODIFY
src/vcpkg_Dependencies.cpp
src/vcpkg_Dependencies.cpp
@@ -56,7 +56,7 @@ namespace vcpkg::Dependencies
{
for (const std::string& dep_as_string : dependencies_as_string)
{
- const package_spec current_dep = package_spec::from_name_and_triplet(dep_as_string, spec.target_triplet()).get_or_exit(VCPKG_LINE_INFO);
+ const package_spec current_dep = package_spec::from_name_and_triplet(dep_as_string, spec.target_triplet()).value_or_exit(VCPKG_LINE_INFO);
graph.add_edge(spec, current_dep);
if (was_examined.find(current_dep) == was_examined.end())
{

MODIFY
src/vcpkg_metrics_uploader.cpp
src/vcpkg_metrics_uploader.cpp
@@ -13,5 +13,5 @@ int WINAPI WinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ LPSTR, _In_ int)
szArgList = CommandLineToArgvW(GetCommandLineW(), &argCount);
Checks::check_exit(VCPKG_LINE_INFO, argCount == 2, "Requires exactly one argument, the path to the payload file");
- Upload(Files::read_contents(szArgList[1]).get_or_exit(VCPKG_LINE_INFO));
+ Upload(Files::read_contents(szArgList[1]).value_or_exit(VCPKG_LINE_INFO));
}

MODIFY
src/vcpkglib.cpp
src/vcpkglib.cpp
@@ -22,7 +22,7 @@ namespace vcpkg
fs::rename(vcpkg_dir_status_file_old, vcpkg_dir_status_file);
}
- auto pghs = Paragraphs::get_paragraphs(vcpkg_dir_status_file).get_or_exit(VCPKG_LINE_INFO);
+ auto pghs = Paragraphs::get_paragraphs(vcpkg_dir_status_file).value_or_exit(VCPKG_LINE_INFO);
std::vector<std::unique_ptr<StatusParagraph>> status_pghs;
for (auto&& p : pghs)
@@ -64,7 +64,7 @@ namespace vcpkg
if (b->path().filename() == "incomplete")
continue;
- auto pghs = Paragraphs::get_paragraphs(b->path()).get_or_exit(VCPKG_LINE_INFO);
+ auto pghs = Paragraphs::get_paragraphs(b->path()).value_or_exit(VCPKG_LINE_INFO);
for (auto&& p : pghs)
{
current_status_db.insert(std::make_unique<StatusParagraph>(p));
@@ -196,7 +196,7 @@ namespace vcpkg
}
const fs::path listfile_path = paths.listfile_path(pgh->package);
- std::vector<std::string> installed_files_of_current_pgh = Files::read_all_lines(listfile_path).get_or_exit(VCPKG_LINE_INFO);
+ std::vector<std::string> installed_files_of_current_pgh = Files::read_all_lines(listfile_path).value_or_exit(VCPKG_LINE_INFO);
Strings::trim_all_and_remove_whitespace_strings(&installed_files_of_current_pgh);
upgrade_to_slash_terminated_sorted_format(&installed_files_of_current_pgh, listfile_path);

Rename expected::get_or_exit() to expected::value_or_exit()