mirror of https://github.com/ARMmbed/mbed-os.git
NFC: Add get_record_size in common types.
parent
b6e604338e
commit
cffc0221cc
|
|
@ -112,6 +112,13 @@ public:
|
|||
bool is_last_record = false
|
||||
);
|
||||
|
||||
/**
|
||||
* Compute the size of this Mime object in a ndef record.
|
||||
*
|
||||
* @return The size of the ndef record required to store this object.
|
||||
*/
|
||||
size_t get_record_size() const;
|
||||
|
||||
private:
|
||||
friend class MimeParser;
|
||||
|
||||
|
|
|
|||
|
|
@ -128,6 +128,13 @@ public:
|
|||
bool is_last_record = false
|
||||
);
|
||||
|
||||
/**
|
||||
* Compute the size of this object in a ndef record.
|
||||
*
|
||||
* @return The size of the ndef record required to store this object.
|
||||
*/
|
||||
size_t get_record_size() const;
|
||||
|
||||
private:
|
||||
friend class TextParser;
|
||||
|
||||
|
|
|
|||
|
|
@ -150,6 +150,13 @@ public:
|
|||
bool is_last_record = false
|
||||
);
|
||||
|
||||
/**
|
||||
* Compute the size of this object in a ndef record.
|
||||
*
|
||||
* @return The size of the ndef record required to store this object.
|
||||
*/
|
||||
size_t get_record_size() const;
|
||||
|
||||
/**
|
||||
* Equal operator between two URIs
|
||||
* @param lhs The URI on the left hand side
|
||||
|
|
|
|||
|
|
@ -106,6 +106,21 @@ bool Mime::append_as_record(
|
|||
get_mime_content(),
|
||||
is_last_record
|
||||
);
|
||||
|
||||
size_t Mime::get_record_size() const
|
||||
{
|
||||
return MessageBuilder::compute_record_size(
|
||||
Record(
|
||||
RecordType(
|
||||
RecordType::media_type,
|
||||
get_mime_type()
|
||||
),
|
||||
get_mime_content(),
|
||||
RecordID(),
|
||||
/* chunk */ false,
|
||||
/* last record */ false
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
void Mime::move_data(
|
||||
|
|
|
|||
|
|
@ -149,6 +149,26 @@ bool Text::append_as_record(
|
|||
return message_builder.append_record(type, payload, is_last_record);
|
||||
}
|
||||
|
||||
size_t Text::get_record_size() const
|
||||
{
|
||||
if (!_text_record) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return MessageBuilder::compute_record_size(
|
||||
Record(
|
||||
RecordType(
|
||||
RecordType::well_known_type,
|
||||
text_record_type_value
|
||||
),
|
||||
RecordPayload(_text_record, _text_record_size),
|
||||
RecordID(),
|
||||
/* chunk */ false,
|
||||
/* last record */ false
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
bool TextParser::do_parse(const Record &record, Text &text)
|
||||
{
|
||||
if (record.type.tnf != RecordType::well_known_type) {
|
||||
|
|
|
|||
|
|
@ -129,6 +129,26 @@ bool URI::append_as_record(MessageBuilder &message_builder, bool is_last_record)
|
|||
return message_builder.append_record(type, payload, is_last_record);
|
||||
}
|
||||
|
||||
size_t URI::get_record_size() const
|
||||
{
|
||||
if (!_uri) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return MessageBuilder::compute_record_size(
|
||||
Record(
|
||||
RecordType(
|
||||
RecordType::well_known_type,
|
||||
uri_record_type_value
|
||||
),
|
||||
RecordPayload(_uri, _uri_size),
|
||||
RecordID(),
|
||||
/* chunk */ false,
|
||||
/* last record */ false
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
void URI::move_data(uint8_t *new_uri, size_t new_uri_size)
|
||||
{
|
||||
delete[] _uri;
|
||||
|
|
|
|||
Loading…
Reference in New Issue