/* */ #include "Checksum.h" #include "MessageDigest.h" namespace aria2 { Checksum::Checksum(const std::string& algo, const std::string& messageDigest) : algo_(algo), messageDigest_(messageDigest) {} Checksum::Checksum() : algo_("sha-1") {} Checksum::~Checksum() {} bool Checksum::isEmpty() const { return messageDigest_.empty(); } void Checksum::setMessageDigest(const std::string& md) { messageDigest_ = md; } void Checksum::setAlgo(const std::string& algo) { algo_ = algo; } void Checksum::swap(Checksum& other) { using std::swap; if(this != &other) { swap(algo_, other.algo_); swap(messageDigest_, other.messageDigest_); } } void swap(Checksum& a, Checksum& b) { a.swap(b); } bool HashTypeStronger::operator() (const Checksum& lhs, const Checksum& rhs) const { return MessageDigest::isStronger(lhs.getAlgo(), rhs.getAlgo()); } } // namespace aria2