consider macro TORRENT_USE_IOSTREAM for sha1_hash iostream operators (#790)

This commit is contained in:
Alden Torres 2016-06-05 23:55:42 -04:00 committed by Arvid Norberg
parent cbeb7adbde
commit 3d5e0144c7
2 changed files with 12 additions and 0 deletions

View File

@ -42,7 +42,9 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/assert.hpp" #include "libtorrent/assert.hpp"
#include "libtorrent/aux_/byteswap.hpp" #include "libtorrent/aux_/byteswap.hpp"
#if TORRENT_USE_IOSTREAM
#include <iosfwd> #include <iosfwd>
#endif // TORRENT_USE_IOSTREAM
#ifdef max #ifdef max
#undef max #undef max
@ -255,11 +257,15 @@ namespace libtorrent
return ret; return ret;
} }
#if TORRENT_USE_IOSTREAM
// print a sha1_hash object to an ostream as 40 hexadecimal digits // print a sha1_hash object to an ostream as 40 hexadecimal digits
TORRENT_EXPORT std::ostream& operator<<(std::ostream& os, sha1_hash const& peer); TORRENT_EXPORT std::ostream& operator<<(std::ostream& os, sha1_hash const& peer);
// read 40 hexadecimal digits from an istream into a sha1_hash // read 40 hexadecimal digits from an istream into a sha1_hash
TORRENT_EXPORT std::istream& operator>>(std::istream& is, sha1_hash& peer); TORRENT_EXPORT std::istream& operator>>(std::istream& is, sha1_hash& peer);
#endif // TORRENT_USE_IOSTREAM
} }
namespace std { namespace std {

View File

@ -34,11 +34,15 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/aux_/cpuid.hpp" #include "libtorrent/aux_/cpuid.hpp"
#include "libtorrent/hex.hpp" // to_hex, from_hex #include "libtorrent/hex.hpp" // to_hex, from_hex
#if TORRENT_USE_IOSTREAM
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#endif // TORRENT_USE_IOSTREAM
namespace libtorrent namespace libtorrent
{ {
#if TORRENT_USE_IOSTREAM
// print a sha1_hash object to an ostream as 40 hexadecimal digits // print a sha1_hash object to an ostream as 40 hexadecimal digits
std::ostream& operator<<(std::ostream& os, sha1_hash const& peer) std::ostream& operator<<(std::ostream& os, sha1_hash const& peer)
{ {
@ -57,6 +61,8 @@ namespace libtorrent
return is; return is;
} }
#endif // TORRENT_USE_IOSTREAM
int sha1_hash::count_leading_zeroes() const int sha1_hash::count_leading_zeroes() const
{ {
int ret = 0; int ret = 0;