Skip to content
Snippets Groups Projects
Commit 02f34594 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: SHA1Digest::str() returns std::string of digest directly

parent 7f7f3976
Branches
Tags
No related merge requests found
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 20101-2011 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......
......@@ -101,6 +101,22 @@ bool Foam::SHA1Digest::empty() const
}
std::string Foam::SHA1Digest::str() const
{
std::string buf;
buf.resize(length*2);
unsigned nChar = 0;
for (unsigned i = 0; i < length; ++i)
{
buf[nChar++] = hexChars[((v_[i] >> 4) & 0xF)];
buf[nChar++] = hexChars[(v_[i] & 0xF)];
}
return buf;
}
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
bool Foam::SHA1Digest::operator==(const SHA1Digest& rhs) const
......
......@@ -80,6 +80,9 @@ public:
//- Return true if the digest is empty (ie, all zero).
bool empty() const;
//- Return string representation
std::string str() const;
//- Equality operator
bool operator==(const SHA1Digest&) const;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment