| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

MD5.h

Go to the documentation of this file.
00001 #ifndef MD5_H
00002 #define MD5_H 1
00003 #include "boost/cstdint.hpp"
00004 #include <cstring>
00005 #include <iostream>
00006 #include <sstream>
00007 // ============================================================================
00014 // ============================================================================
00015 
00016 namespace Gaudi 
00017 {
00018   namespace Math 
00019   {
00020 
00021     class MD5 {
00022         private:
00023            class md5_engine;
00024         public:
00025            typedef boost::uint8_t value_type[16];
00026 
00028            MD5() { memset(m_value,0u,sizeof(m_value)); }
00029            static MD5 createInvalid() {  return MD5(); }
00030 
00032            static MD5 compute(const std::string& s);
00033 
00035            template <typename T> static MD5 compute(const T& t) 
00036            { std::ostringstream x; x << t; return compute(x.str()); }
00037 
00039            std::string str() const; 
00040 
00042            static MD5 createFromStringRep(const std::string& s);
00043 
00045            bool invalid() const 
00046            { value_type x; 
00047              return memcmp(m_value,memset(x,0u,sizeof(x)),sizeof(m_value))==0; 
00048            }
00049            bool valid() const { return !invalid(); }
00050 
00052            bool operator< (const MD5& rhs) const 
00053            { return memcmp(m_value,rhs.m_value,sizeof(m_value))<0; }
00054            bool operator> (const MD5& rhs) const 
00055            { return memcmp(m_value,rhs.m_value,sizeof(m_value))>0; }
00056            bool operator==(const MD5& rhs) const 
00057            { return memcmp(m_value,rhs.m_value,sizeof(m_value))==0; }
00058 
00059            bool operator<=(const MD5& rhs) const { return !operator>(rhs); }
00060            bool operator>=(const MD5& rhs) const { return !operator<(rhs); }
00061            bool operator!=(const MD5& rhs) const { return !operator==(rhs); }
00062 
00063         private:
00064            explicit MD5(const value_type& val) { memcpy(m_value,val,sizeof(m_value)); }
00065 
00066            value_type m_value;
00067     };
00068   } // end of namespace Math
00069 } // end of namespace Gaudi
00070 
00071 std::ostream& operator<<(std::ostream& os, const Gaudi::Math::MD5& x) ;
00072 #endif
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:02:57 2011 for LHCbMath by doxygen 1.4.7