Crashpad
Public Member Functions | List of all members
crashpad::CheckedRange< ValueType, SizeType > Class Template Reference

Ensures that a range, composed of a base and size, does not overflow its data type. More...

#include "util/numeric/checked_range.h"

Public Member Functions

 CheckedRange (ValueType base, SizeType size)
 
void SetRange (ValueType base, SizeType size)
 Sets the range’s base and size to base and size, respectively.
 
ValueType base () const
 The range’s base.
 
SizeType size () const
 The range’s size.
 
ValueType end () const
 The range’s end (its base plus its size).
 
bool IsValid () const
 Returns the validity of the range. More...
 
bool ContainsValue (ValueType value) const
 Returns whether the range contains another value. More...
 
bool ContainsRange (const CheckedRange< ValueType, SizeType > &that) const
 Returns whether the range contains another range. More...
 
bool OverlapsRange (const CheckedRange< ValueType, SizeType > &that) const
 Returns whether the range overlaps another range. More...
 
bool operator< (const CheckedRange &other) const
 

Detailed Description

template<typename ValueType, typename SizeType = ValueType>
class crashpad::CheckedRange< ValueType, SizeType >

Ensures that a range, composed of a base and size, does not overflow its data type.

Member Function Documentation

◆ ContainsRange()

template<typename ValueType , typename SizeType = ValueType>
bool crashpad::CheckedRange< ValueType, SizeType >::ContainsRange ( const CheckedRange< ValueType, SizeType > &  that) const
inline

Returns whether the range contains another range.

Parameters
[in]thatThe (possibly) contained range.
Returns
true if this range, the containing range, contains that, the contained range. false otherwise.

A range contains another range when the contained range’s base is greater than or equal to the containing range’s base, and the contained range’s end is less than or equal to the containing range’s end.

This method must only be called if IsValid() would return true for both CheckedRange objects involved.

◆ ContainsValue()

template<typename ValueType , typename SizeType = ValueType>
bool crashpad::CheckedRange< ValueType, SizeType >::ContainsValue ( ValueType  value) const
inline

Returns whether the range contains another value.

Parameters
[in]valueThe (possibly) contained value.
Returns
true if the range contains value, false otherwise.

A range contains a value if the value is greater than or equal to its base, and less than its end (base plus size).

This method must only be called if IsValid() would return true.

◆ IsValid()

template<typename ValueType , typename SizeType = ValueType>
bool crashpad::CheckedRange< ValueType, SizeType >::IsValid ( ) const
inline

Returns the validity of the range.

Returns
true if the range is valid, false otherwise.

A range is valid if its size can be converted to the range’s data type without data loss, and if its end (base plus size) can be computed without overflowing its data type.

◆ OverlapsRange()

template<typename ValueType , typename SizeType = ValueType>
bool crashpad::CheckedRange< ValueType, SizeType >::OverlapsRange ( const CheckedRange< ValueType, SizeType > &  that) const
inline

Returns whether the range overlaps another range.

Parameters
[in]thatThe (possibly) overlapping range.
Returns
true if this range, the first range, overlaps that, the provided range. false otherwise.

Ranges are considered to be closed-open [base, end) for this test. Zero length ranges are never considered to overlap another range.

This method must only be called if IsValid() would return true for both CheckedRange objects involved.


The documentation for this class was generated from the following file: