Formatting style

feature/pre-code-move
kaetemi 5 years ago committed by Jan Boon
parent aeb127e011
commit e4883acceb

@ -6,7 +6,7 @@ BraceWrapping:
AfterControlStatement: true AfterControlStatement: true
AfterEnum: true AfterEnum: true
AfterFunction: true AfterFunction: true
AfterNamespace: true AfterNamespace: false
AfterObjCDeclaration: true AfterObjCDeclaration: true
AfterStruct: true AfterStruct: true
AfterUnion: true AfterUnion: true

@ -30,19 +30,19 @@ namespace NLMISC {
struct CHashKey struct CHashKey
{ {
CHashKey () { HashKeyString.resize(20); } CHashKey() { HashKeyString.resize(20); }
CHashKey (const unsigned char Message_Digest[20]) CHashKey(const unsigned char Message_Digest[20])
{ {
HashKeyString.clear(); HashKeyString.clear();
for(sint i = 0; i < 20 ; ++i) for (sint i = 0; i < 20; ++i)
{ {
HashKeyString += Message_Digest[i]; HashKeyString += Message_Digest[i];
} }
} }
// Init the hash key with a binary key format or a text key format // Init the hash key with a binary key format or a text key format
CHashKey (const std::string &str) CHashKey(const std::string &str)
{ {
if (str.size() == 20) if (str.size() == 20)
{ {
@ -69,7 +69,7 @@ struct CHashKey
} }
else else
{ {
nlwarning ("SHA: Bad hash key format"); nlwarning("SHA: Bad hash key format");
} }
} }
@ -85,23 +85,28 @@ struct CHashKey
} }
// serial the hash key in binary format // serial the hash key in binary format
void serial (NLMISC::IStream &stream) void serial(NLMISC::IStream &stream)
{ {
stream.serial (HashKeyString); stream.serial(HashKeyString);
} }
bool operator==(const CHashKey &v) const bool operator==(const CHashKey &v) const
{ {
return HashKeyString == v.HashKeyString; return HashKeyString == v.HashKeyString;
} }
bool operator!=(const CHashKey &v) const
{
return !(*this == v);
}
// this string is always 20 bytes long and is the code in binary format (can't print it directly) // this string is always 20 bytes long and is the code in binary format (can't print it directly)
std::string HashKeyString; std::string HashKeyString;
}; };
inline bool operator <(const struct CHashKey &a,const struct CHashKey &b) inline bool operator<(const struct CHashKey &a, const struct CHashKey &b)
{ {
return a.HashKeyString<b.HashKeyString; return a.HashKeyString < b.HashKeyString;
} }
// This function get a filename (it works with big files) and returns his SHA hash key // This function get a filename (it works with big files) and returns his SHA hash key

Loading…
Cancel
Save