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 {
57 return (p.
type & 0x20) == 0;
69 return (p.
type & 0xC0) == 0;
75 return (p.
type & 0xC0) == 0x40;
81 return (p.
type & 0xC0) == 0x80;
87 return (p.
type & 0xC0) == 0xC0;
101 p.
type = s[0] & 0xE0;
157 if (count > s.
size())
174 template <
class Integer>
187 if (count > s.
size())
195 const size_t maxLength = isSigned ?
sizeof(Integer) :
sizeof(Integer) + 1;
196 if (count > maxLength)
202 if (!isSigned && (s[0] & (1 << 7)))
209 if (!isSigned && count ==
sizeof(Integer) + 1 && s[0])
218 for (
size_t i = 0; i < count; ++i)
219 v = (v << 8) | (s[i] & 0xff);
221 if (isSigned && (s[0] & (1 << 7)))
223 for (
int i = count; i <
sizeof(Integer); ++i)
224 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)