scsl
0.1.1
Shimmering Clarity Standard Library
|
TLV.h implements basic tag-length-value records. More...
Go to the source code of this file.
Classes | |
struct | scsl::TLV::Record |
Namespaces | |
scsl | |
scsl is the top-level namespace containing all the code in this library. | |
Functions | |
uint8_t * | scsl::TLV::WriteToMemory (Arena &arena, uint8_t *cursor, Record &rec) |
void | scsl::TLV::ReadFromMemory (Record &rec, uint8_t *cursor) |
void | scsl::TLV::SetRecord (Record &rec, uint8_t tag, uint8_t length, const char *data) |
void | scsl::TLV::DeleteRecord (Arena &arena, uint8_t *cursor) |
uint8_t * | scsl::TLV::FindTag (Arena &arena, uint8_t *cursor, Record &rec) |
uint8_t * | scsl::TLV::LocateTag (Arena &arena, uint8_t *cursor, Record &rec) |
uint8_t * | scsl::TLV::FindEmpty (Arena &arena, uint8_t *cursor) |
uint8_t * | scsl::TLV::SkipRecord (Record &rec, uint8_t *cursor) |
TLV.h implements basic tag-length-value records.
TLV implements tag-length-value (TLV) records. Each record can have a maximum length of 253 bytes; each TLV record occupies a fixed 255 bytes in memory. TLV records don't allocate memory.
This system uses an Arena as a backing store.
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.
uint8_t * scsl::TLV::FindEmpty | ( | Arena & | arena, |
uint8_t * | cursor | ||
) |
FindEmpty finds a pointer the next available empty space.
arena | The backing memory for the TLV store. |
cursor | A pointer to memory inside the arena; if it's NULL, the search starts at the beginning of the arena. |
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.
arena | The backing memory for the TLV store. |
cursor | A pointer to memory inside the arena; if it's NULL, the search starts at the beginning of the arena. |
rec | The record to be filled. |
LocateTag operates similarly to FindTag, but the cursor points to the beginning of the found record.
arena | The backing memory for the TLV store. |
cursor | A pointer to memory inside the arena; if it's NULL, the search starts at the beginning of the arena. |
rec | The record to be filled. |
void scsl::TLV::ReadFromMemory | ( | Record & | rec, |
uint8_t * | cursor | ||
) |
ReadFromMemory reads a record from the memory pointed to by the cursor.
rec | The TLV record to be filled in. |
cursor | A pointer into an arena's memory store. |
void scsl::TLV::SetRecord | ( | Record & | rec, |
uint8_t | tag, | ||
uint8_t | length, | ||
const char * | data | ||
) |
SetRecord sets a record.
rec | The record to be set. |
tag | The record's tag. |
length | The record's length. |
data | The data to fill the record with. |
uint8_t * scsl::TLV::SkipRecord | ( | Record & | rec, |
uint8_t * | cursor | ||
) |
SkipRecord skips the cursor to the next record.
rec | The record that should be skipped. |
cursor | A pointer to the record in the arena. |
WriteToMemory writes the TLV record into the arena at the location pointed to in the arena.
arena | The backing memory store. |
cursor | Pointer into the arena's memory. |
rec | A TLV record to be serialized. |