00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #if !defined(MYSQLPP_COMPARABLE_H)
00029 #define MYSQLPP_COMPARABLE_H
00030
00031 namespace mysqlpp {
00032
00039 template <class T>
00040 class Comparable
00041 {
00042 public:
00044 bool operator ==(const T& other) const
00045 {
00046 return !compare(other);
00047 }
00048
00050 bool operator !=(const T& other) const
00051 {
00052 return compare(other);
00053 }
00054
00056 bool operator <(const T& other) const
00057 {
00058 return compare(other) < 0;
00059 }
00060
00062 bool operator <=(const T& other) const
00063 {
00064 return compare(other) <= 0;
00065 }
00066
00068 bool operator >(const T& other) const
00069 {
00070 return compare(other) > 0;
00071 }
00072
00074 bool operator >=(const T& other) const
00075 {
00076 return compare(other) >= 0;
00077 }
00078
00079 protected:
00087 virtual ~Comparable() { }
00088
00093 virtual int compare(const T& other) const = 0;
00094 };
00095
00096 }
00097
00098 #endif // !defined(MYSQLPP_COMPARABLE_H)