|
| ClosedRange (const HalfOpenRange< Unit, Order > &r) |
|
| ClosedRange (FromTo &&fromTo) |
|
constexpr | ClosedRange (int lo, int hi) |
|
| ClosedRange (MinToMax &&) |
|
| ClosedRange (StartLen &&startLen) |
|
| ClosedRange (std::pair< int, int > range) |
|
| ClosedRange (ZeroToMax &&) |
|
bool | contains (ClosedRange other) const |
|
bool | contains (int index) const |
|
cstring | formatAsSlice (int spaceSize) const |
|
int | hiByte () const |
|
HalfOpenRange< Unit, Order > | intersectWith (ClosedRange a) const |
|
HalfOpenRange< Unit, Order > | intersectWith (int l, int h) const |
|
bool | isHiAligned () const |
|
bool | isLoAligned () const |
|
int | loByte () const |
|
int | nextByte () const |
|
bool | operator!= (ClosedRange other) const |
|
HalfOpenRange< Unit, Order > | operator& (ClosedRange a) const |
|
HalfOpenRange< Unit, Order > | operator&= (ClosedRange a) |
|
bool | operator< (const ClosedRange &other) const |
|
bool | operator== (ClosedRange other) const |
|
ClosedRange | operator| (ClosedRange a) const |
|
ClosedRange | operator|= (ClosedRange a) |
|
bool | overlaps (ClosedRange a) const |
|
bool | overlaps (int l, int h) const |
|
ClosedRange< RangeUnit::Bit, Order > | resizedToBits (int size) const |
|
ClosedRange | resizedToBytes (int size) const |
|
ClosedRange< RangeUnit::Bit, Order > | shiftedByBits (int offset) const |
|
ClosedRange | shiftedByBytes (int offset) const |
|
ssize_t | size () const |
|
void | toJSON (JSONGenerator &json) const |
| JSON serialization/deserialization.
|
|
template<Endian DestOrder> |
ClosedRange< Unit, DestOrder > | toOrder (int spaceSize) const |
|
template<RangeUnit DestUnit> |
ClosedRange< DestUnit, Order > | toUnit () const |
|
ClosedRange | unionWith (ClosedRange a) const |
|
ClosedRange | unionWith (int l, int h) const |
|
template<
RangeUnit Unit,
Endian Order>
struct P4::ClosedRange< Unit, Order >
A closed range of bits or bytes - [lo, hi]
specified in terms of a specific endian order. Closed ranges include both lo
and hi
, so ClosedRange(3, 5)
contains 3
, 4
, and 5
.
Use a closed range when you want to forbid the possibility of an empty range. Using a closed range may also make certain algorithms easier to express.
XXX: ClosedRange's interface is very similar to HalfOpenRange, but they have almost totally different implementations, and the limitations of C++ templates make sharing the things they do have in common challenging. Most of the benefit would have come from sharing documentation; as a compromise, most of the methods in ClosedRange just reference HalfOpenRange's documentation.
XXX: Currently, for backwards compatibility, it's possible to construct ranges where lo
is greater than or equal to hi
. We should enforce that ranges are consistent; we'll add the necessary checks after the existing code has been audited.
XXX: We should also add checks to avoid integer overflow.