Go to the documentation of this file.
36 static const char hexChars[] =
"0123456789abcdef";
45 static const int alphaOffset = toupper(
'A') - 10;
47 static const int zeroOffset = int(
'0');
61 <<
"Illegal hex digit: '" <<
c <<
"'"
67 return int(
c) - zeroOffset;
71 return toupper(
c) - alphaOffset;
94 memset(v_, 0, length);
100 for (
unsigned i = 0; i < length; ++i)
119 buf.resize(1 + length*2);
124 buf.resize(length*2);
127 for (
unsigned i = 0; i < length; ++i)
129 buf[nChar++] = hexChars[((v_[i] >> 4) & 0xF)];
130 buf[nChar++] = hexChars[(v_[i] & 0xF)];
144 for (
unsigned i = 0; i < length; ++i)
146 os.
write(hexChars[((v_[i] >> 4) & 0xF)]);
147 os.
write(hexChars[(v_[i] & 0xF)]);
150 os.
check(
"SHA1Digest::write(Ostream&, const bool)");
159 for (
unsigned i = 0; i < length; ++i)
161 if (v_[i] != rhs.
v_[i])
174 if (hexdigits.empty())
181 if (hexdigits[0] ==
'_')
187 if (hexdigits.size() != charI + length*2)
192 for (
unsigned i = 0; i < length; ++i)
194 const char c1 = hexChars[((v_[i] >> 4) & 0xF)];
195 const char c2 = hexChars[(v_[i] & 0xF)];
197 if (
c1 != hexdigits[charI++])
return false;
198 if (
c2 != hexdigits[charI++])
return false;
208 if (!hexdigits || !*hexdigits)
215 if (hexdigits[0] ==
'_')
221 if (strlen(hexdigits) != charI + length*2)
226 for (
unsigned i = 0; i < length; ++i)
228 const char c1 = hexChars[((v_[i] >> 4) & 0xF)];
229 const char c2 = hexChars[(v_[i] & 0xF)];
231 if (
c1 != hexdigits[charI++])
return false;
232 if (
c2 != hexdigits[charI++])
return false;
261 unsigned char *v = dig.
v_;
263 for (
unsigned i = 0; i < dig.
length; ++i)
268 v[i] = (
c1 << 4) +
c2;
271 is.
check(
"Istream& operator>>(Istream&, SHA1Digest&)");
278 return dig.
write(os);
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
Ostream & write(Ostream &, const bool prefixed=false) const
Write (40-byte) text representation, optionally with '_' prefix.
SHA1Digest()
Construct a zero digest.
bool operator==(const SHA1Digest &) const
Equality operator.
static const unsigned length
The length of the (uncoded) digest contents.
void clear()
Reset the digest to zero.
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
static unsigned char readHexDigit(Istream &)
Read hexadecimal value, ignoring leading or intermediate '_'.
static const SHA1Digest null
A null digest (ie, all zero)
bool empty() const
Return true if the digest is empty (ie, all zero).
const dimensionedScalar c1
First radiation constant: default SI units: [W/m2].
unsigned char v_[length]
The digest contents.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
virtual Ostream & write(const token &)=0
Write next token to stream.
Ostream & operator<<(Ostream &, const edgeMesh &)
virtual bool check(const char *operation) const
Check IOstream status for given operation.
const dimensionedScalar c2
Second radiation constant: default SI units: [m.K].
errorManipArg< error, int > exit(error &err, const int errNo=1)
bool operator!=(const SHA1Digest &) const
Inequality operator.
Istream & operator>>(Istream &, edgeMesh &)
const dimensionedScalar c
Speed of light in a vacuum.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
std::string str(const bool prefixed=false) const
Return (40-byte) text representation, optionally with '_' prefix.
virtual Istream & read(token &)=0
Return next token from stream.