20 #ifndef RIPPLE_CONDITIONS_UTILS_H
21 #define RIPPLE_CONDITIONS_UTILS_H
23 #include <ripple/basics/strHex.h>
24 #include <ripple/conditions/impl/error.h>
25 #include <boost/dynamic_bitset.hpp>
35 namespace cryptoconditions {
58 return (p.
type & 0x20) == 0;
72 return (p.
type & 0xC0) == 0;
79 return (p.
type & 0xC0) == 0x40;
86 return (p.
type & 0xC0) == 0x80;
93 return (p.
type & 0xC0) == 0xC0;
108 p.
type = s[0] & 0xE0;
165 if (count > s.
size())
182 template <
class Integer>
195 if (count > s.
size())
203 const size_t maxLength = isSigned ?
sizeof(Integer) :
sizeof(Integer) + 1;
204 if (count > maxLength)
210 if (!isSigned && (s[0] & (1 << 7)))
217 if (!isSigned && count ==
sizeof(Integer) + 1 && s[0])
226 for (
size_t i = 0; i < count; ++i)
227 v = (v << 8) | (s[i] & 0xff);
229 if (isSigned && (s[0] & (1 << 7)))
231 for (
int i = count; i <
sizeof(Integer); ++i)
232 v |= (Integer(0xff) << (8 * i));
std::size_t size() const noexcept
Returns the number of bytes in the storage.
Buffer parseOctetString(Slice &s, std::uint32_t count, std::error_code &ec)
bool isApplication(Preamble const &p)
An immutable linear range of bytes.
std::uint8_t const * data() const noexcept
Return a pointer to beginning of the storage.
Integer parseInteger(Slice &s, std::size_t count, std::error_code &ec)
Like std::vector<char> but better.
bool empty() const noexcept
Return true if the byte range is empty.
bool isConstructed(Preamble const &p)
bool isPrimitive(Preamble const &p)
bool isContextSpecific(Preamble const &p)
bool isPrivate(Preamble const &p)
Preamble parsePreamble(Slice &s, std::error_code &ec)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
bool isUniversal(Preamble const &p)