PebbleOS
Loading...
Searching...
No Matches
Enumerations | Functions
Attribute groups

Shared code for data made of an attribute list and a group of elements with their own attributes. More...

Enumerations

enum  AttributeGroupType { AttributeGroupType_Action , AttributeGroupType_Address }
 Kind of group elements. More...
 

Functions

bool attribute_group_parse_serial_data (AttributeGroupType type, uint8_t num_attributes, uint8_t num_group_type_elements, const uint8_t *data, size_t size, size_t *string_alloc_size_out, uint8_t *attributes_per_group_type_element_out)
 Measure serialized group data.
 
size_t attribute_group_get_required_buffer_size (AttributeGroupType type, uint8_t num_attributes, uint8_t num_group_type_elements, const uint8_t *attributes_per_group_type_element, size_t required_size_for_strings)
 Get the size of the buffer holding group data.
 
void attribute_group_init (AttributeGroupType type, AttributeList *attr_list, void *group_ptr, uint8_t **buffer, uint8_t num_attributes, uint8_t num_group_type_elements, const uint8_t *attributes_per_group_type_element)
 Lay out an attribute list and group in a buffer.
 
bool attribute_group_deserialize (AttributeGroupType type, AttributeList *attr_list, void *group_ptr, uint8_t *buffer, uint8_t *buf_end, const uint8_t *payload, size_t payload_size)
 Deserialize group data into a list and group set up with attribute_group_init().
 
size_t attribute_group_get_serialized_payload_size (AttributeGroupType type, AttributeList *attr_list, void *group_ptr)
 Get the serialized size of group data.
 
size_t attribute_group_serialize_payload (AttributeGroupType type, AttributeList *attr_list, void *group_ptr, uint8_t *buffer, size_t buffer_size)
 Serialize group data.
 

Detailed Description

Shared code for data made of an attribute list and a group of elements with their own attributes.

The elements ("group data") are either the actions of a TimelineItemActionGroup or the addresses of an AddressList. Use the wrappers in Attributes and actions or pbl/services/contacts/attributes_address.h instead, which document the parameters.

Serialized, the attributes are followed by each element: an element header (action id, type and attribute count, or address UUID, type and attribute count) and its attributes. In memory, one buffer holds the attributes, the elements, each element's attributes and finally the string data.

Enumeration Type Documentation

◆ AttributeGroupType

Kind of group elements.

Enumerator
AttributeGroupType_Action 

Elements are TimelineItemAction.

AttributeGroupType_Address 

Elements are Address.

Function Documentation

◆ attribute_group_deserialize()

bool attribute_group_deserialize ( AttributeGroupType  type,
AttributeList *  attr_list,
void *  group_ptr,
uint8_t *  buffer,
uint8_t *  buf_end,
const uint8_t *  payload,
size_t  payload_size 
)

Deserialize group data into a list and group set up with attribute_group_init().

Parameters
typeKind of group elements.
[in,out]attr_listTop-level attribute list.
[in,out]group_ptrTimelineItemActionGroup or AddressList.
bufferString data buffer.
buf_endEnd of the string data buffer.
payloadSerialized data.
payload_sizeSize of payload in bytes.
Returns
true on success.

◆ attribute_group_get_required_buffer_size()

size_t attribute_group_get_required_buffer_size ( AttributeGroupType  type,
uint8_t  num_attributes,
uint8_t  num_group_type_elements,
const uint8_t *  attributes_per_group_type_element,
size_t  required_size_for_strings 
)

Get the size of the buffer holding group data.

Parameters
typeKind of group elements.
num_attributesNumber of top-level attributes.
num_group_type_elementsNumber of elements.
attributes_per_group_type_elementAttribute count of each element.
required_size_for_stringsSize of the string data.
Returns
Size in bytes.

◆ attribute_group_get_serialized_payload_size()

size_t attribute_group_get_serialized_payload_size ( AttributeGroupType  type,
AttributeList *  attr_list,
void *  group_ptr 
)

Get the serialized size of group data.

Parameters
typeKind of group elements.
attr_listTop-level attribute list, may be NULL.
group_ptrTimelineItemActionGroup or AddressList, may be NULL.
Returns
Size in bytes.

◆ attribute_group_init()

void attribute_group_init ( AttributeGroupType  type,
AttributeList *  attr_list,
void *  group_ptr,
uint8_t **  buffer,
uint8_t  num_attributes,
uint8_t  num_group_type_elements,
const uint8_t *  attributes_per_group_type_element 
)

Lay out an attribute list and group in a buffer.

Parameters
typeKind of group elements.
[out]attr_listTop-level attribute list.
[out]group_ptrTimelineItemActionGroup or AddressList.
[in,out]bufferBuffer; advanced to the start of the string data.
num_attributesNumber of top-level attributes.
num_group_type_elementsNumber of elements.
attributes_per_group_type_elementAttribute count of each element.

◆ attribute_group_parse_serial_data()

bool attribute_group_parse_serial_data ( AttributeGroupType  type,
uint8_t  num_attributes,
uint8_t  num_group_type_elements,
const uint8_t *  data,
size_t  size,
size_t *  string_alloc_size_out,
uint8_t *  attributes_per_group_type_element_out 
)

Measure serialized group data.

Parameters
typeKind of group elements.
num_attributesNumber of top-level attributes.
num_group_type_elementsNumber of elements.
dataSerialized data.
sizeSize of data in bytes.
[out]string_alloc_size_outSize of the string data.
[out]attributes_per_group_type_element_outAttribute count of each element.
Returns
true if the data is well formed.

◆ attribute_group_serialize_payload()

size_t attribute_group_serialize_payload ( AttributeGroupType  type,
AttributeList *  attr_list,
void *  group_ptr,
uint8_t *  buffer,
size_t  buffer_size 
)

Serialize group data.

Parameters
typeKind of group elements.
attr_listTop-level attribute list, may be NULL.
group_ptrTimelineItemActionGroup or AddressList, may be NULL.
[out]bufferOutput buffer.
buffer_sizeSize of buffer in bytes.
Returns
Number of bytes written.