Defined in File record.hpp
NDEFRecord¶NDEF Record struct.
Public Functions
NDEFRecord()¶Default constructor creates empty NDEF record.
NDEFRecord(const std::vector<uint8_t> &payload, const NDEFRecordType &type, size_t offset = 0, bool chunked = false)¶NDEFRecord(const std::vector<uint8_t> &payload, const NDEFRecordType &type, const std::string &id, size_t offset = 0, bool chunked = false)¶~NDEFRecord()¶validate()¶Validates that if the payload has changed size then the type is no longer empty.
as_bytes(uint8_t flags = 0x00) const¶Creates the bytes representation of the Record object passed.
vector of uint8 byte values
flags: 8 bit value of header flags to combine with internal flags
set_id(const std::string &new_id)¶id() const¶set_type(const NDEFRecordType &type)¶type() const¶set_chunked(bool flag)¶is_chunked() const¶set_payload(const std::vector<uint8_t> &data)¶Update the payload stored in this NDEFRecord object, validating the record after doing so.
payload() const¶payload_length() const¶Access number of bytes in the payload
size_t number of bytes in the payload
header() const¶Creates header byte from information known to NDEF Record. Other values will be set by NDEFMessage.
is_short() const¶is_empty() const¶is_valid() const¶get_text_locale() const¶Extracts the text locale in string from the record object.
ASCII string representation of record’s locale
get_text() const¶Extracts stored text from record.
UTF-8 encoded string of record’s contents
get_uri_protocol() const¶Gets string form of URI protocol from URI Record.
UTF-8 encoded string of record’s URI protocol
get_uri() const¶Gets string form of actual URI from URI Record.
UTF-8 encoded string of record’s URI
Public Static Functions
from_bytes(uint8_t bytes[], size_t len, size_t offset = 0)¶Wrapper around from_byte(vector<uint8_t>) that converts the array to a vector.
Record object created from bytes
bytes: array of bytes (uint8_t) that will be used to attempt to create an NDEFRecord object
len: number of elements in bytes array
offset: byte offset to start from
from_bytes(std::vector<uint8_t> bytes, size_t offset = 0, size_t &bytes_used = default_bytes_used)¶NDEFRecord object created from bytes
bytes: vector of bytes (uint8_t) that will be used to attempt to create an NDEFRecord object
offset: byte offset to start from
create_text_record(const std::u16string &text, const std::string &locale)¶NDEFRecord object with text encoded in UTF-16
text: std::u16string to be converted
locale: string’s locale. Should be kept <= 5 characters, which is the max limit set by the NDEF standard
create_text_record(const std::string &text, const std::string &locale, RecordTextCodec codec = RecordTextCodec::UTF8)¶NDEFRecord object with text encoded in whatever is specified by codec
text: string to be converted
locale: string’s locale. Should be kept <= 5 characters, which is the max limit set by the NDEF standard
codec: RecordTextCodec enum variant representing whether this is a UTF-8 or UTF-16 encoded string
get_text_locale(const std::vector<uint8_t> &payload)¶ASCII string representation of locale in payload
payload: vector of bytes to have locale extracted from
get_text(const std::vector<uint8_t> &payload)¶UTF-8 encoded string of record in byte’s contents
payload: vector of bytes to have locale extracted from
create_uri_record(const std::string &uri)¶Creates URI record from URI provided.
NDEFRecord object with URI encoded
uri: string of URI to encode
get_uri_protocol(const std::vector<uint8_t> &payload)¶Gets string form of URI protocol from URI Record payload.
UTF-8 encoded string of record in byte’s URI protocol
payload: vector of bytes to have URI protocol extracted from
get_uri(const std::vector<uint8_t> &payload)¶Gets string form of actual URI from URI Record payload.
UTF-8 encoded string of record in byte’s URI
payload: vector of bytes to have URI extracted from