Mbed OS Reference
Loading...
Searching...
No Matches
Text Class Reference

Represent the well known type text. More...

#include <Text.h>

Public Types

enum  encoding_t { UTF8 = 0 , UTF16 = 1 }
 Encoding of the text. More...
 

Public Member Functions

 Text ()
 Construct an empty text element. More...
 
 Text (encoding_t text_encoding, const Span< const uint8_t > &language_code, const Span< const uint8_t > &text)
 Construct a text element from a data buffer and an encoding. More...
 
 Text (const Text &to_copy)
 Copy construct a text element. More...
 
 ~Text ()
 Destroy a text element. More...
 
Textoperator= (const Text &to_copy)
 Copy assignment of another text element. More...
 
void set_text (encoding_t text_encoding, const Span< const uint8_t > &language_code, const Span< const uint8_t > &text)
 Copy a text from an external buffer. More...
 
encoding_t get_encoding () const
 Get the encoding of the text. More...
 
Span< const uint8_t > get_language_code () const
 Return the language code. More...
 
Span< const uint8_t > get_text () const
 Return the text contained in this object. More...
 
bool append_as_record (MessageBuilder &message_builder, bool is_last_record=false) const
 Append into a message builder. More...
 
size_t get_record_size () const
 Compute the size of this object in a ndef record. More...
 

Detailed Description

Represent the well known type text.

Definition at line 41 of file Text.h.

Member Enumeration Documentation

◆ encoding_t

enum encoding_t

Encoding of the text.

Enumerator
UTF8 

UTF8.

UTF16 

UTF16.

Definition at line 46 of file Text.h.

Constructor & Destructor Documentation

◆ Text() [1/3]

Text ( )

Construct an empty text element.

◆ Text() [2/3]

Text ( encoding_t  text_encoding,
const Span< const uint8_t > &  language_code,
const Span< const uint8_t > &  text 
)

Construct a text element from a data buffer and an encoding.

Parameters
text_encodingThe encoding of the text.
language_codeThe string of the language code.
textThe text buffer.
Note
To remove the NULL terminator of the C-string of the language_code and text parameters, you can use the utility function span_from_cstr.

◆ Text() [3/3]

Text ( const Text to_copy)

Copy construct a text element.

Parameters
to_copy

◆ ~Text()

~Text ( )

Destroy a text element.

Member Function Documentation

◆ operator=()

Text & operator= ( const Text to_copy)

Copy assignment of another text element.

Parameters
to_copyThe Text instance to copy
Returns
a reference to this object.

◆ set_text()

void set_text ( encoding_t  text_encoding,
const Span< const uint8_t > &  language_code,
const Span< const uint8_t > &  text 
)

Copy a text from an external buffer.

Parameters
text_encodingThe encoding of the text.
language_codeThe language code of the text.
textThe text to copy.
Note
To remove the NULL terminator of the C-string of the language_code and text parameters, you can use the utility function span_from_cstr.

◆ get_encoding()

encoding_t get_encoding ( ) const

Get the encoding of the text.

Returns
The encoding of the text.

◆ get_language_code()

Span< const uint8_t > get_language_code ( ) const

Return the language code.

Returns
The language code.

◆ get_text()

Span< const uint8_t > get_text ( ) const

Return the text contained in this object.

Returns
The text contained in this object.

◆ append_as_record()

bool append_as_record ( MessageBuilder message_builder,
bool  is_last_record = false 
) const

Append into a message builder.

◆ get_record_size()

size_t get_record_size ( ) const

Compute the size of this object in a ndef record.

Returns
The size of the ndef record required to store this object.