1#ifndef XRPL_CONDITIONS_UTILS_H
2#define XRPL_CONDITIONS_UTILS_H
4#include <xrpld/conditions/detail/error.h>
6#include <xrpl/basics/Buffer.h>
7#include <xrpl/basics/Slice.h>
9#include <boost/dynamic_bitset.hpp>
14namespace cryptoconditions {
36 return (p.
type & 0x20) == 0;
48 return (p.
type & 0xC0) == 0;
54 return (p.
type & 0xC0) == 0x40;
60 return (p.
type & 0xC0) == 0x80;
66 return (p.
type & 0xC0) == 0xC0;
136 if (count > s.
size())
153template <
class Integer>
166 if (count > s.
size())
174 size_t const maxLength = isSigned ?
sizeof(Integer) :
sizeof(Integer) + 1;
175 if (count > maxLength)
181 if (!isSigned && (s[0] & (1 << 7)))
188 if (!isSigned && count ==
sizeof(Integer) + 1 && s[0])
197 for (
size_t i = 0; i < count; ++i)
198 v = (v << 8) | (s[i] & 0xff);
200 if (isSigned && (s[0] & (1 << 7)))
202 for (
int i = count; i <
sizeof(Integer); ++i)
203 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 isConstructed(Preamble const &p)
bool isPrivate(Preamble const &p)
bool isContextSpecific(Preamble const &p)
Buffer parseOctetString(Slice &s, std::uint32_t count, std::error_code &ec)
Integer parseInteger(Slice &s, std::size_t count, std::error_code &ec)
bool isPrimitive(Preamble const &p)
bool isApplication(Preamble const &p)
bool isUniversal(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.