From 3d5e0144c7b404fa3a0553de21380bf068c590b3 Mon Sep 17 00:00:00 2001 From: Alden Torres Date: Sun, 5 Jun 2016 23:55:42 -0400 Subject: [PATCH] consider macro TORRENT_USE_IOSTREAM for sha1_hash iostream operators (#790) --- include/libtorrent/sha1_hash.hpp | 6 ++++++ src/sha1_hash.cpp | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/include/libtorrent/sha1_hash.hpp b/include/libtorrent/sha1_hash.hpp index 4496bfe56..d88171f03 100644 --- a/include/libtorrent/sha1_hash.hpp +++ b/include/libtorrent/sha1_hash.hpp @@ -42,7 +42,9 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/assert.hpp" #include "libtorrent/aux_/byteswap.hpp" +#if TORRENT_USE_IOSTREAM #include +#endif // TORRENT_USE_IOSTREAM #ifdef max #undef max @@ -255,11 +257,15 @@ namespace libtorrent return ret; } +#if TORRENT_USE_IOSTREAM + // print a sha1_hash object to an ostream as 40 hexadecimal digits TORRENT_EXPORT std::ostream& operator<<(std::ostream& os, sha1_hash const& peer); // read 40 hexadecimal digits from an istream into a sha1_hash TORRENT_EXPORT std::istream& operator>>(std::istream& is, sha1_hash& peer); + +#endif // TORRENT_USE_IOSTREAM } namespace std { diff --git a/src/sha1_hash.cpp b/src/sha1_hash.cpp index b50506fc5..397bb993d 100644 --- a/src/sha1_hash.cpp +++ b/src/sha1_hash.cpp @@ -34,11 +34,15 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/cpuid.hpp" #include "libtorrent/hex.hpp" // to_hex, from_hex +#if TORRENT_USE_IOSTREAM #include #include +#endif // TORRENT_USE_IOSTREAM namespace libtorrent { +#if TORRENT_USE_IOSTREAM + // print a sha1_hash object to an ostream as 40 hexadecimal digits std::ostream& operator<<(std::ostream& os, sha1_hash const& peer) { @@ -57,6 +61,8 @@ namespace libtorrent return is; } +#endif // TORRENT_USE_IOSTREAM + int sha1_hash::count_leading_zeroes() const { int ret = 0;