00001 /*---------------------------------------------------------------------\ 00002 | ____ _ __ __ ___ | 00003 | |__ / \ / / . \ . \ | 00004 | / / \ V /| _/ _/ | 00005 | / /__ | | | | | | | 00006 | /_____||_| |_| |_| | 00007 | | 00008 \---------------------------------------------------------------------*/ 00012 #ifndef ZYPP_CHECKSUM_H 00013 #define ZYPP_CHECKSUM_H 00014 00015 #include <string> 00016 00017 #include "zypp/base/String.h" 00018 00020 namespace zypp 00021 { 00022 00023 class CheckSum 00024 { 00025 public: 00026 CheckSum(const std::string & type, const std::string & checksum) 00027 { 00028 _checksum = checksum; 00029 if (str::toLower(type) == "sha") 00030 { 00031 if (checksum.size() == 40) 00032 _type = "sha1"; 00033 else if (checksum.size() == 64) 00034 _type = "sha256"; 00035 } 00036 else 00037 { 00038 _type = type; 00039 } 00040 } 00041 00042 CheckSum() 00043 {} 00044 00045 inline bool operator==( const CheckSum &rhs ) 00046 { 00047 return ((rhs.type() == _type) && (rhs.checksum() == _checksum)); 00048 } 00049 00050 std::string type() const 00051 { return _type; } 00052 std::string checksum() const 00053 { return _checksum; } 00054 00055 bool empty() const 00056 { return (checksum().empty() || type().empty()); } 00057 private: 00058 std::string _type; 00059 std::string _checksum; 00060 }; 00061 } // namespace zypp 00063 #endif // ZYPP_CHECKSUM_H
1.4.6