36 static const char hexChars[] =
"0123456789abcdef";
42 unsigned char Foam::SHA1Digest::readHexDigit(Istream& is)
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)
265 unsigned char c1 = SHA1Digest::readHexDigit(is);
266 unsigned char c2 = SHA1Digest::readHexDigit(is);
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...
virtual bool check(const char *operation) const
Check IOstream status for given operation.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
virtual Ostream & write(const char)=0
Write character.
bool operator==(const SHA1Digest &) const
Equality operator.
std::string str(const bool prefixed=false) const
Return (40-byte) text representation, optionally with '_' prefix.
bool empty() const
Return true if the digest is empty (ie, all zero).
SHA1Digest()
Construct a zero digest.
static const unsigned length
The length of the (uncoded) digest contents.
Ostream & write(Ostream &, const bool prefixed=false) const
Write (40-byte) text representation, optionally with '_' prefix.
void clear()
Reset the digest to zero.
static const SHA1Digest null
A null digest (ie, all zero)
bool operator!=(const SHA1Digest &) const
Inequality operator.
void read(const dictionary &)
Update the value of dimensioned<Type>
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
const dimensionedScalar c1
First radiation constant: default SI units: [W/m^2].
const dimensionedScalar c2
Second radiation constant: default SI units: [m K].
const dimensionedScalar c
Speed of light in a vacuum.
errorManipArg< error, int > exit(error &err, const int errNo=1)
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
Istream & operator>>(Istream &, pistonPointEdgeData &)
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)