Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: NFC M2M_2016_STM32 MyongjiElec_capstone1 IDW01M1_Cloud_IBM ... more
Fork of NDefLib by
RecordText Class Reference
Record containing a simple text. More...
#include <RecordText.h>
Inherits NDefLib::Record.
Public Types | |
| enum | TextEncoding { UTF8, UTF16 } |
Set the type of encoding used to store the text data. More... | |
| enum | RecordType_t { TYPE_UNKNOWN, TYPE_TEXT, TYPE_AAR, TYPE_MIME, TYPE_URI, TYPE_URI_MAIL, TYPE_URI_SMS, TYPE_URI_GEOLOCATION, TYPE_MIME_VCARD, TYPE_WIFI_CONF } |
Enum used to identify the record type. More... | |
Public Member Functions | |
| RecordText (const std::string &text="") | |
| Build a utf8, English text record. | |
| RecordText (const TextEncoding encoding, const std::string &language, const std::string &text) | |
| Build a text record. | |
| virtual RecordType_t | get_type () const |
| Get the record type. | |
| const std::string & | get_text () const |
| Get the text inside this record. | |
| void | set_text (const std::string &text) |
| Change the text content. | |
| const std::string & | get_language () const |
| Get the language used in the text. | |
| TextEncoding | get_encoding () const |
| Get the encoding used to store the text. | |
| bool | operator== (const RecordText &other) const |
| Compare 2 objects. | |
| virtual uint16_t | write (uint8_t *buffer) |
| Write the record content into a buffer. | |
| void | set_as_first_record () |
| Set the record as the first record in the message. | |
| void | set_as_last_record () |
| Set the record as the last record in the message. | |
| bool | is_last_record () const |
| Check if it is the last record in the message. | |
| bool | is_first_record () const |
| Check if it is the first record in the message. | |
| void | set_as_middle_record () |
| Set the record as generic (not the first one and not the last one) | |
| bool | is_middle_record () const |
| Check if the record is in the middle of a chain. | |
| const RecordHeader & | get_header () const |
| Get the record header. | |
| virtual uint16_t | get_byte_length () |
| Number of bytes needed to store this record. | |
Static Public Member Functions | |
| static RecordText * | parse (const RecordHeader &header, const uint8_t *const buffer) |
| Read a recordText from a buffer. | |
Detailed Description
Record containing a simple text.
- The text is copied inside the class.
Definition at line 50 of file RecordText.h.
Member Enumeration Documentation
enum RecordType_t [inherited] |
Enum used to identify the record type.
- Enumerator:
| enum TextEncoding |
Set the type of encoding used to store the text data.
Definition at line 66 of file RecordText.h.
Constructor & Destructor Documentation
| RecordText | ( | const std::string & | text = "" ) |
[explicit] |
Build a utf8, English text record.
- Parameters:
-
text Text to store in the record.
Definition at line 51 of file RecordText.cpp.
| RecordText | ( | const TextEncoding | encoding, |
| const std::string & | language, | ||
| const std::string & | text | ||
| ) |
Build a text record.
- Parameters:
-
encoding Rype used to store the message. language Language used in the text. Text record text.
Definition at line 56 of file RecordText.cpp.
Member Function Documentation
| virtual uint16_t get_byte_length | ( | ) | [virtual, inherited] |
Number of bytes needed to store this record.
- Returns:
- size of the header + size of the record content
Reimplemented in RecordURI, RecordVCard, and RecordWifiConf.
| TextEncoding get_encoding | ( | ) | const |
Get the encoding used to store the text.
- Returns:
- get the encoding used to store the text
Definition at line 123 of file RecordText.h.
| const RecordHeader& get_header | ( | ) | const [inherited] |
| const std::string& get_language | ( | ) | const |
Get the language used in the text.
- Returns:
- Language used in the text.
Definition at line 115 of file RecordText.h.
| const std::string& get_text | ( | ) | const |
Get the text inside this record.
- Returns:
- the text content
Definition at line 98 of file RecordText.h.
| virtual RecordType_t get_type | ( | ) | const [virtual] |
Get the record type.
- Returns:
- TYPE_TEXT
Reimplemented from Record.
Definition at line 90 of file RecordText.h.
| bool is_first_record | ( | ) | const [inherited] |
| bool is_last_record | ( | ) | const [inherited] |
| bool is_middle_record | ( | ) | const [inherited] |
| bool operator== | ( | const RecordText & | other ) | const |
Compare 2 objects.
- Returns:
- true if the objects have the same encoding,language and text
Definition at line 131 of file RecordText.h.
| RecordText * parse | ( | const RecordHeader & | header, |
| const uint8_t *const | buffer | ||
| ) | [static] |
Read a recordText from a buffer.
- Parameters:
-
header Record header. buffer Buffer to read the record content from.
- Returns:
- a record of type Text or NULL if it was not possible build this type of record
- User is in charge of freeing the pointer returned by this function.
Definition at line 77 of file RecordText.cpp.
| void set_as_first_record | ( | ) | [inherited] |
| void set_as_last_record | ( | ) | [inherited] |
| void set_as_middle_record | ( | ) | [inherited] |
| void set_text | ( | const std::string & | text ) |
Change the text content.
- Parameters:
-
text New text to store.
Definition at line 106 of file RecordText.h.
| uint16_t write | ( | uint8_t * | buffer ) | [virtual] |
Write the record content into a buffer.
- Parameters:
-
[out] buffer buffer to write the record content into, the buffer size must be almost Record#getByteLength bytes.
- Returns:
- number of written bytes
Implements Record.
Definition at line 62 of file RecordText.cpp.
Generated on Tue Jul 12 2022 14:14:49 by
1.7.2
