2 // This file is part of the aMule Project.
4 // Copyright (c) 2004-2008 Angel Vidal (Kry) ( kry@amule.org )
5 // Copyright (c) 2004-2008 aMule Team ( admin@amule.org / http://www.amule.org )
6 // Copyright (c) 2003 Barry Dunne (http://www.emule-project.net)
8 // Any parts of this program derived from the xMule, lMule or eMule project,
9 // or contributed by third-party developers are copyrighted by their
10 // respective authors.
12 // This program is free software; you can redistribute it and/or modify
13 // it under the terms of the GNU General Public License as published by
14 // the Free Software Foundation; either version 2 of the License, or
15 // (at your option) any later version.
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 Please do not change anything here and release it..
30 There is going to be a new forum created just for the Kademlia side of the client..
31 If you feel there is an error or a way to improve something, please
32 post it in the forum first and let us look at it.. If it is a real improvement,
33 it will be added to the offical client.. Changing something without knowing
34 what all it does can cause great harm to the network if released in mass form..
35 Any mod that changes anything within the Kademlia side will not be allowed to advertise
36 there client on the eMule forum..
42 #include "../../Types.h"
44 ////////////////////////////////////////
46 ////////////////////////////////////////
53 explicit CUInt128(bool fill
);
54 explicit CUInt128(uint32 value
);
55 explicit CUInt128(const byte
*valueBE
);
57 * Generates a new number, copying the most significant 'numBits' bits from 'value'.
58 * The remaining bits are randomly generated.
60 CUInt128(const CUInt128
&value
, uint32 numBits
= 128);
64 const byte
* GetData() const { return (byte
*)m_data
; }
65 byte
* GetDataPtr() const { return (byte
*)m_data
; }
67 /** Bit at level 0 being most significant. */
68 uint32
GetBitNumber(uint32 bit
) const;
69 int CompareTo(const CUInt128
&other
) const;
70 int CompareTo(uint32 value
) const;
72 wxString
ToHexString(void) const;
73 wxString
ToBinaryString(bool trim
= false) const;
74 void ToByteArray(byte
*b
) const;
76 uint32
Get32BitChunk(int val
) const {return m_data
[val
];}
78 CUInt128
& SetValue(const CUInt128
&value
);
79 CUInt128
& SetValue(uint32 value
);
80 CUInt128
& SetValueBE(const byte
*valueBE
);
82 CUInt128
& SetValueRandom(void);
83 // CUInt128& SetValueGUID(void);
85 CUInt128
& SetBitNumber(uint32 bit
, uint32 value
);
86 CUInt128
& ShiftLeft(uint32 bits
);
88 CUInt128
& Add(const CUInt128
&value
);
89 CUInt128
& Add(uint32 value
);
90 CUInt128
& Subtract(const CUInt128
&value
);
91 CUInt128
& Subtract(uint32 value
);
93 CUInt128
& XOR(const CUInt128
&value
);
94 CUInt128
& XORBE(const byte
*valueBE
);
96 void operator+ (const CUInt128
&value
) {Add(value
);}
97 void operator- (const CUInt128
&value
) {Subtract(value
);}
98 void operator= (const CUInt128
&value
) {SetValue(value
);}
99 bool operator< (const CUInt128
&value
) const {return (CompareTo(value
) < 0);}
100 bool operator> (const CUInt128
&value
) const {return (CompareTo(value
) > 0);}
101 bool operator<= (const CUInt128
&value
) const {return (CompareTo(value
) <= 0);}
102 bool operator>= (const CUInt128
&value
) const {return (CompareTo(value
) >= 0);}
103 bool operator== (const CUInt128
&value
) const {return (CompareTo(value
) == 0);}
104 bool operator!= (const CUInt128
&value
) const {return (CompareTo(value
) != 0);}
106 void operator+ (uint32 value
) {Add(value
);}
107 void operator- (uint32 value
) {Subtract(value
);}
108 void operator= (uint32 value
) {SetValue(value
);}
109 bool operator< (uint32 value
) const {return (CompareTo(value
) < 0);}
110 bool operator> (uint32 value
) const {return (CompareTo(value
) > 0);}
111 bool operator<= (uint32 value
) const {return (CompareTo(value
) <= 0);}
112 bool operator>= (uint32 value
) const {return (CompareTo(value
) >= 0);}
113 bool operator== (uint32 value
) const {return (CompareTo(value
) == 0);}
114 bool operator!= (uint32 value
) const {return (CompareTo(value
) != 0);}
124 // File_checked_for_headers