Commit 02f34594 authored by Mark Olesen's avatar Mark Olesen
Browse files

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

parent 7f7f3976
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 20101-2011 OpenCFD Ltd. \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
......
...@@ -101,6 +101,22 @@ bool Foam::SHA1Digest::empty() const ...@@ -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 * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
bool Foam::SHA1Digest::operator==(const SHA1Digest& rhs) const bool Foam::SHA1Digest::operator==(const SHA1Digest& rhs) const
......
...@@ -80,6 +80,9 @@ public: ...@@ -80,6 +80,9 @@ public:
//- Return true if the digest is empty (ie, all zero). //- Return true if the digest is empty (ie, all zero).
bool empty() const; bool empty() const;
//- Return string representation
std::string str() const;
//- Equality operator //- Equality operator
bool operator==(const SHA1Digest&) const; bool operator==(const SHA1Digest&) const;
......
Supports Markdown
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