scsl 1.0.1
Shimmering Clarity Standard Library
Loading...
Searching...
No Matches
Classes | Functions
scsl::TLV Namespace Reference

Tag-length-value record tooling. More...

Classes

struct  Record
 Tag-length-value record with single byte tags and lengths. More...
 

Functions

uint8_t * WriteToMemory (Arena &arena, uint8_t *cursor, Record &rec)
 
void ReadFromMemory (Record &rec, uint8_t *cursor)
 
void SetRecord (Record &rec, uint8_t tag, uint8_t length, const char *data)
 
void DeleteRecord (Arena &arena, uint8_t *cursor)
 
uint8_t * FindTag (Arena &arena, uint8_t *cursor, Record &rec)
 
uint8_t * LocateTag (Arena &arena, uint8_t *cursor, Record &rec)
 
uint8_t * FindEmpty (Arena &arena, uint8_t *cursor)
 
uint8_t * SkipRecord (Record &rec, uint8_t *cursor)
 

Detailed Description

Tag-length-value record tooling.

Function Documentation

◆ DeleteRecord()

void scsl::TLV::DeleteRecord ( Arena arena,
uint8_t *  cursor 
)

DeleteRecord removes the record from the arena. All records ahead of this record are shifted backwards so that there are no gaps.

◆ FindEmpty()

uint8_t * scsl::TLV::FindEmpty ( Arena arena,
uint8_t *  cursor 
)

FindEmpty finds a pointer the next available empty space.

Returns
A cursor to the start of empty space in the arena, or nullptr if there is no more empty space available.
Parameters
arenaThe backing memory for the TLV store.
cursorA pointer to memory inside the arena; if it's NULL, the search starts At the beginning of the arena.
Returns
If the arena has space available, a cursor pointing the start of empty space; otherwise, nullptr is returned.

◆ FindTag()

uint8_t * scsl::TLV::FindTag ( Arena arena,
uint8_t *  cursor,
Record rec 
)

FindTag finds the next occurrence of the record's tag.

The record must have a tag set, which tells FindTag which tag to look for. If found, it fills the record.

See also
LocateTag.
Parameters
arenaThe backing memory for the TLV store.
cursorA pointer to memory inside the arena; if it's NULL, the search starts At the beginning of the arena.
recThe record to be filled.
Returns
If the tag is found, a cursor pointing to the next record is returned; otherwise nullptr is returned.

◆ LocateTag()

uint8_t * scsl::TLV::LocateTag ( Arena arena,
uint8_t *  cursor,
Record rec 
)

LocateTag operates similarly to FindTag, but the cursor points to the beginning of the found record.

Parameters
arenaThe backing memory for the TLV store.
cursorA pointer to memory inside the arena; if it's NULL, the search starts At the beginning of the arena.
recThe record to be filled.
Returns
If the tag is found, a cursor pointing to the record is returned; otherwise nullptr is returned.

◆ ReadFromMemory()

void scsl::TLV::ReadFromMemory ( Record rec,
uint8_t *  cursor 
)

ReadFromMemory reads a record from the memory pointed to by the cursor.

Parameters
recThe TLV record to be filled in.
cursorA pointer into an arena's memory store.

◆ SetRecord()

void scsl::TLV::SetRecord ( Record rec,
uint8_t  tag,
uint8_t  length,
const char *  data 
)

SetRecord sets a record.

Parameters
recThe record to be set.
tagThe record's tag.
lengthThe record's length.
dataThe data to fill the record with.

◆ SkipRecord()

uint8_t * scsl::TLV::SkipRecord ( Record rec,
uint8_t *  cursor 
)

SkipRecord skips the cursor to the next record.

Parameters
recThe record that should be skipped.
cursorA pointer to the record in the arena.
Returns
The pointer to the next record in the arena.

◆ WriteToMemory()

uint8_t * scsl::TLV::WriteToMemory ( Arena arena,
uint8_t *  cursor,
Record rec 
)

WriteToMemory writes the TLV record into the arena At the location pointed to in the arena.

Parameters
arenaThe backing memory store.
cursorPointer into the arena's memory.
recA TLV record to be serialized.
Returns
A pointer the memory after the record.