1#ifndef XRPL_BASICS_RANGESET_H_INCLUDED
2#define XRPL_BASICS_RANGESET_H_INCLUDED
4#include <xrpl/beast/core/LexicalCast.h>
6#include <boost/algorithm/string.hpp>
7#include <boost/icl/closed_interval.hpp>
8#include <boost/icl/interval_set.hpp>
51using RangeSet = boost::icl::interval_set<T, std::less, ClosedInterval<T>>;
66 if (ci.first() == ci.last())
87 for (
auto const& interval : rs)
112 boost::split(tokens, s, boost::algorithm::is_any_of(
","));
113 for (
auto const& t : tokens)
115 boost::split(intervals, t, boost::algorithm::is_any_of(
"-"));
116 switch (intervals.
size())
136 rs.insert(
range(front, back));
166 if (rs.empty() || t == minVal)
172 return boost::icl::last(tgt);
bool lexicalCastChecked(Out &out, In in)
Intelligently convert from one type to another.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::optional< T > prevMissing(RangeSet< T > const &rs, T t, T minVal=0)
Find the largest value not in the set that is less than a given value.
boost::icl::closed_interval< T > ClosedInterval
A closed interval over the domain T.
bool from_string(RangeSet< T > &rs, std::string const &s)
Convert the given styled string to a RangeSet.
boost::icl::interval_set< T, std::less, ClosedInterval< T > > RangeSet
A set of closed intervals over the domain T.
std::string to_string(base_uint< Bits, Tag > const &a)
ClosedInterval< T > range(T low, T high)
Create a closed range interval.