37 static const char hexChars[] =
"0123456789abcdef";
66 else if (!isxdigit(
c))
69 <<
"Illegal hex digit: '" <<
c <<
"'" 81 bool Foam::SHA1Digest::isEqual(
const char* hexdigits, std::size_t len)
const 84 if (*hexdigits ==
'_')
91 if (len != 2*dig_.size())
96 for (
const auto& byteVal : dig_)
98 const char upp =
hexChars[((byteVal >> 4) & 0xF)];
99 const char low =
hexChars[(byteVal & 0xF)];
101 if (upp != *hexdigits++)
return false;
102 if (low != *hexdigits++)
return false;
134 for (
const auto& byteVal : dig_)
148 for (
auto& byteVal : dig_)
153 byteVal = (upp << 4) + low;
164 std::size_t nChar = 0;
168 buf.resize(1 + 2*dig_.size());
173 buf.resize(2*dig_.size());
176 for (
const auto& byteVal : dig_)
178 buf[nChar++] =
hexChars[((byteVal >> 4) & 0xF)];
193 for (
const auto& byteVal : dig_)
208 return (dig_ == rhs.dig_);
215 size_t len = hexdigits.length();
217 return len ? isEqual(hexdigits.data(), len) : empty();
224 size_t len = (hexdigits ? strlen(hexdigits) : 0);
226 return len ? isEqual(hexdigits, len) : empty();
static constexpr int offsetZero
virtual Ostream & write(const char c)
Write character.
errorManipArg< error, int > exit(error &err, const int errNo=1)
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)...
bool operator!=(const SHA1Digest &rhs) const
Inequality operator.
bool read(const char *buf, int32_t &val)
Same as readInt32.
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
virtual Istream & read(token &)=0
Return next token from stream.
static const char hexChars[]
Istream & operator>>(Istream &, directionInfo &)
SHA1Digest()
Default construct a zero digest.
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
bool empty() const
Return true if the digest is empty (ie, all zero).
OBJstream os(runTime.globalPath()/outputName)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Ostream & write(Ostream &os, const bool prefixed=false) const
Write (40-byte) text representation, optionally with '_' prefix.
static constexpr int offsetAlpha
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
void clear()
Reset the digest to zero.
static unsigned char readHexDigit(Istream &is)
bool operator==(const SHA1Digest &rhs) const
Equality operator.
const dimensionedScalar c
Speed of light in a vacuum.
std::string str(const bool prefixed=false) const
Return (40-byte) text representation, optionally with '_' prefix.
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
Istream & read(Istream &is)
Read (40-byte) text representation.
static const SHA1Digest null
A null digest (ie, all zero)
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...