retdec
Public Types | Public Member Functions | Protected Attributes | Friends | List of all members
retdec::common::Range< T > Class Template Reference

#include <range.h>

Inheritance diagram for retdec::common::Range< T >:
Inheritance graph
[legend]

Public Types

using RangeType = T
 

Public Member Functions

 Range ()
 
 Range (const RangeType &start, const RangeType &end)
 
 Range (const Range< RangeType > &range)
 
 Range (Range< RangeType > &&range) noexcept(std::is_nothrow_move_constructible< RangeType >::value)
 
virtual ~Range ()=default
 
Rangeoperator= (const Range< RangeType > &rhs)=default
 
Rangeoperator= (Range< RangeType > &&rhs)=default
 
const RangeTypegetStart () const
 
const RangeTypegetEnd () const
 
void setStart (const RangeType &start)
 
void setEnd (const RangeType &end)
 
void setStartEnd (const RangeType &start, const RangeType &end)
 
RangeType getSize () const
 
bool contains (const RangeType &value) const
 
bool contains (const Range< RangeType > &o) const
 
bool overlaps (const Range< RangeType > &o) const
 
bool operator== (const Range< RangeType > &rhs) const
 
bool operator< (const Range< RangeType > &rhs) const
 
bool operator!= (const Range< RangeType > &rhs) const
 

Protected Attributes

RangeType _start
 
RangeType _end
 

Friends

std::ostream & operator<< (std::ostream &out, const Range< RangeType > &r)
 

Detailed Description

template<typename T>
class retdec::common::Range< T >

Range <start, end) – including start, excluding end.

Range class can be used to represent the range defined by two specific values, one starting and one ending value. These values can be of any type, but this type must provide subtraction operator and must have relational operators defined.

Template Parameters
Parametrizedtype of the range.

Member Typedef Documentation

◆ RangeType

template<typename T >
using retdec::common::Range< T >::RangeType = T

Constructor & Destructor Documentation

◆ Range() [1/4]

template<typename T >
retdec::common::Range< T >::Range ( )
inline

Default constructor.

◆ Range() [2/4]

template<typename T >
retdec::common::Range< T >::Range ( const RangeType start,
const RangeType end 
)
inline

Constructor for specific range.

Parameters
startThe starting value of the range.
endThe ending value of the range.

◆ Range() [3/4]

template<typename T >
retdec::common::Range< T >::Range ( const Range< RangeType > &  range)
inline

Copy constructor.

Parameters
rangeRange to copy.

◆ Range() [4/4]

template<typename T >
retdec::common::Range< T >::Range ( Range< RangeType > &&  range)
inlinenoexcept

Move constructor.

Parameters
rangeRange to move.

◆ ~Range()

template<typename T >
virtual retdec::common::Range< T >::~Range ( )
virtualdefault

Destructor.

Member Function Documentation

◆ contains() [1/2]

template<typename T >
bool retdec::common::Range< T >::contains ( const Range< RangeType > &  o) const
inline

Checks whether range fully contains given range, i.e. it contains both its start and end.

Parameters
oRange to check.
Returns
True if in range, otherwise false.

◆ contains() [2/2]

template<typename T >
bool retdec::common::Range< T >::contains ( const RangeType value) const
inline

Checks whether range contains given value. It checks for non-strict order.

Parameters
valueValue to check.
Returns
True if in range, otherwise false.

◆ getEnd()

template<typename T >
const RangeType& retdec::common::Range< T >::getEnd ( ) const
inline

Returns the ending value of the range.

Returns
Ending value of the range.

◆ getSize()

template<typename T >
RangeType retdec::common::Range< T >::getSize ( ) const
inline

Returns the size of the range.

Returns
Size of the range.

◆ getStart()

template<typename T >
const RangeType& retdec::common::Range< T >::getStart ( ) const
inline

Returns the starting value of the range.

Returns
Starting value of the range.

◆ operator!=()

template<typename T >
bool retdec::common::Range< T >::operator!= ( const Range< RangeType > &  rhs) const
inline

Return whether two ranges are not equal. They are equal if their starting and ending values are the same.

Returns
True if not equal, otherwise false.

◆ operator<()

template<typename T >
bool retdec::common::Range< T >::operator< ( const Range< RangeType > &  rhs) const
inline

Return whether this range less than rhs. It is less if its starting value is less than rhs starting value.

Returns
True if less, otherwise false.

◆ operator=() [1/2]

template<typename T >
Range& retdec::common::Range< T >::operator= ( const Range< RangeType > &  rhs)
default

Assign operator.

Parameters
rhsRight-hand side of the assignment.
Returns
Assigned object.

◆ operator=() [2/2]

template<typename T >
Range& retdec::common::Range< T >::operator= ( Range< RangeType > &&  rhs)
default

Move-assign operator.

Parameters
rhsRight-hand side of the assignment.
Returns
Assigned object.

◆ operator==()

template<typename T >
bool retdec::common::Range< T >::operator== ( const Range< RangeType > &  rhs) const
inline

Return whether two ranges are equal. They are equal if their starting and ending values are the same.

Returns
True if equal, otherwise false.

◆ overlaps()

template<typename T >
bool retdec::common::Range< T >::overlaps ( const Range< RangeType > &  o) const
inline

Check whether range overlaps with the given range, i.e. there exists some value that which is in both ranges.

◆ setEnd()

template<typename T >
void retdec::common::Range< T >::setEnd ( const RangeType end)
inline

Sets the ending value of the range.

Parameters
endThe ending value of the range.

◆ setStart()

template<typename T >
void retdec::common::Range< T >::setStart ( const RangeType start)
inline

Sets the starting value of the range.

Parameters
startThe starting value of the range.

◆ setStartEnd()

template<typename T >
void retdec::common::Range< T >::setStartEnd ( const RangeType start,
const RangeType end 
)
inline

Sets the starting value of the range.

Parameters
startThe starting value of the range.
endThe ending value of the range.

Friends And Related Function Documentation

◆ operator<<

template<typename T >
std::ostream& operator<< ( std::ostream &  out,
const Range< RangeType > &  r 
)
friend

Member Data Documentation

◆ _end

template<typename T >
RangeType retdec::common::Range< T >::_end
protected

◆ _start

template<typename T >
RangeType retdec::common::Range< T >::_start
protected

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