GTIRB  v1.10.4
GrammaTech Intermediate Representation for Binaries: C++ API
Public Types | Public Member Functions | Friends | Related Functions | List of all members
gtirb::Addr Class Reference

A special class to store an Effective Address. More...

#include <Addr.hpp>

Public Types

typedef int64_t difference_type
 The type used to represent a difference between two Addr objects. More...
 
typedef uint64_t value_type
 The underlying type used to represent an Addr object. More...
 

Public Member Functions

constexpr Addr () noexcept
 Default constructor. More...
 
constexpr Addr (value_type X) noexcept
 Explicit conversion from value_type to Addr. More...
 
constexpr operator value_type () const noexcept
 Explicitly convert Addr to value_type. More...
 
constexpr Addr operator+ () const noexcept
 Unary plus for Addr. This is a noop because Addr objects represent an unsigned address value. More...
 
constexpr Addroperator++ () noexcept
 Preincrement for Addr. More...
 
constexpr Addr operator++ (int) noexcept
 Postincrement for Addr. More...
 
constexpr Addroperator+= (value_type Offset) noexcept
 Add-assign for Addr. More...
 
constexpr Addroperator-- () noexcept
 Predecrement for Addr. More...
 
constexpr Addr operator-- (int) noexcept
 Postdecrement for Addr. More...
 
constexpr Addroperator-= (value_type Offset) noexcept
 Subtract-assign for Addr. More...
 
constexpr Addr operator~ () const noexcept
 Unary complement for Addr. Flips the value of all bits in the address. More...
 

Friends

constexpr friend bool operator!= (const Addr &LHS, const Addr &RHS) noexcept
 Inquality operator for Addr. More...
 
constexpr friend Addr operator+ (const Addr &A, value_type Offset) noexcept
 Binary + operator for Addr + integral offset. More...
 
constexpr friend Addr operator+ (value_type Offset, const Addr &A) noexcept
 Binary + operator for integral offset + Addr. More...
 
constexpr friend difference_type operator- (const Addr &A, const Addr &B) noexcept
 Binary - operator for Addr - Addr. More...
 
constexpr friend Addr operator- (const Addr &A, value_type Offset) noexcept
 Binary - operator for Addr - integral offset. More...
 
constexpr friend bool operator< (const Addr &LHS, const Addr &RHS) noexcept
 Less-than operator for Addr. More...
 
constexpr friend bool operator<= (const Addr &LHS, const Addr &RHS) noexcept
 Less-than-or-equal operator for Addr. More...
 
constexpr friend bool operator== (const Addr &LHS, const Addr &RHS) noexcept
 Equality operator for Addr. More...
 
constexpr friend bool operator> (const Addr &LHS, const Addr &RHS) noexcept
 Greater-than operator for Addr. More...
 
constexpr friend bool operator>= (const Addr &LHS, const Addr &RHS) noexcept
 Greater-than-or-equal operator for Addr. More...
 

Related Functions

(Note that these are not member functions.)

template<typename T >
std::optional< AddraddressLimit (const T &Object)
 Exclusive upper limit of an object's address range. More...
 
template<typename T >
std::optional< AddrRangeaddressRange (const T &Object)
 Address range of an object. More...
 
template<typename T >
bool containsAddr (const T &Object, Addr Ea)
 Check: Does the specified object contain the specified address? More...
 
template<typename CharT , typename Traits >
std::basic_ostream< CharT, Traits > & operator<< (std::basic_ostream< CharT, Traits > &Stream, Addr A)
 Writes an address to an output stream in hex. More...
 
template<typename CharT , typename Traits >
std::basic_ostream< CharT, Traits > & operator<< (std::basic_ostream< CharT, Traits > &Stream, std::optional< Addr > A)
 Writes an optional address to an output stream in hex. More...
 

Detailed Description

A special class to store an Effective Address.

It is a thin wrapper around a uint64_t for 64-bit address storage. Its semantics in overflow situations are the same as semantics for unsigned integers.

An Addr cannot store a relative address as it cannot contain a negative number.

Member Typedef Documentation

◆ difference_type

The type used to represent a difference between two Addr objects.

◆ value_type

typedef uint64_t gtirb::Addr::value_type

The underlying type used to represent an Addr object.

Constructor & Destructor Documentation

◆ Addr() [1/2]

constexpr gtirb::Addr::Addr ( )
inlineconstexprnoexcept

Default constructor.

◆ Addr() [2/2]

constexpr gtirb::Addr::Addr ( value_type  X)
inlineexplicitconstexprnoexcept

Explicit conversion from value_type to Addr.

Parameters
XThe address.

Member Function Documentation

◆ operator value_type()

constexpr gtirb::Addr::operator value_type ( ) const
inlineexplicitconstexprnoexcept

Explicitly convert Addr to value_type.

Returns
An integer representation of the Addr.

◆ operator+()

constexpr Addr gtirb::Addr::operator+ ( ) const
inlineconstexprnoexcept

Unary plus for Addr. This is a noop because Addr objects represent an unsigned address value.

Returns
A copy of the implicit Addr.

◆ operator++() [1/2]

constexpr Addr& gtirb::Addr::operator++ ( )
inlineconstexprnoexcept

Preincrement for Addr.

Returns
The incremented Addr.

◆ operator++() [2/2]

constexpr Addr gtirb::Addr::operator++ ( int  )
inlineconstexprnoexcept

Postincrement for Addr.

Returns
A new Addr representing the address prior to being incremented.

◆ operator+=()

constexpr Addr& gtirb::Addr::operator+= ( value_type  Offset)
inlineconstexprnoexcept

Add-assign for Addr.

Parameters
OffsetThe offset to add to the represented address.
Returns
*this

◆ operator--() [1/2]

constexpr Addr& gtirb::Addr::operator-- ( )
inlineconstexprnoexcept

Predecrement for Addr.

Returns
The decremented Addr.

◆ operator--() [2/2]

constexpr Addr gtirb::Addr::operator-- ( int  )
inlineconstexprnoexcept

Postdecrement for Addr.

Returns
A new Addr representing the address prior to being decremented.

◆ operator-=()

constexpr Addr& gtirb::Addr::operator-= ( value_type  Offset)
inlineconstexprnoexcept

Subtract-assign for Addr.

Parameters
OffsetThe offset to subtract from the represented address.
Returns
*this

◆ operator~()

constexpr Addr gtirb::Addr::operator~ ( ) const
inlineconstexprnoexcept

Unary complement for Addr. Flips the value of all bits in the address.

Returns
A copy of the implicit Addr object, with all bits flipped.

Friends And Related Function Documentation

◆ addressLimit()

template<typename T >
std::optional< Addr > addressLimit ( const T &  Object)
related

Exclusive upper limit of an object's address range.

Template Parameters
TAny type that specifies a range of addresses via getAddress() and getSize() methods (e.g. DataBlock).
Parameters
ObjectThe object to interrogate.
Returns
An address (Addr) A such that A-1 is in Object and A is not.

◆ addressRange()

template<typename T >
std::optional< AddrRange > addressRange ( const T &  Object)
related

Address range of an object.

Template Parameters
TAny type that specifies a range of addresses via getAddress() and getSize() methods (e.g., DataBlock).
Parameters
ObjectThe object to interrogate.
Returns
An address range (AddrRange) [L, H) such that all and only the addresses L <= A < H are in Object, or std::nullopt if the object's addresses are not defined.

◆ containsAddr()

template<typename T >
bool containsAddr ( const T &  Object,
Addr  Ea 
)
related

Check: Does the specified object contain the specified address?

Template Parameters
TAny type that specifies a range of addresses via getAddress() and getSize() methods (e.g. DataBlock).
Parameters
ObjectThe object of interest.
EaThe address of interest.
Returns
true if Ea is in the address range of Object, false otherwise.

◆ operator!=

constexpr friend bool operator!= ( const Addr LHS,
const Addr RHS 
)
friend

Inquality operator for Addr.

◆ operator+ [1/2]

constexpr friend Addr operator+ ( const Addr A,
value_type  Offset 
)
friend

Binary + operator for Addr + integral offset.

Parameters
AThe Addr operand to +.
OffsetThe offset to add to A.
Returns
A new Addr representing A + Offset.

◆ operator+ [2/2]

constexpr friend Addr operator+ ( value_type  Offset,
const Addr A 
)
friend

Binary + operator for integral offset + Addr.

Parameters
OffsetThe offset to add to A.
AThe Addr operand to +.
Returns
A new Addr representing A + Offset.

◆ operator- [1/2]

constexpr friend difference_type operator- ( const Addr A,
const Addr B 
)
friend

Binary - operator for Addr - Addr.

Parameters
AThe minuend.
BThe subtrahend.
Returns
The difference A - B. NB: this is a difference type and not a valid address.

◆ operator- [2/2]

constexpr friend Addr operator- ( const Addr A,
value_type  Offset 
)
friend

Binary - operator for Addr - integral offset.

Parameters
AThe Addr operand to -.
OffsetThe offset to subtract from A.
Returns
A new Addr representing A - Offset.

NB: There is no overload for Offset - Addr like there is for Offset + Addr because subtraction is not associative like addition is.

◆ operator<

constexpr friend bool operator< ( const Addr LHS,
const Addr RHS 
)
friend

Less-than operator for Addr.

◆ operator<<() [1/2]

template<typename CharT , typename Traits >
std::basic_ostream< CharT, Traits > & operator<< ( std::basic_ostream< CharT, Traits > &  Stream,
Addr  A 
)
related

Writes an address to an output stream in hex.

This is a convenience, since this seems to be the format that is most commonly used. Note that other formats can be used by casting the address to a uint64_t and setting the formatting explicilty.

Parameters
Streamthe stream to write to.
Athe address to write.
Returns
Stream.

◆ operator<<() [2/2]

template<typename CharT , typename Traits >
std::basic_ostream< CharT, Traits > & operator<< ( std::basic_ostream< CharT, Traits > &  Stream,
std::optional< Addr A 
)
related

Writes an optional address to an output stream in hex.

This is a convenience to unwrap an Addr stored in a std::optional. If the optional does not hold a valid Addr object, then <none> is printed to the stream.

Parameters
Streamthe stream to write to.
Athe optional address to write.
Returns
Stream.

◆ operator<=

constexpr friend bool operator<= ( const Addr LHS,
const Addr RHS 
)
friend

Less-than-or-equal operator for Addr.

◆ operator==

constexpr friend bool operator== ( const Addr LHS,
const Addr RHS 
)
friend

Equality operator for Addr.

◆ operator>

constexpr friend bool operator> ( const Addr LHS,
const Addr RHS 
)
friend

Greater-than operator for Addr.

◆ operator>=

constexpr friend bool operator>= ( const Addr LHS,
const Addr RHS 
)
friend

Greater-than-or-equal operator for Addr.


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