Developers.Hash.Refactor: Difference between revisions

From Shareaza Wiki
Jump to navigation Jump to search
(Importing page from Tikiwiki)
 
m (1 revision)
 

Latest revision as of 20:09, 20 June 2009

design your own interface to buffers, hashing, and guids define CData in Buffer.h have static memory to hold guids or hashes that are named Buffer16, Buffer20, and Buffer24 get your ToBase16, 32, 32 functions in the alpha branch add features to cbuffer to use it like packet

you could write your own little classes on top of camper's code they would convert hashing into your interface shareaza could then use both

the CBuffer class is a smart, optimized buffer that can hold any size and has a lot of features in addition to that, there are static sized small classes that are faster and simpler they have names like Buffer16, Buffer20, and Buffer24 instead of naming the value types based on what is inside, like GUID, GGUID, MD4, and MD5, just use a Buffer16 for all of those it's easy to load Buffer16 values in and out of CBuffer objects

a function can return a Buffer16 value, just like it can return a CData value <source lang="c"> before:

   Buffer16 guid;
   MakeGuid(&guid);

after:

   Buffer16 guid = MakeGuid();

</source>

separate all text encoding from everything else have it do any length add base 62 to base 16 and base 32 remove uri headers, do that with strings and find


all refactored, it would look like this

put in CData, and have an advanced and simple CBuffer use it no special types for values, instead use Buffer16, Buffer20, and Buffer24 everywehre something needs to return a variable length data, use CBuffer perfect interfaces on each hashing object, groups of methods to call in a set are named to look like they belong in a group commented and documented and understood down to C functions that actually hash data inside the C functions that actually hash data, an if switches between optimised C and faster assembly, and you can switch them to get the same result

Buffer16 Buffer20 Buffer24 CBuffer

CGuid CHashMd4 CHashMd5 CHashSha1 CHashTiger CHashTigerTree CHashDonkey

ToBase16 ToBase32 ToBase62 FromBase16 FromBase32 FromBase62

have Hash.h and Hash.cpp contain all the stateless, objectless, C function and assembly number crunching of each hash algorithm

no special types for kinds of values, just buffer types no namespaces, no throwing exceptions just well named and well documented classes that are shown together

when you open up the project, all the .h and .cpp files are there, in one big list, in alphabetical order when you look at the documentation, groups of them are described and introduced together this makes a lot more sense than trying to put that grouping into the code or the project itself, with namespaces, file names, file system folders, or visual studio folders