CheckSum.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #ifndef ZYPP_CHECKSUM_H
00013 #define ZYPP_CHECKSUM_H
00014 
00015 #include <iosfwd>
00016 #include <string>
00017 
00018 #include "zypp/Pathname.h"
00019 
00021 namespace zypp
00022 { 
00023 
00024 
00025   class CheckSum
00026   {
00027   public:
00032     CheckSum( const std::string & type, const std::string & checksum);
00033     CheckSum( const std::string & type, std::istream & input_r );
00034     CheckSum();
00035 
00036   public:
00037     static const std::string & md5Type();
00038     static const std::string & shaType();
00039     static const std::string & sha1Type();
00040     static const std::string & sha256Type();
00041 
00042     static CheckSum md5( const std::string & checksum )
00043     { return  CheckSum( md5Type(), checksum); }
00044     static CheckSum sha( const std::string & checksum )
00045     { return  CheckSum( shaType(), checksum); }
00046     static CheckSum sha1( const std::string & checksum )
00047     { return  CheckSum( sha1Type(), checksum); }
00048     static CheckSum sha256( const std::string & checksum )
00049     { return  CheckSum( sha256Type(), checksum); }
00050 
00051     static CheckSum md5( std::istream & input_r )
00052     { return  CheckSum( md5Type(), input_r ); }
00053     static CheckSum sha( std::istream & input_r )
00054     { return  CheckSum( sha1Type(), input_r ); }
00055     static CheckSum sha1( std::istream & input_r )
00056     { return  CheckSum( sha1Type(), input_r ); }
00057     static CheckSum sha256( std::istream & input_r )
00058     { return  CheckSum( sha256Type(), input_r ); }
00059 
00060   public:
00061     std::string type() const;
00062     std::string checksum() const;
00063     bool empty() const;
00064 
00065   private:
00066     std::string _type;
00067     std::string _checksum;
00068   };
00069 
00071   std::ostream & operator<<( std::ostream & str, const CheckSum & obj );
00072 
00074   bool operator==( const CheckSum & lhs, const CheckSum & rhs );
00075 
00077   bool operator!=( const CheckSum & lhs, const CheckSum & rhs );
00078 
00079 } // namespace zypp
00081 #endif // ZYPP_CHECKSUM_H

Generated on Tue Sep 25 19:23:00 2007 for libzypp by  doxygen 1.5.3