PebbleOS
Loading...
Searching...
No Matches
Data Structures | Functions
Pascal strings

Length-prefixed strings and lists of them. More...

Data Structures

struct  pbl_pstring16
 Length-prefixed string, not NUL-terminated. More...
 
struct  pbl_serialized_array
 Length-prefixed byte array. More...
 
struct  pbl_pstring16_list
 View of a pbl_serialized_array holding back-to-back pbl_pstring16 entries. More...
 

Functions

void pbl_pstring16_to_cstring (const struct pbl_pstring16 *pstring, char *string_out)
 Copy a pstring16 into a C string.
 
bool pbl_pstring16_equal (const struct pbl_pstring16 *ps1, const struct pbl_pstring16 *ps2)
 Compare two pstring16.
 
bool pbl_pstring16_equal_cstring (const struct pbl_pstring16 *pstr, const char *cstr)
 Compare a pstring16 with a C string.
 
void pbl_pstring16_list_init (struct pbl_pstring16_list *list, struct pbl_serialized_array *serialized_array)
 Point a list at a serialized array and count its entries.
 
struct pbl_pstring16 * pbl_pstring16_list_get (const struct pbl_pstring16_list *list, uint16_t index)
 Get an entry of a list.
 

Detailed Description

Length-prefixed strings and lists of them.


Data Structure Documentation

◆ pbl_pstring16

struct pbl_pstring16

Length-prefixed string, not NUL-terminated.

Data Fields
uint16_t str_length Length of str_value in bytes.
char str_value[] Characters.

◆ pbl_serialized_array

struct pbl_serialized_array

Length-prefixed byte array.

Data Fields
uint8_t data[] Bytes.
uint16_t data_size Size of data in bytes.

◆ pbl_pstring16_list

struct pbl_pstring16_list

View of a pbl_serialized_array holding back-to-back pbl_pstring16 entries.

Data Fields
uint16_t count Number of entries.
struct pbl_serialized_array * pstrings Serialized entries.

Function Documentation

◆ pbl_pstring16_equal()

bool pbl_pstring16_equal ( const struct pbl_pstring16 *  ps1,
const struct pbl_pstring16 *  ps2 
)

Compare two pstring16.

Parameters
ps1First string, may be NULL.
ps2Second string, may be NULL.
Returns
true if both are non-NULL and equal.

◆ pbl_pstring16_equal_cstring()

bool pbl_pstring16_equal_cstring ( const struct pbl_pstring16 *  pstr,
const char *  cstr 
)

Compare a pstring16 with a C string.

Parameters
pstrLength-prefixed string, may be NULL.
cstrC string, may be NULL.
Returns
true if both are non-NULL and equal.

◆ pbl_pstring16_list_get()

struct pbl_pstring16 * pbl_pstring16_list_get ( const struct pbl_pstring16_list *  list,
uint16_t  index 
)

Get an entry of a list.

Parameters
listList.
indexZero-based index.
Returns
Entry, or NULL if index is out of bounds.

◆ pbl_pstring16_list_init()

void pbl_pstring16_list_init ( struct pbl_pstring16_list *  list,
struct pbl_serialized_array *  serialized_array 
)

Point a list at a serialized array and count its entries.

An all-zero array is an empty list, not a list of empty strings.

Parameters
[out]listList.
serialized_arraySerialized entries, must outlive list.

◆ pbl_pstring16_to_cstring()

void pbl_pstring16_to_cstring ( const struct pbl_pstring16 *  pstring,
char *  string_out 
)

Copy a pstring16 into a C string.

Parameters
pstringString to copy.
[out]string_outDestination, at least pstring->str_length + 1 bytes.