WPILibC++ 2024.1.1-beta-4
wpi::log::DataLogRecord Class Reference

A record in the data log. More...

#include <wpi/DataLogReader.h>

Public Member Functions

 DataLogRecord ()=default
 
 DataLogRecord (int entry, int64_t timestamp, std::span< const uint8_t > data)
 
int GetEntry () const
 Gets the entry ID. More...
 
int64_t GetTimestamp () const
 Gets the record timestamp. More...
 
size_t GetSize () const
 Gets the size of the raw data. More...
 
std::span< const uint8_t > GetRaw () const
 Gets the raw data. More...
 
bool IsControl () const
 Returns true if the record is a control record. More...
 
bool IsStart () const
 Returns true if the record is a start control record. More...
 
bool IsFinish () const
 Returns true if the record is a finish control record. More...
 
bool IsSetMetadata () const
 Returns true if the record is a set metadata control record. More...
 
bool GetStartData (StartRecordData *out) const
 Decodes a start control record. More...
 
bool GetFinishEntry (int *out) const
 Decodes a finish control record. More...
 
bool GetSetMetadataData (MetadataRecordData *out) const
 Decodes a set metadata control record. More...
 
bool GetBoolean (bool *value) const
 Decodes a data record as a boolean. More...
 
bool GetInteger (int64_t *value) const
 Decodes a data record as an integer. More...
 
bool GetFloat (float *value) const
 Decodes a data record as a float. More...
 
bool GetDouble (double *value) const
 Decodes a data record as a double. More...
 
bool GetString (std::string_view *value) const
 Decodes a data record as a string. More...
 
bool GetBooleanArray (std::vector< int > *arr) const
 Decodes a data record as a boolean array. More...
 
bool GetIntegerArray (std::vector< int64_t > *arr) const
 Decodes a data record as an integer array. More...
 
bool GetFloatArray (std::vector< float > *arr) const
 Decodes a data record as a float array. More...
 
bool GetDoubleArray (std::vector< double > *arr) const
 Decodes a data record as a double array. More...
 
bool GetStringArray (std::vector< std::string_view > *arr) const
 Decodes a data record as a string array. More...
 

Detailed Description

A record in the data log.

May represent either a control record (entry == 0) or a data record. Used only for reading (e.g. with DataLogReader).

Constructor & Destructor Documentation

◆ DataLogRecord() [1/2]

wpi::log::DataLogRecord::DataLogRecord ( )
default

◆ DataLogRecord() [2/2]

wpi::log::DataLogRecord::DataLogRecord ( int  entry,
int64_t  timestamp,
std::span< const uint8_t >  data 
)
inline

Member Function Documentation

◆ GetBoolean()

bool wpi::log::DataLogRecord::GetBoolean ( bool *  value) const

Decodes a data record as a boolean.

Note if the data type (as indicated in the corresponding start control record for this entry) is not "boolean", invalid results may be returned.

Parameters
[out]valueboolean value (if successful)
Returns
True on success, false on error

◆ GetBooleanArray()

bool wpi::log::DataLogRecord::GetBooleanArray ( std::vector< int > *  arr) const

Decodes a data record as a boolean array.

Note if the data type (as indicated in the corresponding start control record for this entry) is not "boolean[]", invalid results may be returned.

Parameters
[out]arrboolean array
Returns
True (never fails)

◆ GetDouble()

bool wpi::log::DataLogRecord::GetDouble ( double *  value) const

Decodes a data record as a double.

Note if the data type (as indicated in the corresponding start control record for this entry) is not "double", invalid results may be returned.

Parameters
[out]valuedouble value (if successful)
Returns
True on success, false on error

◆ GetDoubleArray()

bool wpi::log::DataLogRecord::GetDoubleArray ( std::vector< double > *  arr) const

Decodes a data record as a double array.

Note if the data type (as indicated in the corresponding start control record for this entry) is not "double[]", invalid results may be returned.

Parameters
[out]arrdouble array (if successful)
Returns
True on success, false on error

◆ GetEntry()

int wpi::log::DataLogRecord::GetEntry ( ) const
inline

Gets the entry ID.

Returns
entry ID

◆ GetFinishEntry()

bool wpi::log::DataLogRecord::GetFinishEntry ( int *  out) const

Decodes a finish control record.

Parameters
[out]outfinish record entry ID (if successful)
Returns
True on success, false on error

◆ GetFloat()

bool wpi::log::DataLogRecord::GetFloat ( float *  value) const

Decodes a data record as a float.

Note if the data type (as indicated in the corresponding start control record for this entry) is not "float", invalid results may be returned.

Parameters
[out]valuefloat value (if successful)
Returns
True on success, false on error

◆ GetFloatArray()

bool wpi::log::DataLogRecord::GetFloatArray ( std::vector< float > *  arr) const

Decodes a data record as a float array.

Note if the data type (as indicated in the corresponding start control record for this entry) is not "float[]", invalid results may be returned.

Parameters
[out]arrfloat array (if successful)
Returns
True on success, false on error

◆ GetInteger()

bool wpi::log::DataLogRecord::GetInteger ( int64_t *  value) const

Decodes a data record as an integer.

Note if the data type (as indicated in the corresponding start control record for this entry) is not "int64", invalid results may be returned.

Parameters
[out]valueinteger value (if successful)
Returns
True on success, false on error

◆ GetIntegerArray()

bool wpi::log::DataLogRecord::GetIntegerArray ( std::vector< int64_t > *  arr) const

Decodes a data record as an integer array.

Note if the data type (as indicated in the corresponding start control record for this entry) is not "int64[]", invalid results may be returned.

Parameters
[out]arrinteger array (if successful)
Returns
True on success, false on error

◆ GetRaw()

std::span< const uint8_t > wpi::log::DataLogRecord::GetRaw ( ) const
inline

Gets the raw data.

Use the GetX functions to decode based on the data type in the entry's start record.

◆ GetSetMetadataData()

bool wpi::log::DataLogRecord::GetSetMetadataData ( MetadataRecordData out) const

Decodes a set metadata control record.

Parameters
[out]outset metadata record decoded data (if successful)
Returns
True on success, false on error

◆ GetSize()

size_t wpi::log::DataLogRecord::GetSize ( ) const
inline

Gets the size of the raw data.

Returns
size

◆ GetStartData()

bool wpi::log::DataLogRecord::GetStartData ( StartRecordData out) const

Decodes a start control record.

Parameters
[out]outstart record decoded data (if successful)
Returns
True on success, false on error

◆ GetString()

bool wpi::log::DataLogRecord::GetString ( std::string_view value) const

Decodes a data record as a string.

Note if the data type (as indicated in the corresponding start control record for this entry) is not "string", invalid results may be returned.

Parameters
[out]valuestring value
Returns
True (never fails)

◆ GetStringArray()

bool wpi::log::DataLogRecord::GetStringArray ( std::vector< std::string_view > *  arr) const

Decodes a data record as a string array.

Note if the data type (as indicated in the corresponding start control record for this entry) is not "string[]", invalid results may be returned.

Parameters
[out]arrstring array (if successful)
Returns
True on success, false on error

◆ GetTimestamp()

int64_t wpi::log::DataLogRecord::GetTimestamp ( ) const
inline

Gets the record timestamp.

Returns
Timestamp, in integer microseconds

◆ IsControl()

bool wpi::log::DataLogRecord::IsControl ( ) const
inline

Returns true if the record is a control record.

Returns
True if control record, false if normal data record.

◆ IsFinish()

bool wpi::log::DataLogRecord::IsFinish ( ) const

Returns true if the record is a finish control record.

Use GetFinishEntry() to decode the contents.

Returns
True if finish control record, false otherwise.

◆ IsSetMetadata()

bool wpi::log::DataLogRecord::IsSetMetadata ( ) const

Returns true if the record is a set metadata control record.

Use GetSetMetadataData() to decode the contents.

Returns
True if set metadata control record, false otherwise.

◆ IsStart()

bool wpi::log::DataLogRecord::IsStart ( ) const

Returns true if the record is a start control record.

Use GetStartData() to decode the contents.

Returns
True if start control record, false otherwise.

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