18#ifndef NFC_NDEF_MESSAGEPARSER_H_
19#define NFC_NDEF_MESSAGEPARSER_H_
22#include "platform/Span.h"
148 struct parsing_state_t;
151 bool parse_record(parsing_state_t &it);
153 static uint8_t compute_lengths_size(uint8_t header);
154 static uint8_t extract_type_length(parsing_state_t &s);
155 static uint32_t extract_payload_length(parsing_state_t &s, uint8_t header);
156 static uint8_t extract_id_length(parsing_state_t &s, uint8_t header);
159 void report_parsing_started();
160 void report_record_parsed(
const Record &record);
161 void report_parsing_terminated();
162 void report_parsing_error(
error_t error, parsing_state_t &parsing_state);
Event driven NDEF Message parser.
void parse(const Span< const uint8_t > &data_buffer)
Parse an NDEF Message.
MessageParser()
Construct a message parser.
error_t
Error that can be reported by the parsing operation.
@ MISSING_MESSAGE_END
Message is not properly closed.
@ INSUFICIENT_DATA
There is not enough data left to pursue parsing of the message.
@ INVALID_EMPTY_RECORD
An empty record is malformed.
@ CHUNK_RECORD_NOT_SUPPORTED
Chunk record encountered.
@ MISSING_TYPE_VALUE
Type is missing in a record expecting a type (well known type, media type, absolute uri or external t...
@ INVALID_UNCHANGED_TYPE
Record of unchanged type contains a type.
@ INVALID_TYPE_NAME_FORMAT
The type name of a record is invalid.
@ INVALID_UNKNOWN_TYPE_LENGTH
Record of unknown type embed a type length different than 0.
@ INVALID_MESSAGE_START
The message doesn't start with a message start tag.
void set_delegate(Delegate *delegate)
Set the handler that processes parsing events.
Nonowning view to a sequence of contiguous elements.
Report parsing event to the application.
virtual void on_parsing_terminated()
Invoked when parsing is over.
virtual void on_parsing_started()
Invoked when parsing as started.
virtual void on_record_parsed(const Record &record)
Invoked when a record has been parsed.
~Delegate()
Protected non virtual destructor.
virtual void on_parsing_error(error_t error)
Invoked when an error is present in the message.