From 7069fbbebc750a7c8a64adc8c30269527cbec9bd Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Wed, 12 Apr 2017 22:48:52 -0700 Subject: [vcpkg] Remove+indirect nearly all uses of iostreams --- toolsrc/include/BinaryParagraph.h | 2 +- toolsrc/include/SourceParagraph.h | 2 +- toolsrc/include/StatusParagraph.h | 2 +- toolsrc/include/StatusParagraphs.h | 4 ++-- toolsrc/include/vcpkg_Files.h | 1 + toolsrc/include/vcpkg_Strings.h | 8 ++++++++ 6 files changed, 14 insertions(+), 5 deletions(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/BinaryParagraph.h b/toolsrc/include/BinaryParagraph.h index e29e0f51b..6cf740920 100644 --- a/toolsrc/include/BinaryParagraph.h +++ b/toolsrc/include/BinaryParagraph.h @@ -25,5 +25,5 @@ namespace vcpkg std::vector depends; }; - std::ostream& operator<<(std::ostream& os, const BinaryParagraph& pgh); + void serialize(const BinaryParagraph& pgh, std::string& out_str); } diff --git a/toolsrc/include/SourceParagraph.h b/toolsrc/include/SourceParagraph.h index 65ba478ee..b66fa131b 100644 --- a/toolsrc/include/SourceParagraph.h +++ b/toolsrc/include/SourceParagraph.h @@ -13,7 +13,7 @@ namespace vcpkg std::string qualifier; }; - std::ostream& operator<<(std::ostream& os, const Dependency& p); + const std::string& to_string(const Dependency& dep); struct SourceParagraph { diff --git a/toolsrc/include/StatusParagraph.h b/toolsrc/include/StatusParagraph.h index bc2766aa2..a71fb7893 100644 --- a/toolsrc/include/StatusParagraph.h +++ b/toolsrc/include/StatusParagraph.h @@ -33,7 +33,7 @@ namespace vcpkg InstallState state; }; - std::ostream& operator<<(std::ostream& os, const StatusParagraph& pgh); + void serialize(const StatusParagraph& pgh, std::string& out_str); std::string to_string(InstallState f); diff --git a/toolsrc/include/StatusParagraphs.h b/toolsrc/include/StatusParagraphs.h index c5ece9616..fcfe99b5a 100644 --- a/toolsrc/include/StatusParagraphs.h +++ b/toolsrc/include/StatusParagraphs.h @@ -29,7 +29,7 @@ namespace vcpkg iterator insert(std::unique_ptr); - friend std::ostream& operator<<(std::ostream&, const StatusParagraphs&); + friend void serialize(const StatusParagraphs& pgh, std::string& out_str); iterator end() { @@ -55,5 +55,5 @@ namespace vcpkg std::vector> paragraphs; }; - std::ostream& operator<<(std::ostream&, const StatusParagraphs&); + void serialize(const StatusParagraphs& pgh, std::string& out_str); } diff --git a/toolsrc/include/vcpkg_Files.h b/toolsrc/include/vcpkg_Files.h index dde5cf5ee..7bf13e973 100644 --- a/toolsrc/include/vcpkg_Files.h +++ b/toolsrc/include/vcpkg_Files.h @@ -14,6 +14,7 @@ namespace vcpkg::Files virtual std::vector non_recursive_find_all_files_in_dir(const fs::path& dir) const = 0; virtual void write_all_lines(const fs::path& file_path, const std::vector& lines) = 0; + virtual void write_contents(const fs::path& file_path, const std::string& data) = 0; virtual void rename(const fs::path& oldpath, const fs::path& newpath) = 0; virtual bool remove(const fs::path& path) = 0; virtual bool remove(const fs::path& path, std::error_code& ec) = 0; diff --git a/toolsrc/include/vcpkg_Strings.h b/toolsrc/include/vcpkg_Strings.h index 7b031608c..d152eccf5 100644 --- a/toolsrc/include/vcpkg_Strings.h +++ b/toolsrc/include/vcpkg_Strings.h @@ -119,4 +119,12 @@ namespace vcpkg::Strings void trim_all_and_remove_whitespace_strings(std::vector* strings); std::vector split(const std::string& s, const std::string& delimiter); + + template + std::string serialize(const T& t) + { + std::string ret; + serialize(t, ret); + return ret; + } } -- cgit v1.2.3