20#ifndef RIPPLE_CONDITIONS_UTILS_H
21#define RIPPLE_CONDITIONS_UTILS_H
23#include <xrpld/conditions/detail/error.h>
24#include <xrpl/basics/Buffer.h>
25#include <xrpl/basics/Slice.h>
26#include <xrpl/basics/strHex.h>
27#include <boost/dynamic_bitset.hpp>
37namespace cryptoconditions {
59 return (p.
type & 0x20) == 0;
71 return (p.
type & 0xC0) == 0;
77 return (p.
type & 0xC0) == 0x40;
83 return (p.
type & 0xC0) == 0x80;
89 return (p.
type & 0xC0) == 0xC0;
103 p.
type = s[0] & 0xE0;
159 if (count > s.
size())
176template <
class Integer>
189 if (count > s.
size())
197 const size_t maxLength = isSigned ?
sizeof(Integer) :
sizeof(Integer) + 1;
198 if (count > maxLength)
204 if (!isSigned && (s[0] & (1 << 7)))
211 if (!isSigned && count ==
sizeof(Integer) + 1 && s[0])
220 for (
size_t i = 0; i < count; ++i)
221 v = (v << 8) | (s[i] & 0xff);
223 if (isSigned && (s[0] & (1 << 7)))
225 for (
int i = count; i <
sizeof(Integer); ++i)
226 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.