37 static const char hexChars[] =
"0123456789abcdef";
66 else if (!isxdigit(
c))
69 <<
"Illegal hex digit: '" <<
c <<
"'" 85 std::array<unsigned char, 20>& digest,
86 const unsigned char* content,
95 if (len == digest.size())
98 for (
auto& val : digest)
115 if (len != 2*digest.size())
120 for (
auto& val : digest)
122 const unsigned char upp = *content++;
123 const unsigned char low = *content++;
125 val = (upp << 4) + low;
135 const std::array<unsigned char, 20>& digest,
136 const char* hexdigits,
141 if (*hexdigits ==
'_')
148 if (len != 2*digest.size())
153 for (
const auto& byteVal : digest)
155 const char upp =
hexChars[((byteVal >> 4) & 0xF)];
156 const char low =
hexChars[(byteVal & 0xF)];
158 if (upp != *hexdigits++)
return false;
159 if (low != *hexdigits++)
return false;
179 assign(dig_, reinterpret_cast<const unsigned char*>(content), len);
186 assign(dig_, content, len);
207 for (
const auto& byteVal : dig_)
221 for (
auto& byteVal : dig_)
226 byteVal = (upp << 4) + low;
237 std::size_t nChar = 0;
241 buf.resize(1 + 2*dig_.size());
246 buf.resize(2*dig_.size());
249 for (
const auto& byteVal : dig_)
251 buf[nChar++] =
hexChars[((byteVal >> 4) & 0xF)];
266 for (
const auto& byteVal : dig_)
281 return (dig_ == rhs.dig_);
288 size_t len = hexdigits.length();
290 return len ? isEqual(dig_, hexdigits.data(), len) : empty();
297 size_t len = (hexdigits ? strlen(hexdigits) : 0);
299 return len ? isEqual(dig_, hexdigits, len) : empty();
static constexpr int offsetZero
errorManipArg< error, int > exit(error &err, const int errNo=1)
virtual Ostream & write(const char c) override
Write character.
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...
void assign(Field< Tout > &result, const Field< T1 > &a, const UnaryOp &op)
Populate a field as the result of a unary operation on an input.
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 ...