3#include <xrpl/basics/Buffer.h>
4#include <xrpl/basics/Slice.h>
5#include <xrpl/conditions/detail/error.h>
7#include <boost/dynamic_bitset.hpp>
12namespace cryptoconditions {
34 return (p.
type & 0x20) == 0;
46 return (p.
type & 0xC0) == 0;
52 return (p.
type & 0xC0) == 0x40;
58 return (p.
type & 0xC0) == 0x80;
64 return (p.
type & 0xC0) == 0xC0;
134 if (count > s.
size())
151template <
class Integer>
164 if (count > s.
size())
172 size_t const maxLength = isSigned ?
sizeof(Integer) :
sizeof(Integer) + 1;
173 if (count > maxLength)
179 if (!isSigned && (s[0] & (1 << 7)))
186 if (!isSigned && count ==
sizeof(Integer) + 1 && s[0])
195 for (
size_t i = 0; i < count; ++i)
196 v = (v << 8) | (s[i] & 0xff);
198 if (isSigned && (s[0] & (1 << 7)))
200 for (
int i = count; i <
sizeof(Integer); ++i)
201 v |= (Integer(0xff) << (8 * i));
Like std::vector<char> but better.
An immutable linear range of bytes.
bool empty() const noexcept
Return true if the byte range is empty.
std::uint8_t const * data() const noexcept
Return a pointer to beginning of the storage.
std::size_t size() const noexcept
Returns the number of bytes in the storage.
bool isPrimitive(Preamble const &p)
Integer parseInteger(Slice &s, std::size_t count, std::error_code &ec)
bool isApplication(Preamble const &p)
bool isContextSpecific(Preamble const &p)
Buffer parseOctetString(Slice &s, std::uint32_t count, std::error_code &ec)
bool isConstructed(Preamble const &p)
bool isPrivate(Preamble const &p)
Preamble parsePreamble(Slice &s, std::error_code &ec)
bool isUniversal(Preamble const &p)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.