ST / NDefLib

Dependents:   NFC M2M_2016_STM32 MyongjiElec_capstone1 IDW01M1_Cloud_IBM ... more

Fork of NDefLib by ST Expansion SW Team

Embed: (wiki syntax)

« Back to documentation index

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 RecordHeaderget_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 RecordTextparse (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:
TYPE_UNKNOWN 

UNKNOWN record.

TYPE_TEXT 

TEXT.

TYPE_AAR 

Android Archive record.

TYPE_MIME 

generic MIME type

TYPE_URI 

generic URI

TYPE_URI_MAIL 

Email URI record.

TYPE_URI_SMS 

SMS URI record.

TYPE_URI_GEOLOCATION 

position URI record

TYPE_MIME_VCARD 

VCard record.

TYPE_WIFI_CONF 

Wifi configuration.

Definition at line 56 of file Record.h.

Set the type of encoding used to store the text data.

Enumerator:
UTF8 

UTF8.

UTF16 

UTF16.

Definition at line 66 of file RecordText.h.


Constructor & Destructor Documentation

RecordText ( const std::string &  text = "" ) [explicit]

Build a utf8, English text record.

Parameters:
textText 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:
encodingRype used to store the message.
languageLanguage used in the text.
Textrecord 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.

Definition at line 140 of file Record.h.

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]

Get the record header.

Returns:
record header

Definition at line 132 of file Record.h.

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]

Check if it is the first record in the message.

Returns:
true if it is the fist record in the message

Definition at line 98 of file Record.h.

bool is_last_record (  ) const [inherited]

Check if it is the last record in the message.

Returns:
true if it is the last record in the message

Definition at line 90 of file Record.h.

bool is_middle_record (  ) const [inherited]

Check if the record is in the middle of a chain.

Returns:
true if is not the fist or the last one

Definition at line 114 of file Record.h.

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:
headerRecord header.
bufferBuffer 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]

Set the record as the first record in the message.

Definition at line 75 of file Record.h.

void set_as_last_record (  ) [inherited]

Set the record as the last record in the message.

Definition at line 82 of file Record.h.

void set_as_middle_record (  ) [inherited]

Set the record as generic (not the first one and not the last one)

Definition at line 105 of file Record.h.

void set_text ( const std::string &  text )

Change the text content.

Parameters:
textNew 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]bufferbuffer 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.