38static const char hexChars[] =
"0123456789abcdef";
67 else if (!isxdigit(c))
70 <<
"Illegal hex digit: '" << c <<
"'"
86 std::array<unsigned char, 20>& digest,
87 const unsigned char* content,
96 if (len == digest.size())
98 std::copy_n(content, len, digest.data());
110 if (len != 2*digest.size())
115 for (
auto& val : digest)
117 const unsigned char upp = *content++;
118 const unsigned char low = *content++;
120 val = (upp << 4) + low;
130 const std::array<unsigned char, 20>& digest,
131 const char* hexdigits,
136 if (*hexdigits ==
'_')
143 if (len != 2*digest.size())
148 for (
const auto& byteVal : digest)
150 const char upp =
hexChars[((byteVal >> 4) & 0xF)];
151 const char low =
hexChars[(byteVal & 0xF)];
153 if (upp != *hexdigits++)
return false;
154 if (low != *hexdigits++)
return false;
174 assign(dig_,
reinterpret_cast<const unsigned char*
>(content), len);
181 assign(dig_, content, len);
202 for (
const auto& byteVal : dig_)
216 for (
auto& byteVal : dig_)
221 byteVal = (upp << 4) + low;
236 buf.resize(1 + 2*dig_.size());
241 buf.resize(2*dig_.size());
244 for (
const auto& byteVal : dig_)
246 buf[nChar++] =
hexChars[((byteVal >> 4) & 0xF)];
261 for (
const auto& byteVal : dig_)
276 return (dig_ ==
rhs.dig_);
283 size_t len = hexdigits.length();
285 return len ? isEqual(dig_, hexdigits.data(), len) :
empty();
292 size_t len = (hexdigits ? strlen(hexdigits) : 0);
294 return len ? isEqual(dig_, hexdigits, len) : empty();
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
static const char hexChars[]
static constexpr int offsetAlpha
static constexpr int offsetZero
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)....
virtual Istream & read(token &)=0
Return next token from stream.
virtual Ostream & write(const char c) override
Write character.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
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()
Default construct a zero digest.
Ostream & write(Ostream &os, const bool prefixed=false) const
Write (40-byte) text representation, optionally with '_' prefix.
bool operator==(const SHA1Digest &rhs) const
Equality operator.
void clear()
Reset the digest to zero.
static const SHA1Digest null
A null digest (ie, all zero).
Istream & read(Istream &is)
Read (40-byte) text representation.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
OBJstream os(runTime.globalPath()/outputName)
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 read(const char *buf, int32_t &val)
Same as readInt32.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
Istream & operator>>(Istream &, directionInfo &)
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
static unsigned char readHexDigit(Istream &is)
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr bool isdigit(char c) noexcept
Test for digits [0-9] (C-locale only).