20#ifndef RIPPLE_CONDITIONS_UTILS_H
21#define RIPPLE_CONDITIONS_UTILS_H
23#include <xrpld/conditions/detail/error.h>
25#include <xrpl/basics/Buffer.h>
26#include <xrpl/basics/Slice.h>
28#include <boost/dynamic_bitset.hpp>
33namespace cryptoconditions {
55 return (p.
type & 0x20) == 0;
67 return (p.
type & 0xC0) == 0;
73 return (p.
type & 0xC0) == 0x40;
79 return (p.
type & 0xC0) == 0x80;
85 return (p.
type & 0xC0) == 0xC0;
155 if (count > s.
size())
172template <
class Integer>
185 if (count > s.
size())
193 size_t const maxLength = isSigned ?
sizeof(Integer) :
sizeof(Integer) + 1;
194 if (count > maxLength)
200 if (!isSigned && (s[0] & (1 << 7)))
207 if (!isSigned && count ==
sizeof(Integer) + 1 && s[0])
216 for (
size_t i = 0; i < count; ++i)
217 v = (v << 8) | (s[i] & 0xff);
219 if (isSigned && (s[0] & (1 << 7)))
221 for (
int i = count; i <
sizeof(Integer); ++i)
222 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.