00001 #ifndef URLRANGE_H 00002 #define URLRANGE_H 00003 00004 #include <abuse/Url.h> 00005 00006 class UrlRange 00007 { 00008 public: 00009 UrlRange(const Url& f,const Url& to); 00010 UrlRange(const Url& f,unsigned char netw); 00011 UrlRange(const std::string& range)throw(std::runtime_error); 00012 Url from; 00013 Url to; 00014 unsigned char netwidth; 00015 bool operator==(const UrlRange& other)const 00016 { 00017 return ((from==other.from)&&(to==other.to)); 00018 } 00019 bool operator!=(const UrlRange& other)const 00020 { 00021 return !(*this==other); 00022 } 00023 bool operator<(const UrlRange& other)const 00024 { 00025 if(from!=other.from) 00026 return from<other.from; 00027 //WATCH OUT!! it was to<other.to, I've corrected, 00028 //but I don't sincerely know how it could affect the legacy code... 00029 return to>other.to; 00030 } 00031 bool contains(const in_addr& addr)const; 00032 bool contains(const UrlRange& other)const; 00033 bool overlaps(const UrlRange& other)const; 00034 int size()const; 00035 bool empty()const; 00036 private: 00037 void rangeFromNetwidth(const Url& from,unsigned char netw); 00038 }; 00039 00040 #endif