GTIRB  v2.2.0
GrammaTech Intermediate Representation for Binaries: C++ API
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
gtirb::DataBlock Class Reference

Represents a data object, possibly symbolic. More...

#include <DataBlock.hpp>

Inheritance diagram for gtirb::DataBlock:
Inheritance graph
[legend]
Collaboration diagram for gtirb::DataBlock:
Collaboration graph
[legend]

Public Types

template<typename T >
using bytes_iterator = ByteInterval::bytes_iterator< T >
 Iterator over bytes in this block. More...
 
template<typename T >
using bytes_range = ByteInterval::bytes_range< T >
 Range over bytes in this block. More...
 
template<typename T >
using const_bytes_iterator = ByteInterval::const_bytes_iterator< T >
 Const iterator over bytes in this block. More...
 
template<typename T >
using const_bytes_range = ByteInterval::const_bytes_range< T >
 Const range over bytes in this block. More...
 

Public Member Functions

template<typename T >
bytes_range< T > bytes ()
 Get a range of the bytes in this block. More...
 
template<typename T >
const_bytes_range< T > bytes () const
 Get a range of the bytes in this block. More...
 
template<typename T >
bytes_range< T > bytes (boost::endian::order InputOrder, boost::endian::order OutputOrder=boost::endian::order::native)
 Get a range of the bytes in this block. More...
 
template<typename T >
const_bytes_range< T > bytes (boost::endian::order InputOrder, boost::endian::order OutputOrder=boost::endian::order::native) const
 Get a range of the bytes in this block. More...
 
template<typename T >
bytes_iterator< T > bytes_begin ()
 Get an iterator to the first byte in this block. More...
 
template<typename T >
const_bytes_iterator< T > bytes_begin () const
 Get an iterator to the first byte in this block. More...
 
template<typename T >
bytes_iterator< T > bytes_begin (boost::endian::order InputOrder, boost::endian::order OutputOrder=boost::endian::order::native)
 Get an iterator to the first byte in this block. More...
 
template<typename T >
const_bytes_iterator< T > bytes_begin (boost::endian::order InputOrder, boost::endian::order OutputOrder=boost::endian::order::native) const
 Get an iterator to the first byte in this block. More...
 
template<typename T >
bytes_iterator< T > bytes_end ()
 Get an iterator past the last byte in this block. More...
 
template<typename T >
const_bytes_iterator< T > bytes_end () const
 Get an iterator past the last byte in this block. More...
 
template<typename T >
bytes_iterator< T > bytes_end (boost::endian::order InputOrder, boost::endian::order OutputOrder=boost::endian::order::native)
 Get an iterator past the last byte in this block. More...
 
template<typename T >
const_bytes_iterator< T > bytes_end (boost::endian::order InputOrder, boost::endian::order OutputOrder=boost::endian::order::native) const
 Get an iterator past the last byte in this block. More...
 
std::optional< AddrgetAddress () const
 Get the address of this block, if present. See ByteInterval::getAddress for details on why this address may not be present. More...
 
ByteIntervalgetByteInterval ()
 Get the ByteInterval this block belongs to. More...
 
const ByteIntervalgetByteInterval () const
 Get the ByteInterval this block belongs to. More...
 
uint64_t getOffset () const
 Get the offset from the beginning of the ByteInterval this block belongs to. More...
 
uint64_t getSize () const
 Get the size of a DataBlock. More...
 
template<typename T >
T * rawBytes ()
 Return the raw data underlying this block's byte vector. More...
 
template<typename T >
const T * rawBytes () const
 Return the raw data underlying this block's byte vector. More...
 
void setSize (uint64_t S)
 Set the size of this block. More...
 
- Public Member Functions inherited from gtirb::Node
 Node (const Node &)=delete
 Copying Nodes is explicitly disabled. More...
 
 Node (Node &&)=delete
 Move-constructing Nodes is explicitly disabled. More...
 
 ~Node () noexcept
 Cleans up resources no longer needed by the Node object. More...
 
const UUIDgetUUID () const
 Get the Universally Unique ID (UUID) for this. More...
 
Nodeoperator= (const Node &)=delete
 Copying Nodes is explicilty disabled. More...
 
Nodeoperator= (Node &&)=delete
 Move-assigning Nodes is explicilty disabled. More...
 

Static Public Member Functions

static DataBlockCreate (Context &C)
 Create an unitialized DataBlock object. More...
 
static DataBlockCreate (Context &C, uint64_t Size)
 Create a DataBlock object. More...
 
- Static Public Member Functions inherited from gtirb::Node
static NodeCreate (Context &C)
 Create a Node object in its default state. More...
 
static const NodegetByUUID (const Context &C, const UUID &Uuid)
 Retrieve a node by its UUID. More...
 
static NodegetByUUID (Context &C, const UUID &Uuid)
 Retrieve a node by its UUID. More...
 

Friends

class ByteInterval
 
class Context
 
class SerializationTestHarness
 

Detailed Description

Represents a data object, possibly symbolic.

Does not directly store the data bytes, which are kept in the ImageByteMap.

Member Typedef Documentation

◆ bytes_iterator

Iterator over bytes in this block.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.

◆ bytes_range

template<typename T >
using gtirb::DataBlock::bytes_range = ByteInterval::bytes_range<T>

Range over bytes in this block.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.

◆ const_bytes_iterator

Const iterator over bytes in this block.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.

◆ const_bytes_range

Const range over bytes in this block.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.

Member Function Documentation

◆ bytes() [1/4]

template<typename T >
bytes_range<T> gtirb::DataBlock::bytes ( )
inline

Get a range of the bytes in this block.

If this block is not associated with any ByteInterval, than the behavior of this function is undefined.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.

◆ bytes() [2/4]

template<typename T >
const_bytes_range<T> gtirb::DataBlock::bytes ( ) const
inline

Get a range of the bytes in this block.

If this block is not associated with any ByteInterval, than the behavior of this function is undefined.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.

◆ bytes() [3/4]

template<typename T >
bytes_range<T> gtirb::DataBlock::bytes ( boost::endian::order  InputOrder,
boost::endian::order  OutputOrder = boost::endian::order::native 
)
inline

Get a range of the bytes in this block.

If this block is not associated with any ByteInterval, than the behavior of this function is undefined.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.
Parameters
InputOrderThe endianness of the data in the block.
OutputOrderThe endianness you wish to read out from the block.

◆ bytes() [4/4]

template<typename T >
const_bytes_range<T> gtirb::DataBlock::bytes ( boost::endian::order  InputOrder,
boost::endian::order  OutputOrder = boost::endian::order::native 
) const
inline

Get a range of the bytes in this block.

If this block is not associated with any ByteInterval, than the behavior of this function is undefined.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.
Parameters
InputOrderThe endianness of the data in the block.
OutputOrderThe endianness you wish to read out from the block.

◆ bytes_begin() [1/4]

template<typename T >
bytes_iterator<T> gtirb::DataBlock::bytes_begin ( )
inline

Get an iterator to the first byte in this block.

If this block is not associated with any ByteInterval, than the behavior of this function is undefined.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.

◆ bytes_begin() [2/4]

template<typename T >
const_bytes_iterator<T> gtirb::DataBlock::bytes_begin ( ) const
inline

Get an iterator to the first byte in this block.

If this block is not associated with any ByteInterval, than the behavior of this function is undefined.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.

◆ bytes_begin() [3/4]

template<typename T >
bytes_iterator<T> gtirb::DataBlock::bytes_begin ( boost::endian::order  InputOrder,
boost::endian::order  OutputOrder = boost::endian::order::native 
)
inline

Get an iterator to the first byte in this block.

If this block is not associated with any ByteInterval, than the behavior of this function is undefined.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.
Parameters
InputOrderThe endianness of the data in the block.
OutputOrderThe endianness you wish to read out from the block.

◆ bytes_begin() [4/4]

template<typename T >
const_bytes_iterator<T> gtirb::DataBlock::bytes_begin ( boost::endian::order  InputOrder,
boost::endian::order  OutputOrder = boost::endian::order::native 
) const
inline

Get an iterator to the first byte in this block.

If this block is not associated with any ByteInterval, than the behavior of this function is undefined.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.
Parameters
InputOrderThe endianness of the data in the block.
OutputOrderThe endianness you wish to read out from the block.

◆ bytes_end() [1/4]

template<typename T >
bytes_iterator<T> gtirb::DataBlock::bytes_end ( )
inline

Get an iterator past the last byte in this block.

If this block is not associated with any ByteInterval, than the behavior of this function is undefined.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.

◆ bytes_end() [2/4]

template<typename T >
const_bytes_iterator<T> gtirb::DataBlock::bytes_end ( ) const
inline

Get an iterator past the last byte in this block.

If this block is not associated with any ByteInterval, than the behavior of this function is undefined.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.

◆ bytes_end() [3/4]

template<typename T >
bytes_iterator<T> gtirb::DataBlock::bytes_end ( boost::endian::order  InputOrder,
boost::endian::order  OutputOrder = boost::endian::order::native 
)
inline

Get an iterator past the last byte in this block.

If this block is not associated with any ByteInterval, than the behavior of this function is undefined.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.
Parameters
InputOrderThe endianness of the data in the block.
OutputOrderThe endianness you wish to read out from the block.

◆ bytes_end() [4/4]

template<typename T >
const_bytes_iterator<T> gtirb::DataBlock::bytes_end ( boost::endian::order  InputOrder,
boost::endian::order  OutputOrder = boost::endian::order::native 
) const
inline

Get an iterator past the last byte in this block.

If this block is not associated with any ByteInterval, than the behavior of this function is undefined.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type that satisfies Boost's EndianReversible concept.
Parameters
InputOrderThe endianness of the data in the block.
OutputOrderThe endianness you wish to read out from the block.

◆ Create() [1/2]

static DataBlock* gtirb::DataBlock::Create ( Context C)
inlinestatic

Create an unitialized DataBlock object.

Parameters
CThe Context in which this DataBlock will be held.
Returns
The newly created DataBlock.

◆ Create() [2/2]

static DataBlock* gtirb::DataBlock::Create ( Context C,
uint64_t  Size 
)
inlinestatic

Create a DataBlock object.

Parameters
CThe Context in which the newly-created DataBlock will be
SizeThe size of the object in bytes.
Returns
The newly created DataBlock.

◆ getAddress()

std::optional<Addr> gtirb::DataBlock::getAddress ( ) const

Get the address of this block, if present. See ByteInterval::getAddress for details on why this address may not be present.

◆ getByteInterval() [1/2]

ByteInterval* gtirb::DataBlock::getByteInterval ( )
inline

Get the ByteInterval this block belongs to.

◆ getByteInterval() [2/2]

const ByteInterval* gtirb::DataBlock::getByteInterval ( ) const
inline

Get the ByteInterval this block belongs to.

◆ getOffset()

uint64_t gtirb::DataBlock::getOffset ( ) const

Get the offset from the beginning of the ByteInterval this block belongs to.

◆ getSize()

uint64_t gtirb::DataBlock::getSize ( ) const
inline

Get the size of a DataBlock.

Returns
The size.

◆ rawBytes() [1/2]

template<typename T >
T* gtirb::DataBlock::rawBytes ( )
inline

Return the raw data underlying this block's byte vector.

If this block is not associated with any ByteInterval, than the behavior of this function is undefined.

Much like std::vector::data, this function is low-level and potentially unsafe. This pointer refers to valid memory only where an iterator would be valid to point to. Modifying the size of the byte vector may invalidate this pointer. Any endian conversions will not be performed.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type.

\retrurn A pointer to raw data.

◆ rawBytes() [2/2]

template<typename T >
const T* gtirb::DataBlock::rawBytes ( ) const
inline

Return the raw data underlying this block's byte vector.

If this block is not associated with any ByteInterval, than the behavior of this function is undefined.

Much like std::vector::data, this function is low-level and potentially unsafe. This pointer refers to valid memory only where an iterator would be valid to point to. Modifying the size of the byte vector may invalidate this pointer. Any endian conversions will not be performed.

Template Parameters
TThe type of data stored in this block's byte vector. Must be a POD type.

\retrurn A pointer to raw data.

◆ setSize()

void gtirb::DataBlock::setSize ( uint64_t  S)
inline

Set the size of this block.

Note that this does not automatically update any ByteInterval's size, bytes, or symbolic expressions. This simply changes the extents of a block in its ByteInterval.

Friends And Related Function Documentation

◆ ByteInterval

friend class ByteInterval
friend

◆ Context

friend class Context
friend

◆ SerializationTestHarness

friend class SerializationTestHarness
friend

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