AdsLib
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Frame Struct Reference

#include <Frame.h>

Public Member Functions

 Frame (size_t length, const void *data=nullptr)
 Frame. More...
 
uint8_t operator[] (size_t index) const
 operator [] bytewise access to the frame bytes More...
 
size_t capacity () const
 capacity More...
 
Frameclear ()
 clear Reset internal buffer to an empty frame More...
 
Framelimit (size_t newSize)
 limit If the frame is reused as a response buffer, call limit() to lock the frames state and limit its size to the length of the response More...
 
Framereset (size_t newSize=4096)
 reset Prepare the frame to be reused as a response buffer More...
 
const uint8_t * data () const
 data More...
 
template<typename T >
pop ()
 
template<typename T >
pop_letoh ()
 
Frameprepend (const void *const data, const size_t size)
 prepend prepend <data> in front of the frame More...
 
template<class T >
Frameprepend (const T &header)
 
uint8_t * rawData () const
 rawData Reuse the frame as response buffer, use with care! More...
 
Frameremove (size_t numBytes)
 remove remove <numBytest> from the beginning of the frame More...
 
template<class T >
remove ()
 
size_t size () const
 size More...
 

Detailed Description

Copyright (c) 2015 - 2022 Beckhoff Automation GmbH & Co. KG

Constructor & Destructor Documentation

◆ Frame()

Frame::Frame ( size_t  length,
const void *  data = nullptr 
)

Frame.

Parameters
lengthnumber of bytes preallocated in the internale buffer
data,ifnot null this frame will be initialized with <lenght> number of bytes from <data>

Copyright (c) 2015 - 2022 Beckhoff Automation GmbH & Co. KG

Member Function Documentation

◆ capacity()

size_t Frame::capacity ( ) const

capacity

Returns
number of bytes, which are accessable by rawData()

◆ clear()

Frame & Frame::clear ( )

clear Reset internal buffer to an empty frame

Returns
reference to self

◆ data()

const uint8_t * Frame::data ( ) const

data

Returns
a pointer to the beginning of the frame

◆ limit()

Frame & Frame::limit ( size_t  newSize)

limit If the frame is reused as a response buffer, call limit() to lock the frames state and limit its size to the length of the response

Parameters
newSizelength of the response
Returns
reference to self

◆ operator[]()

uint8_t Frame::operator[] ( size_t  index) const

operator [] bytewise access to the frame bytes

Parameters
indexshould be within the frames bounds!
Returns

◆ pop()

template<typename T >
T Frame::pop ( )
inline

remove sizeof(T) bytes from the beginning of the frame and return them interpreted as T. If frame is to short to fit a T, we silently return a default initialized T.

◆ pop_letoh()

template<typename T >
T Frame::pop_letoh ( )
inline

remove sizeof(T) bytes from the beginning of the frame and return them interpreted as T in little endian byte order (result is in host order).

◆ prepend() [1/2]

template<class T >
Frame & Frame::prepend ( const T &  header)
inline

prepend a header of type <T>

◆ prepend() [2/2]

Frame & Frame::prepend ( const void *const  data,
const size_t  size 
)

prepend prepend <data> in front of the frame

Parameters
data
sizenumber of bytes in <data>
Returns
reference to self

◆ rawData()

uint8_t * Frame::rawData ( ) const

rawData Reuse the frame as response buffer, use with care!

Returns
a raw pointer to the beginning of the internal allocated buffer

◆ remove() [1/2]

template<class T >
T Frame::remove ( )
inline

remove header of type <T> from the beginning of the frame

◆ remove() [2/2]

Frame & Frame::remove ( size_t  numBytes)

remove remove <numBytest> from the beginning of the frame

Parameters
numBytes
Returns
reference to self

◆ reset()

Frame & Frame::reset ( size_t  newSize = 4096)

reset Prepare the frame to be reused as a response buffer

Parameters
newSizeexpected size of the response
Returns
reference to self

◆ size()

size_t Frame::size ( ) const

size

Returns
length of the frame in bytes

The documentation for this struct was generated from the following files: