VRS
A file format for sensor data.
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
vrs::RecordFormat Class Reference

Description of the format of a VRS record as a succession of typed blocks of content. More...

#include <RecordFormat.h>

Public Member Functions

 RecordFormat ()=default
 Empty record format definition.
 
 RecordFormat (const RecordFormat &)=default
 Default copy constructor.
 
 RecordFormat (const string &format)
 
 RecordFormat (const char *format)
 
 RecordFormat (const ContentBlock &block)
 Build a RecordFormat from a single ContentBlock.
 
 RecordFormat (ContentBlock &&block)
 Build a RecordFormat from a single ContentBlock.
 
 RecordFormat (const ContentBlock &first, const ContentBlock &second)
 Build a RecordFormat from two ContentBlock definitions.
 
 RecordFormat (const ContentBlock &&first, const ContentBlock &&second)
 Build a RecordFormat from two ContentBlock definitions.
 
 RecordFormat (ContentType type, size_t size=ContentBlock::kSizeUnknown)
 
RecordFormatoperator+ (const ContentBlock &block)
 Append a ContentBlock to this RecordFormat.
 
RecordFormatoperator+ (ContentBlock &&block)
 Append a ContentBlock to this RecordFormat.
 
RecordFormatoperator= (const RecordFormat &)=default
 Default copy assignment.
 
bool operator== (const RecordFormat &rhs) const
 
bool operator!= (const RecordFormat &rhs) const
 
void clear ()
 
void set (const string &format)
 
string asString () const
 
size_t getRecordSize () const
 
size_t getUsedBlocksCount () const
 
size_t getBlocksOfTypeCount (ContentType type) const
 
const ContentBlockgetContentBlock (size_t index) const
 
const ContentBlockgetFirstContentBlock () const
 
size_t getRemainingBlocksSize (size_t firstBlock) const
 
size_t getBlockSize (size_t blockIndex, size_t remainingSize) const
 

Static Public Member Functions

static string getRecordFormatTagName (Record::Type recordType, uint32_t formatVersion)
 Names of the VRS stream tags used for RecordFormat descriptions.
 
static string getDataLayoutTagName (Record::Type type, uint32_t version, size_t blockIndex)
 
static bool parseRecordFormatTagName (const string &tagName, Record::Type &recordType, uint32_t &formatVersion)
 
static bool addRecordFormat (map< string, string > &inOutRecordFormatRegister, Record::Type recordType, uint32_t formatVersion, const RecordFormat &format, const vector< const DataLayout * > &layouts)
 
static void getRecordFormats (const map< string, string > &recordFormatRegister, RecordFormatMap &outFormats)
 
static unique_ptr< DataLayoutgetDataLayout (const map< string, string > &recordFormatRegister, const ContentBlockId &blockId)
 

Detailed Description

Description of the format of a VRS record as a succession of typed blocks of content.

A RecordFormat description can be associated with each record type & record format version, so that we can tell how a particular type of VRS record looks like.

Major ContentBlock types include DataLayout blocks and image blocks. See enum class ContentType above for the complete list of ContentBlock types.

See ContentBlock to find out about all the different types of content blocks supported.

Constructor & Destructor Documentation

◆ RecordFormat() [1/3]

vrs::RecordFormat::RecordFormat ( const string &  format)
inline

Build a RecordFormat from a string description. This constructor is meant for internal VRS usage only.

◆ RecordFormat() [2/3]

vrs::RecordFormat::RecordFormat ( const char *  format)
inline

Build a RecordFormat from a string description. This constructor is meant for internal VRS usage only.

◆ RecordFormat() [3/3]

vrs::RecordFormat::RecordFormat ( ContentType  type,
size_t  size = ContentBlock::kSizeUnknown 
)
inline

Build a RecordFormat from a simple ContentType & block size.

Parameters
typeContent type of the block.
sizeSize of the block, or ContentBlock::kSizeUnknown, if the size of the block isn't known/fixed.

Member Function Documentation

◆ addRecordFormat()

bool vrs::RecordFormat::addRecordFormat ( map< string, string > &  inOutRecordFormatRegister,
Record::Type  recordType,
uint32_t  formatVersion,
const RecordFormat format,
const vector< const DataLayout * > &  layouts 
)
static

VRS internal utility to add record format definitions to a container. This container might be the VRS tags for a Recordable, or a legacy registry.

◆ asString()

string vrs::RecordFormat::asString ( ) const

Convert as a string. For VRS usage only.

◆ getBlockSize()

size_t vrs::RecordFormat::getBlockSize ( size_t  blockIndex,
size_t  remainingSize 
) const

Get the size of a particular block, knowing the remaining record size including this block, or ContentBlock::kSizeUnknown.

Parameters
firstBlockSize of the first content block to count the size of.
remainingSizeNumber of bytes left in the record for the remaining blocks.
Returns
The size of all the content blocks at and past the index, or ContentBlock::kSizeUnknown if more than one block doesn't have a known size.

◆ getBlocksOfTypeCount()

size_t vrs::RecordFormat::getBlocksOfTypeCount ( ContentType  type) const

Count the number of blocks of a particular type.

Parameters
typeContent block type to count.
Returns
The number of content blocks of the requested type.

◆ getContentBlock()

const ContentBlock & vrs::RecordFormat::getContentBlock ( size_t  index) const

Get a specific ContentBlock. Use getUsedBlocksCount() to know when to stop.

Parameters
indexThe index of the block requested.
Returns
The requested ContentBlock, or an empty block, if there is no block at that index.

◆ getFirstContentBlock()

const ContentBlock & vrs::RecordFormat::getFirstContentBlock ( ) const
inline

Get first content block.

Returns
The first ContentBlock, or an empty block, if there are no ContentBlock defined.

◆ getRecordSize()

size_t vrs::RecordFormat::getRecordSize ( ) const

Get the size of the record, based on RecordFormat information only.

Returns
The size of the record, or ContentBlock::kSizeUnknown.

◆ getRemainingBlocksSize()

size_t vrs::RecordFormat::getRemainingBlocksSize ( size_t  firstBlock) const

Get the size of all the blocks at and past an index, or ContentBlock::kSizeUnknown.

Parameters
firstBlockSize of the first content block to count the size of.
Returns
The size of all the content blocks at and past the index, or ContentBlock::kSizeUnknown if any of the blocks doesn't have a known size.

◆ getUsedBlocksCount()

size_t vrs::RecordFormat::getUsedBlocksCount ( ) const

Get the number of blocks to read (ignores trailing empty blocks).

Returns
The number of blocks until the last block, that's not an empty block.

◆ parseRecordFormatTagName()

bool vrs::RecordFormat::parseRecordFormatTagName ( const string &  tagName,
Record::Type recordType,
uint32_t &  formatVersion 
)
static

Tell if a tag name was generated by getRecordFormatTagName, by returning true, and setting recordType & formatVersion. Otherwise, it returns false.

◆ set()

void vrs::RecordFormat::set ( const string &  format)

Initialize from a string description. For VRS usage only.


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