From 0b5e2e9e76e66b566cf4d3f68146fdbdff2bac05 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 5 Jan 2017 12:47:08 -0800 Subject: Use nested namespace definition --- toolsrc/include/vcpkg_Checks.h | 4 ++-- toolsrc/include/vcpkg_Files.h | 4 ++-- toolsrc/include/vcpkg_Graphs.h | 4 ++-- toolsrc/include/vcpkg_Maps.h | 4 ++-- toolsrc/include/vcpkg_Sets.h | 4 ++-- toolsrc/include/vcpkg_Strings.h | 8 ++++---- toolsrc/include/vcpkg_System.h | 4 ++-- toolsrc/src/vcpkg_Checks.cpp | 4 ++-- toolsrc/src/vcpkg_Files.cpp | 4 ++-- toolsrc/src/vcpkg_Strings.cpp | 8 ++++---- toolsrc/src/vcpkg_System.cpp | 6 +++--- 11 files changed, 27 insertions(+), 27 deletions(-) diff --git a/toolsrc/include/vcpkg_Checks.h b/toolsrc/include/vcpkg_Checks.h index 9d9b21ed6..a58b38ac0 100644 --- a/toolsrc/include/vcpkg_Checks.h +++ b/toolsrc/include/vcpkg_Checks.h @@ -2,7 +2,7 @@ #include "vcpkg_Strings.h" -namespace vcpkg {namespace Checks +namespace vcpkg::Checks { __declspec(noreturn) void unreachable(); @@ -46,4 +46,4 @@ namespace vcpkg {namespace Checks exit_with_message(Strings::format(errorMessageTemplate, errorMessageArgs...).c_str()); } } -}} +} diff --git a/toolsrc/include/vcpkg_Files.h b/toolsrc/include/vcpkg_Files.h index 6c9d0d365..3f9570946 100644 --- a/toolsrc/include/vcpkg_Files.h +++ b/toolsrc/include/vcpkg_Files.h @@ -4,7 +4,7 @@ #include "filesystem_fs.h" #include -namespace vcpkg {namespace Files +namespace vcpkg::Files { static const char* FILESYSTEM_INVALID_CHARACTERS = R"(\/:*?"<>|)"; @@ -53,4 +53,4 @@ namespace vcpkg {namespace Files std::vector non_recursive_find_all_files_in_dir(const fs::path& dir); void print_paths(const std::vector& paths); -}} +} diff --git a/toolsrc/include/vcpkg_Graphs.h b/toolsrc/include/vcpkg_Graphs.h index 9444ac45b..933d9ac67 100644 --- a/toolsrc/include/vcpkg_Graphs.h +++ b/toolsrc/include/vcpkg_Graphs.h @@ -3,7 +3,7 @@ #include #include -namespace vcpkg { namespace Graphs +namespace vcpkg::Graphs { enum class ExplorationStatus { @@ -117,4 +117,4 @@ namespace vcpkg { namespace Graphs private: std::unordered_map> vertices; }; -}} +} diff --git a/toolsrc/include/vcpkg_Maps.h b/toolsrc/include/vcpkg_Maps.h index c67462a39..5e2f92f55 100644 --- a/toolsrc/include/vcpkg_Maps.h +++ b/toolsrc/include/vcpkg_Maps.h @@ -4,7 +4,7 @@ #include #include -namespace vcpkg { namespace Maps +namespace vcpkg::Maps { template std::unordered_set extract_key_set(const std::unordered_map& input_map) @@ -38,4 +38,4 @@ namespace vcpkg { namespace Maps } return key_set; } -}} +} diff --git a/toolsrc/include/vcpkg_Sets.h b/toolsrc/include/vcpkg_Sets.h index 7b330f31c..6dec95b89 100644 --- a/toolsrc/include/vcpkg_Sets.h +++ b/toolsrc/include/vcpkg_Sets.h @@ -3,7 +3,7 @@ #include "vcpkg_Checks.h" #include -namespace vcpkg { namespace Sets +namespace vcpkg::Sets { template void remove_all(std::unordered_set* input_set, Container remove_these) @@ -14,4 +14,4 @@ namespace vcpkg { namespace Sets input_set->erase(r); } } -}} +} diff --git a/toolsrc/include/vcpkg_Strings.h b/toolsrc/include/vcpkg_Strings.h index a117a1a81..28853cb5d 100644 --- a/toolsrc/include/vcpkg_Strings.h +++ b/toolsrc/include/vcpkg_Strings.h @@ -2,7 +2,7 @@ #include -namespace vcpkg {namespace Strings {namespace details +namespace vcpkg::Strings::details { inline const char* to_printf_arg(const std::string& s) { @@ -42,9 +42,9 @@ namespace vcpkg {namespace Strings {namespace details } std::wstring wformat_internal(const wchar_t* fmtstr, ...); -}}} +} -namespace vcpkg {namespace Strings +namespace vcpkg::Strings { template std::string format(const char* fmtstr, const Args&...args) @@ -75,4 +75,4 @@ namespace vcpkg {namespace Strings std::string trimmed(const std::string& s); void trim_all_and_remove_whitespace_strings(std::vector* strings); -}} +} diff --git a/toolsrc/include/vcpkg_System.h b/toolsrc/include/vcpkg_System.h index 1101c9b27..c9195163c 100644 --- a/toolsrc/include/vcpkg_System.h +++ b/toolsrc/include/vcpkg_System.h @@ -3,7 +3,7 @@ #include "vcpkg_Strings.h" #include "filesystem_fs.h" -namespace vcpkg {namespace System +namespace vcpkg::System { fs::path get_exe_path_of_current_process(); @@ -93,4 +93,4 @@ namespace vcpkg {namespace System }; std::wstring wdupenv_str(const wchar_t* varname) noexcept; -}} +} diff --git a/toolsrc/src/vcpkg_Checks.cpp b/toolsrc/src/vcpkg_Checks.cpp index 817ac9e96..46b28e55c 100644 --- a/toolsrc/src/vcpkg_Checks.cpp +++ b/toolsrc/src/vcpkg_Checks.cpp @@ -3,7 +3,7 @@ #include #include "vcpkg_System.h" -namespace vcpkg {namespace Checks +namespace vcpkg::Checks { void unreachable() { @@ -41,4 +41,4 @@ namespace vcpkg {namespace Checks exit_with_message(errorMessage); } } -}} +} diff --git a/toolsrc/src/vcpkg_Files.cpp b/toolsrc/src/vcpkg_Files.cpp index 48283e43f..1d4faa773 100644 --- a/toolsrc/src/vcpkg_Files.cpp +++ b/toolsrc/src/vcpkg_Files.cpp @@ -3,7 +3,7 @@ #include #include "vcpkg_System.h" -namespace vcpkg {namespace Files +namespace vcpkg::Files { static const std::regex FILESYSTEM_INVALID_CHARACTERS_REGEX = std::regex(R"([\/:*?"<>|])"); @@ -140,4 +140,4 @@ namespace vcpkg {namespace Files } System::println(""); } -}} +} diff --git a/toolsrc/src/vcpkg_Strings.cpp b/toolsrc/src/vcpkg_Strings.cpp index 46a4b1855..cf7d3b0ee 100644 --- a/toolsrc/src/vcpkg_Strings.cpp +++ b/toolsrc/src/vcpkg_Strings.cpp @@ -7,7 +7,7 @@ #include #include -namespace vcpkg {namespace Strings {namespace details +namespace vcpkg::Strings::details { // To disambiguate between two overloads static const auto isspace = [](const char c) @@ -40,9 +40,9 @@ namespace vcpkg {namespace Strings {namespace details return output; } -}}} +} -namespace vcpkg {namespace Strings +namespace vcpkg::Strings { std::wstring utf8_to_utf16(const std::string& s) { @@ -119,4 +119,4 @@ namespace vcpkg {namespace Strings return s == ""; }), strings->end()); } -}} +} diff --git a/toolsrc/src/vcpkg_System.cpp b/toolsrc/src/vcpkg_System.cpp index 43eae3412..405dfd1b8 100644 --- a/toolsrc/src/vcpkg_System.cpp +++ b/toolsrc/src/vcpkg_System.cpp @@ -3,7 +3,7 @@ #include #include -namespace vcpkg {namespace System +namespace vcpkg::System { fs::path get_exe_path_of_current_process() { @@ -104,6 +104,6 @@ namespace vcpkg {namespace System double Stopwatch2::microseconds() const { return (reinterpret_cast(&end_time)->QuadPart - - reinterpret_cast(&start_time)->QuadPart) * 1000000.0 / reinterpret_cast(&freq)->QuadPart; + reinterpret_cast(&start_time)->QuadPart) * 1000000.0 / reinterpret_cast(&freq)->QuadPart; } -}} +} -- cgit v1.2.3 From 1565cafb836a8efdb7c39c9c1df1ca4d671f3d90 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 5 Jan 2017 14:09:48 -0800 Subject: Use nullptr --- toolsrc/src/metrics.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/toolsrc/src/metrics.cpp b/toolsrc/src/metrics.cpp index 51c7179c8..1806dad87 100644 --- a/toolsrc/src/metrics.cpp +++ b/toolsrc/src/metrics.cpp @@ -237,13 +237,13 @@ true std::wstring GetSQMUser() { - LONG err = NULL; + LONG err; struct RAII_HKEY { - HKEY hkey = NULL; + HKEY hkey = nullptr; ~RAII_HKEY() { - if (hkey != NULL) + if (hkey != nullptr) RegCloseKey(hkey); } } HKCU_SQMClient; @@ -257,7 +257,7 @@ true std::array buffer; DWORD lType = 0; DWORD dwBufferSize = static_cast(buffer.size() * sizeof(wchar_t)); - err = RegQueryValueExW(HKCU_SQMClient.hkey, L"UserId", NULL, &lType, reinterpret_cast(buffer.data()), &dwBufferSize); + err = RegQueryValueExW(HKCU_SQMClient.hkey, L"UserId", nullptr, &lType, reinterpret_cast(buffer.data()), &dwBufferSize); if (err == ERROR_SUCCESS && lType == REG_SZ && dwBufferSize >= sizeof(wchar_t)) { size_t sz = dwBufferSize / sizeof(wchar_t); -- cgit v1.2.3 From 88b5791b0bcaa9cce7f488bbd03042aa65e4417e Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 5 Jan 2017 14:14:11 -0800 Subject: Use Nested Namespace Definition --- toolsrc/include/coff_file_reader.h | 4 ++-- toolsrc/include/post_build_lint.h | 4 ++-- toolsrc/include/vcpkg_Dependencies.h | 4 ++-- toolsrc/include/vcpkg_Environment.h | 4 ++-- toolsrc/include/vcpkg_Input.h | 4 ++-- toolsrc/src/coff_file_reader.cpp | 4 ++-- toolsrc/src/post_build_lint.cpp | 4 ++-- toolsrc/src/vcpkg_Dependencies.cpp | 4 ++-- toolsrc/src/vcpkg_Environment.cpp | 4 ++-- toolsrc/src/vcpkg_Input.cpp | 4 ++-- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/toolsrc/include/coff_file_reader.h b/toolsrc/include/coff_file_reader.h index edf6910a5..24fbf4576 100644 --- a/toolsrc/include/coff_file_reader.h +++ b/toolsrc/include/coff_file_reader.h @@ -3,7 +3,7 @@ #include "MachineType.h" #include "filesystem_fs.h" -namespace vcpkg {namespace COFFFileReader +namespace vcpkg::COFFFileReader { struct dll_info { @@ -18,4 +18,4 @@ namespace vcpkg {namespace COFFFileReader dll_info read_dll(const fs::path& path); lib_info read_lib(const fs::path& path); -}} +} diff --git a/toolsrc/include/post_build_lint.h b/toolsrc/include/post_build_lint.h index a5fb9149f..215a237aa 100644 --- a/toolsrc/include/post_build_lint.h +++ b/toolsrc/include/post_build_lint.h @@ -2,7 +2,7 @@ #include "package_spec.h" #include "vcpkg_paths.h" -namespace vcpkg {namespace PostBuildLint +namespace vcpkg::PostBuildLint { void perform_all_checks(const package_spec& spec, const vcpkg_paths& paths); -}} +} diff --git a/toolsrc/include/vcpkg_Dependencies.h b/toolsrc/include/vcpkg_Dependencies.h index 3616e6be9..4da9de694 100644 --- a/toolsrc/include/vcpkg_Dependencies.h +++ b/toolsrc/include/vcpkg_Dependencies.h @@ -4,7 +4,7 @@ #include "StatusParagraphs.h" #include "vcpkg_paths.h" -namespace vcpkg {namespace Dependencies +namespace vcpkg::Dependencies { enum class install_plan_type { @@ -27,4 +27,4 @@ namespace vcpkg {namespace Dependencies }; std::vector create_install_plan(const vcpkg_paths& paths, const std::vector& specs, const StatusParagraphs& status_db); -}} +} diff --git a/toolsrc/include/vcpkg_Environment.h b/toolsrc/include/vcpkg_Environment.h index 877ac7deb..1e8624d89 100644 --- a/toolsrc/include/vcpkg_Environment.h +++ b/toolsrc/include/vcpkg_Environment.h @@ -1,7 +1,7 @@ #pragma once #include "vcpkg_paths.h" -namespace vcpkg {namespace Environment +namespace vcpkg::Environment { void ensure_nuget_on_path(const vcpkg_paths& paths); @@ -14,4 +14,4 @@ namespace vcpkg {namespace Environment ensure_cmake_on_path(paths); ensure_git_on_path(paths); } -}} +} diff --git a/toolsrc/include/vcpkg_Input.h b/toolsrc/include/vcpkg_Input.h index 5ce90e3b9..3cce334c4 100644 --- a/toolsrc/include/vcpkg_Input.h +++ b/toolsrc/include/vcpkg_Input.h @@ -3,7 +3,7 @@ #include "package_spec.h" #include "vcpkg_paths.h" -namespace vcpkg {namespace Input +namespace vcpkg::Input { package_spec check_and_get_package_spec(const std::string& package_spec_as_string, const triplet& default_target_triplet, const std::string& example_text); @@ -12,4 +12,4 @@ namespace vcpkg {namespace Input void check_triplet(const triplet& t, const vcpkg_paths& paths); void check_triplets(std::vector triplets, const vcpkg_paths& paths); -}} +} diff --git a/toolsrc/src/coff_file_reader.cpp b/toolsrc/src/coff_file_reader.cpp index 1f30ea70b..8ce714bbe 100644 --- a/toolsrc/src/coff_file_reader.cpp +++ b/toolsrc/src/coff_file_reader.cpp @@ -6,7 +6,7 @@ using namespace std; -namespace vcpkg { namespace COFFFileReader +namespace vcpkg::COFFFileReader { template static T reinterpret_bytes(const char* data) @@ -306,4 +306,4 @@ namespace vcpkg { namespace COFFFileReader return {std::vector(machine_types.cbegin(), machine_types.cend())}; } -}} +} diff --git a/toolsrc/src/post_build_lint.cpp b/toolsrc/src/post_build_lint.cpp index 4f0adf677..1fca3a2f6 100644 --- a/toolsrc/src/post_build_lint.cpp +++ b/toolsrc/src/post_build_lint.cpp @@ -7,7 +7,7 @@ #include "BuildInfo.h" #include -namespace vcpkg { namespace PostBuildLint +namespace vcpkg::PostBuildLint { enum class lint_status { @@ -668,4 +668,4 @@ namespace vcpkg { namespace PostBuildLint System::println("-- Performing post-build validation done"); } -}} +} diff --git a/toolsrc/src/vcpkg_Dependencies.cpp b/toolsrc/src/vcpkg_Dependencies.cpp index ae7f697fa..f1464a605 100644 --- a/toolsrc/src/vcpkg_Dependencies.cpp +++ b/toolsrc/src/vcpkg_Dependencies.cpp @@ -9,7 +9,7 @@ #include "vcpkg_Files.h" #include "vcpkg.h" -namespace vcpkg { namespace Dependencies +namespace vcpkg::Dependencies { std::vector create_install_plan(const vcpkg_paths& paths, const std::vector& specs, const StatusParagraphs& status_db) { @@ -72,4 +72,4 @@ namespace vcpkg { namespace Dependencies } return ret; } -}} +} diff --git a/toolsrc/src/vcpkg_Environment.cpp b/toolsrc/src/vcpkg_Environment.cpp index ed70e6881..c7eec3bd0 100644 --- a/toolsrc/src/vcpkg_Environment.cpp +++ b/toolsrc/src/vcpkg_Environment.cpp @@ -5,7 +5,7 @@ #include "metrics.h" #include "vcpkg_System.h" -namespace vcpkg {namespace Environment +namespace vcpkg::Environment { static const fs::path default_cmake_installation_dir = "C:/Program Files/CMake/bin"; static const fs::path default_cmake_installation_dir_x86 = "C:/Program Files (x86)/CMake/bin"; @@ -83,4 +83,4 @@ namespace vcpkg {namespace Environment // TODO: switch out ExecutionPolicy Bypass with "Remove Mark Of The Web" code and restore RemoteSigned ensure_on_path(nuget_version, L"nuget 2>&1", L"powershell -ExecutionPolicy Bypass scripts\\fetchDependency.ps1 -Dependency nuget"); } -}} +} diff --git a/toolsrc/src/vcpkg_Input.cpp b/toolsrc/src/vcpkg_Input.cpp index 29d487fdb..a8145230c 100644 --- a/toolsrc/src/vcpkg_Input.cpp +++ b/toolsrc/src/vcpkg_Input.cpp @@ -3,7 +3,7 @@ #include "metrics.h" #include "vcpkg_Commands.h" -namespace vcpkg {namespace Input +namespace vcpkg::Input { package_spec check_and_get_package_spec(const std::string& package_spec_as_string, const triplet& default_target_triplet, const std::string& example_text) { @@ -49,4 +49,4 @@ namespace vcpkg {namespace Input check_triplet(spec.target_triplet(), paths); } } -}} +} -- cgit v1.2.3 From 6e29b7b8d4b3a21e46a721f79d184213d1c874a4 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 5 Jan 2017 14:21:09 -0800 Subject: Pass by reference --- toolsrc/include/vcpkg_Input.h | 2 +- toolsrc/src/vcpkg_Input.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/toolsrc/include/vcpkg_Input.h b/toolsrc/include/vcpkg_Input.h index 3cce334c4..96cbeecc3 100644 --- a/toolsrc/include/vcpkg_Input.h +++ b/toolsrc/include/vcpkg_Input.h @@ -11,5 +11,5 @@ namespace vcpkg::Input void check_triplet(const triplet& t, const vcpkg_paths& paths); - void check_triplets(std::vector triplets, const vcpkg_paths& paths); + void check_triplets(const std::vector& triplets, const vcpkg_paths& paths); } diff --git a/toolsrc/src/vcpkg_Input.cpp b/toolsrc/src/vcpkg_Input.cpp index a8145230c..365f28cdb 100644 --- a/toolsrc/src/vcpkg_Input.cpp +++ b/toolsrc/src/vcpkg_Input.cpp @@ -42,7 +42,7 @@ namespace vcpkg::Input } } - void check_triplets(std::vector triplets, const vcpkg_paths& paths) + void check_triplets(const std::vector& triplets, const vcpkg_paths& paths) { for (const package_spec& spec : triplets) { -- cgit v1.2.3 From 708e93d82acd4da9c651cc7043dfd32a182ecc11 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 5 Jan 2017 14:25:50 -0800 Subject: Use Nested Namespace Definition --- toolsrc/include/BuildInfo.h | 4 ++-- toolsrc/include/Paragraphs.h | 4 ++-- toolsrc/include/vcpkg_info.h | 4 ++-- toolsrc/include/vcpkglib_helpers.h | 4 ++-- toolsrc/src/BuildInfo.cpp | 4 ++-- toolsrc/src/Paragraphs.cpp | 4 ++-- toolsrc/src/vcpkg_info.cpp | 4 ++-- toolsrc/src/vcpkglib_helpers.cpp | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/toolsrc/include/BuildInfo.h b/toolsrc/include/BuildInfo.h index 49811d521..c90ad7a4e 100644 --- a/toolsrc/include/BuildInfo.h +++ b/toolsrc/include/BuildInfo.h @@ -4,7 +4,7 @@ #include "Paragraphs.h" #include -namespace vcpkg { namespace PostBuildLint +namespace vcpkg::PostBuildLint { enum class LinkageType { @@ -126,4 +126,4 @@ namespace vcpkg { namespace PostBuildLint }; BuildInfo read_build_info(const fs::path& filepath); -}} +} diff --git a/toolsrc/include/Paragraphs.h b/toolsrc/include/Paragraphs.h index 9e9fafe49..761b49759 100644 --- a/toolsrc/include/Paragraphs.h +++ b/toolsrc/include/Paragraphs.h @@ -3,8 +3,8 @@ #include "filesystem_fs.h" #include -namespace vcpkg { namespace Paragraphs +namespace vcpkg::Paragraphs { std::vector> get_paragraphs(const fs::path& control_path); std::vector> parse_paragraphs(const std::string& str); -}} +} diff --git a/toolsrc/include/vcpkg_info.h b/toolsrc/include/vcpkg_info.h index 01da06307..5380e0158 100644 --- a/toolsrc/include/vcpkg_info.h +++ b/toolsrc/include/vcpkg_info.h @@ -2,9 +2,9 @@ #include -namespace vcpkg { namespace Info +namespace vcpkg::Info { const std::string& version(); const std::string& email(); -}} +} diff --git a/toolsrc/include/vcpkglib_helpers.h b/toolsrc/include/vcpkglib_helpers.h index 019bb8c39..8a08513f3 100644 --- a/toolsrc/include/vcpkglib_helpers.h +++ b/toolsrc/include/vcpkglib_helpers.h @@ -2,7 +2,7 @@ #include -namespace vcpkg {namespace details +namespace vcpkg::details { std::string optional_field(const std::unordered_map& fields, const std::string& fieldname); std::string remove_optional_field(std::unordered_map* fields, const std::string& fieldname); @@ -11,4 +11,4 @@ namespace vcpkg {namespace details std::string remove_required_field(std::unordered_map* fields, const std::string& fieldname); std::string shorten_description(const std::string& desc); -}} +} diff --git a/toolsrc/src/BuildInfo.cpp b/toolsrc/src/BuildInfo.cpp index f151a3ea5..a45dc4b72 100644 --- a/toolsrc/src/BuildInfo.cpp +++ b/toolsrc/src/BuildInfo.cpp @@ -2,7 +2,7 @@ #include "vcpkg_Checks.h" #include "vcpkglib_helpers.h" -namespace vcpkg { namespace PostBuildLint +namespace vcpkg::PostBuildLint { const ConfigurationType& BuildType::config() const { @@ -161,4 +161,4 @@ namespace vcpkg { namespace PostBuildLint { return this->m_dll_name; } -}} +} diff --git a/toolsrc/src/Paragraphs.cpp b/toolsrc/src/Paragraphs.cpp index 823b4a85e..d99ad45cf 100644 --- a/toolsrc/src/Paragraphs.cpp +++ b/toolsrc/src/Paragraphs.cpp @@ -1,7 +1,7 @@ #include "Paragraphs.h" #include "vcpkg_Files.h" -namespace vcpkg { namespace Paragraphs +namespace vcpkg::Paragraphs { struct Parser { @@ -160,4 +160,4 @@ namespace vcpkg { namespace Paragraphs { return Parser(str.c_str(), str.c_str() + str.size()).get_paragraphs(); } -}} +} diff --git a/toolsrc/src/vcpkg_info.cpp b/toolsrc/src/vcpkg_info.cpp index 25c09d6da..69bc6a355 100644 --- a/toolsrc/src/vcpkg_info.cpp +++ b/toolsrc/src/vcpkg_info.cpp @@ -6,7 +6,7 @@ #define VCPKG_VERSION_AS_STRING MACRO_TO_STRING(VCPKG_VERSION)"" // Double quotes needed at the end to prevent blank token -namespace vcpkg { namespace Info +namespace vcpkg::Info { const std::string& version() { @@ -31,4 +31,4 @@ namespace vcpkg { namespace Info static const std::string s_email = R"(vcpkg@microsoft.com)"; return s_email; } -}} +} diff --git a/toolsrc/src/vcpkglib_helpers.cpp b/toolsrc/src/vcpkglib_helpers.cpp index d104bb19d..fdc287507 100644 --- a/toolsrc/src/vcpkglib_helpers.cpp +++ b/toolsrc/src/vcpkglib_helpers.cpp @@ -3,7 +3,7 @@ #include #include -namespace vcpkg {namespace details +namespace vcpkg::details { std::string optional_field(const std::unordered_map& fields, const std::string& fieldname) { @@ -53,4 +53,4 @@ namespace vcpkg {namespace details simple_desc.append("..."); return simple_desc; } -}} +} -- cgit v1.2.3 From 64e1bf8de73d18c85776c4cce2f40281f3ebb253 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 5 Jan 2017 14:27:36 -0800 Subject: Use Nested Namespace Definition --- toolsrc/src/tests_paragraph.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/toolsrc/src/tests_paragraph.cpp b/toolsrc/src/tests_paragraph.cpp index 6d9e46fcf..fb20eee82 100644 --- a/toolsrc/src/tests_paragraph.cpp +++ b/toolsrc/src/tests_paragraph.cpp @@ -7,14 +7,14 @@ using namespace Microsoft::VisualStudio::CppUnitTestFramework; -namespace Microsoft { namespace VisualStudio { namespace CppUnitTestFramework +namespace Microsoft::VisualStudio::CppUnitTestFramework { template <> inline std::wstring ToString(const vcpkg::package_spec_parse_result& t) { return ToString(static_cast(t)); } -}}} +} namespace UnitTest1 { -- cgit v1.2.3 From e5f60816cb6a786aa828aa2845522bb81c02cbe6 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 22 Dec 2016 16:43:47 -0800 Subject: Introduce ImmutableSortedVector --- toolsrc/include/ImmutableSortedVector.h | 48 +++++++++++++++++++++++++ toolsrc/include/vcpkg.h | 3 +- toolsrc/src/vcpkg.cpp | 2 +- toolsrc/vcpkgcommon/vcpkgcommon.vcxproj | 1 + toolsrc/vcpkgcommon/vcpkgcommon.vcxproj.filters | 3 ++ 5 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 toolsrc/include/ImmutableSortedVector.h diff --git a/toolsrc/include/ImmutableSortedVector.h b/toolsrc/include/ImmutableSortedVector.h new file mode 100644 index 000000000..681f9fd4d --- /dev/null +++ b/toolsrc/include/ImmutableSortedVector.h @@ -0,0 +1,48 @@ +#pragma once + +#include +#include + +// Add more forwarding functions to the delegate std::vector as needed. +namespace vcpkg +{ + template + class ImmutableSortedVector + { + public: + static ImmutableSortedVector create(std::vector vector) + { + ImmutableSortedVector out; + out.delegate = std::move(vector); + if (!std::is_sorted(out.delegate.cbegin(), out.delegate.cend())) + { + std::sort(out.delegate.begin(), out.delegate.end()); + } + + return out; + } + + typename std::vector::const_iterator begin() const + { + return this->delegate.cbegin(); + } + + typename std::vector::const_iterator end() const + { + return this->delegate.cend(); + } + + typename std::vector::const_iterator cbegin() const + { + return this->delegate.cbegin(); + } + + typename std::vector::const_iterator cend() const + { + return this->delegate.cend(); + } + + private: + std::vector delegate; + }; +} diff --git a/toolsrc/include/vcpkg.h b/toolsrc/include/vcpkg.h index 75dc40b43..b1653d197 100644 --- a/toolsrc/include/vcpkg.h +++ b/toolsrc/include/vcpkg.h @@ -4,6 +4,7 @@ #include "BinaryParagraph.h" #include "StatusParagraphs.h" #include "vcpkg_paths.h" +#include "ImmutableSortedVector.h" namespace vcpkg { @@ -14,7 +15,7 @@ namespace vcpkg struct StatusParagraph_and_associated_files { StatusParagraph pgh; - std::vector files; + ImmutableSortedVector files; }; std::vector get_installed_files(const vcpkg_paths& paths, const StatusParagraphs& status_db); diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp index 4748aeb54..eb2184ccb 100644 --- a/toolsrc/src/vcpkg.cpp +++ b/toolsrc/src/vcpkg.cpp @@ -204,7 +204,7 @@ std::vector vcpkg::get_installed_files(con } ), installed_files_of_current_pgh.end()); - StatusParagraph_and_associated_files pgh_and_files = {*pgh, std::move(installed_files_of_current_pgh)}; + StatusParagraph_and_associated_files pgh_and_files = {*pgh, ImmutableSortedVector::create(std::move(installed_files_of_current_pgh))}; installed_files.push_back(std::move(pgh_and_files)); } diff --git a/toolsrc/vcpkgcommon/vcpkgcommon.vcxproj b/toolsrc/vcpkgcommon/vcpkgcommon.vcxproj index 218a826ad..c0d108602 100644 --- a/toolsrc/vcpkgcommon/vcpkgcommon.vcxproj +++ b/toolsrc/vcpkgcommon/vcpkgcommon.vcxproj @@ -128,6 +128,7 @@ + diff --git a/toolsrc/vcpkgcommon/vcpkgcommon.vcxproj.filters b/toolsrc/vcpkgcommon/vcpkgcommon.vcxproj.filters index 4d40bfbe2..bba605c54 100644 --- a/toolsrc/vcpkgcommon/vcpkgcommon.vcxproj.filters +++ b/toolsrc/vcpkgcommon/vcpkgcommon.vcxproj.filters @@ -62,5 +62,8 @@ Header Files + + Header Files + \ No newline at end of file -- cgit v1.2.3 From ff10939203b7694f21d8e8e0464f092dff1b4eb0 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 5 Jan 2017 15:23:08 -0800 Subject: Refactor pre-install check --- toolsrc/src/commands_installation.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/toolsrc/src/commands_installation.cpp b/toolsrc/src/commands_installation.cpp index 8d940bc9d..c239bf06c 100644 --- a/toolsrc/src/commands_installation.cpp +++ b/toolsrc/src/commands_installation.cpp @@ -164,9 +164,8 @@ namespace vcpkg return output; } - void install_package(const vcpkg_paths& paths, const BinaryParagraph& binary_paragraph, StatusParagraphs& status_db) + static ImmutableSortedVector build_list_of_package_files(const fs::path& package_dir) { - const fs::path package_dir = paths.package_dir(binary_paragraph.spec); const std::vector package_file_paths = Files::recursive_find_all_files_in_dir(package_dir); std::vector package_files; const size_t package_remove_char_count = package_dir.generic_string().size() + 1; // +1 for the slash @@ -176,14 +175,27 @@ namespace vcpkg as_string.erase(0, package_remove_char_count); return std::move(as_string); }); - std::sort(package_files.begin(), package_files.end()); - const std::vector& pgh_and_files = get_installed_files(paths, status_db); - const triplet& triplet = binary_paragraph.spec.target_triplet(); + return ImmutableSortedVector::create(std::move(package_files)); + } + + static ImmutableSortedVector build_list_of_installed_files(const std::vector& pgh_and_files, const triplet& triplet) + { std::vector installed_files = extract_files_in_triplet(pgh_and_files, triplet); const size_t installed_remove_char_count = triplet.canonical_name().size() + 1; // +1 for the slash remove_first_n_chars(&installed_files, installed_remove_char_count); - std::sort(installed_files.begin(), installed_files.end()); // Should already be sorted + + return ImmutableSortedVector::create(std::move(installed_files)); + } + + void install_package(const vcpkg_paths& paths, const BinaryParagraph& binary_paragraph, StatusParagraphs& status_db) + { + const fs::path package_dir = paths.package_dir(binary_paragraph.spec); + const triplet& triplet = binary_paragraph.spec.target_triplet(); + const std::vector pgh_and_files = get_installed_files(paths, status_db); + + const ImmutableSortedVector package_files = build_list_of_package_files(package_dir); + const ImmutableSortedVector installed_files = build_list_of_installed_files(pgh_and_files, triplet); std::vector intersection; std::set_intersection(package_files.cbegin(), package_files.cend(), -- cgit v1.2.3