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>
31 return (p.
type & 0x20) == 0;
43 return (p.
type & 0xC0) == 0;
49 return (p.
type & 0xC0) == 0x40;
55 return (p.
type & 0xC0) == 0x80;
61 return (p.
type & 0xC0) == 0xC0;
89 if ((p.
length & 0x80) != 0u)
131 if (count > s.
size())
148template <
class Integer>
161 if (count > s.
size())
169 size_t const maxLength = isSigned ?
sizeof(Integer) :
sizeof(Integer) + 1;
170 if (count > maxLength)
176 if (!isSigned && (s[0] & (1 << 7)))
183 if (!isSigned && count ==
sizeof(Integer) + 1 && s[0])
192 for (
size_t i = 0; i < count; ++i)
193 v = (v << 8) | (s[i] & 0xff);
195 if (isSigned && (s[0] & (1 << 7)))
197 for (
int i = count; i <
sizeof(Integer); ++i)
198 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)