29 {
static std::string
_type(
"md5" );
return _type; }
32 {
static std::string
_type(
"sha" );
return _type; }
35 {
static std::string
_type(
"sha1" );
return _type; }
38 {
static std::string
_type(
"sha256" );
return _type; }
43 , _checksum( checksum )
45 switch ( checksum.size() )
87 WAR <<
"Can't determine type of " << checksum.size() <<
" byte checksum '" <<
_checksum <<
"'" << endl;
95 std::string msg =
str::form (
_(
"Dubious type '%s' for %u byte checksum '%s'"),
112 if ( input_r.good() && ! type_r.empty() )
116 if ( ! input_r.eof() ||
_checksum.empty() )
134 std::ostringstream
str;
143 return str << std::string(
"NoCheckSum");
146 return str << ( obj.
type().empty() ? std::string(
"UNKNOWN") : obj.
type() ) <<
'-' << obj.
checksum();
151 const std::string & type( obj.
type() );
154 if ( ! type.empty() ) str <<
" type=\"" << type <<
"\"";
158 str <<
">" <<
checksum <<
"</checksum>";
168 {
return ! ( lhs == rhs ); }
std::string digest()
get hex string representation of the digest
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
std::ostream & dumpAsXmlOn(std::ostream &str, const CheckSum &obj)
static const std::string & shaType()
String related utilities and Regular expression matching.
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
std::string asString() const
static const std::string & sha256Type()
std::ostream & operator<<(std::ostream &str, const Exception &obj)
#define _(MSG)
Return translated text.
std::string checksum() const
std::string toLower(const std::string &s)
Return lowercase version of s.
static const std::string & sha1Type()
std::string checksum(const Pathname &file, const std::string &algorithm)
Compute a files checksum.
bool operator!=(const CheckSum &lhs, const CheckSum &rhs)
CheckSum()
Default Ctor: empty checksum.
bool operator==(const CheckSum &lhs, const CheckSum &rhs)
static const std::string & md5Type()
Easy-to use interface to the ZYPP dependency resolver.