CP2PListLibrary 1.0
|
00001 /* 00002 Copyright (C) 2004-2005 Cory Nelson 00003 00004 This software is provided 'as-is', without any express or implied 00005 warranty. In no event will the authors be held liable for any damages 00006 arising from the use of this software. 00007 00008 Permission is granted to anyone to use this software for any purpose, 00009 including commercial applications, and to alter it and redistribute it 00010 freely, subject to the following restrictions: 00011 00012 1. The origin of this software must not be misrepresented; you must not 00013 claim that you wrote the original software. If you use this software 00014 in a product, an acknowledgment in the product documentation would be 00015 appreciated but is not required. 00016 2. Altered source versions must be plainly marked as such, and must not be 00017 misrepresented as being the original software. 00018 3. This notice may not be removed or altered from any source distribution. 00019 00020 CVS Info : 00021 $Author: phrostbyte $ 00022 $Date: 2005/06/30 18:26:00 $ 00023 $Revision: 1.6 $ 00024 */ 00025 00026 #ifndef __P2P_RANGE_HPP__ 00027 #define __P2P_RANGE_HPP__ 00028 00029 #include <string> 00030 #include <ostream> 00031 #include <p2p/ip.hpp> 00032 00033 namespace p2p { 00034 struct range { 00035 typedef std::wstring string_type; 00036 00037 string_type name; 00038 ip start, end; 00039 00040 range() {} 00041 range(const string_type &name) : name(name) {} 00042 range(const string_type &name, const ip &start, const ip &end) : name(name),start(start),end(end) {} 00043 00044 bool operator<(const range &range) const { 00045 return (this->start<range.start) | (this->start==range.start && this->end<range.end); 00046 } 00047 bool operator>(const range &range) const { 00048 return (this->start>range.start) | (this->start==range.start && this->end>range.end); 00049 } 00050 bool operator==(const range &range) const { 00051 return (this->start>=range.start && this->end<=range.end); 00052 } 00053 }; 00054 } 00055 00056 #endif