Mistake on this page?
Report an issue in GitHub or email us
Data Structures | Public Member Functions | Static Public Member Functions
MessageBuilder Class Reference

Construct a NDEF Message. More...

#include <MessageBuilder.h>

Data Structures

struct  PayloadBuilder
 Build a record payload. More...
 

Public Member Functions

 MessageBuilder (const Span< uint8_t > &buffer)
 Create a new MessageBuilder that can be used to construct valid NDEF messages. More...
 
bool append_record (const RecordType &type, const RecordPayload &payload=RecordPayload(), bool is_last_record=false)
 Append a new record to the message being built. More...
 
bool append_record (const RecordType &type, const PayloadBuilder &builder, bool is_last_record=false)
 Append a new record to the message being built. More...
 
bool append_record (const Record &record, const PayloadBuilder *builder=NULL)
 Append a new record to the message being built. More...
 
void reset ()
 Reset the builder state. More...
 
void reset (const Span< uint8_t > &buffer)
 Reset the builder state and assign a new buffer to it. More...
 
bool is_message_complete () const
 Return true if the message stored is complete and false otherwise. More...
 
Span< const uint8_t > get_message () const
 Return the buffer storing the data if the message is complete or an empty buffer if the message is not complete. More...
 

Static Public Member Functions

static size_t compute_record_size (const Record &record, const PayloadBuilder *builder=NULL)
 Compute the size of a record. More...
 

Detailed Description

Construct a NDEF Message.

Definition at line 37 of file MessageBuilder.h.

Constructor & Destructor Documentation

MessageBuilder ( const Span< uint8_t > &  buffer)

Create a new MessageBuilder that can be used to construct valid NDEF messages.

Parameters
bufferThe data buffer that will contain the NDEF message.

Member Function Documentation

bool append_record ( const RecordType type,
const RecordPayload payload = RecordPayload(),
bool  is_last_record = false 
)

Append a new record to the message being built.

Parameters
typeThe type of the record to insert.
payloadThe payload of the record (optional).
is_last_recordtrue if the record to insert is the last record of the payload or false otherwise.
Returns
true if the record has been successfully inserted or false otherwise.
Note
insertion can fail if the message is already complete or if the size remaining in the message buffer is not large enough to makes the record inserted fit.
bool append_record ( const RecordType type,
const PayloadBuilder builder,
bool  is_last_record = false 
)

Append a new record to the message being built.

Parameters
typeThe type of the record to insert.
builderThe builder of the payload.
is_last_recordtrue if the record to insert is the last record of the payload or false otherwise.
Returns
true if the record has been successfully inserted or false otherwise.
Note
insertion can fail if the message is already complete or if the size remaining in the message buffer is not large enough to makes the record inserted fit.
bool append_record ( const Record record,
const PayloadBuilder builder = NULL 
)

Append a new record to the message being built.

Parameters
recordThe record to insert.
builderThe builder that will construct the payload.
Returns
true if the record has been successfully inserted or false otherwise.
Note
insertion can fail if the message is already complete or if the size remaining in the message buffer is not large enough to makes the record inserted fit.
static size_t compute_record_size ( const Record record,
const PayloadBuilder builder = NULL 
)
static

Compute the size of a record.

Parameters
recordThe record used to compute the size.
builderThe payload builder if any.
Returns
The size of the payload for the record in input.
Span<const uint8_t> get_message ( ) const

Return the buffer storing the data if the message is complete or an empty buffer if the message is not complete.

Returns
The message built.
bool is_message_complete ( ) const

Return true if the message stored is complete and false otherwise.

Returns
true if the message is complete or false.
void reset ( )

Reset the builder state.

void reset ( const Span< uint8_t > &  buffer)

Reset the builder state and assign a new buffer to it.

Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.