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

RecordURI Class Reference

Record that contains an URI address. More...

#include <RecordURI.h>

Inherits NDefLib::Record.

Inherited by RecordGeo, RecordMail, and RecordSMS.

Public Types

enum  knowUriId_t {
  UNKNOWN = 0X00, HTTP_WWW = 0X01, HTTPS_WWW = 0X02, HTTP = 0X03,
  HTTPS = 0X04, TEL = 0x05, MAIL = 0X06, FTP_ANONIMUS = 0X07,
  FTP_FTP = 0X08, FTPS = 0X09, SFTP = 0X0A, SMB = 0X0B,
  NFS = 0X0C, FTP = 0X0d, DAV = 0X0E, NEWS = 0X0F,
  TELNET = 0X10, IMAP = 0X11, RTSP = 0X12, URN = 0X13,
  POP = 0X14, SIP = 0X15, SIPS = 0X016, TFTP = 0X017,
  BTSPP = 0x018, BTL2CAP = 0x019, BTGOEP = 0X01A, TCPOBEX = 0X1B,
  IRDAOBEX = 0X1C, FILE = 0X1D, URN_EPC_ID = 0X1E, URN_EPC_TAG = 0X1F,
  URN_EPC_PAT = 0X20, URN_EPC_RAW = 0X21, URN_EPC = 0X22, URN_NFC = 0X23
}
 

If you want encode an know URI you can use this define to avoid to encode the URI type as string.

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

 RecordURI (knowUriId_t URIId, const std::string &URIContent="")
 Build RecordUri with a defined URI type.
 RecordURI (const std::string &URIType, const std::string &URIContent="")
 Build a custom URI type.
virtual RecordType_t get_type () const
 Get the record type.
knowUriId_t get_uri_id () const
 Returns the URI type.
virtual uint16_t get_byte_length ()
 Number of bytes needed to store this record.
std::string & get_content ()
 Returns the URI content.
void set_content (const std::string &URI)
 Change the URI content.
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 write (uint8_t *buffer)=0
 Write the record content into a buffer.

Static Public Member Functions

static RecordURIparse (const RecordHeader &header, const uint8_t *buffer)
 Load a record URI from a buffer.

Detailed Description

Record that contains an URI address.

Definition at line 49 of file RecordURI.h.


Member Enumeration Documentation

If you want encode an know URI you can use this define to avoid to encode the URI type as string.

Enumerator:
UNKNOWN 

UNKNOWN.

HTTP_WWW 

HTTP_WWW.

HTTPS_WWW 

HTTPS_WWW.

HTTP 

HTTP.

HTTPS 

HTTPS.

TEL 

TEL.

MAIL 

MAIL.

FTP_ANONIMUS 

FTP_ANONIMUS.

FTP_FTP 

FTP_FTP.

FTPS 

FTPS.

SFTP 

SFTP.

SMB 

SMB.

NFS 

NFS.

FTP 

FTP.

DAV 

DAV.

NEWS 

NEWS.

TELNET 

TELNET.

IMAP 

IMAP.

RTSP 

RTSP.

URN 

URN.

POP 

POP.

SIP 

SIP.

SIPS 

SIPS.

TFTP 

TFTP.

BTSPP 

BTSPP.

BTL2CAP 

BTL2CAP.

BTGOEP 

BTGOEP.

TCPOBEX 

TCPOBEX.

IRDAOBEX 

IRDAOBEX.

FILE 

FILE.

URN_EPC_ID 

URN_EPC_ID.

URN_EPC_TAG 

URN_EPC_TAG.

URN_EPC_PAT 

URN_EPC_PAT.

URN_EPC_RAW 

URN_EPC_RAW.

URN_EPC 

URN_EPC.

URN_NFC 

URN_NFC.

Definition at line 67 of file RecordURI.h.

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.


Constructor & Destructor Documentation

RecordURI ( knowUriId_t  URIId,
const std::string &  URIContent = "" 
) [explicit]

Build RecordUri with a defined URI type.

Parameters:
URIIdURI type.
URIContentURI content.
The URI prefix is removed.
The string is copied inside the class.

Definition at line 63 of file RecordURI.cpp.

RecordURI ( const std::string &  URIType,
const std::string &  URIContent = "" 
) [explicit]

Build a custom URI type.

Parameters:
URITypestring with the URI type.
URIContentURI content.

Definition at line 69 of file RecordURI.cpp.


Member Function Documentation

virtual uint16_t get_byte_length (  ) [virtual]

Number of bytes needed to store this record.

Returns:
size of the header + size of the record content

Reimplemented from Record.

Definition at line 138 of file RecordURI.h.

std::string& get_content (  )

Returns the URI content.

Returns:
URI content

Definition at line 147 of file RecordURI.h.

const RecordHeader& get_header (  ) const [inherited]

Get the record header.

Returns:
record header

Definition at line 132 of file Record.h.

virtual RecordType_t get_type (  ) const [virtual]

Get the record type.

Returns:
TYPE_URI

Reimplemented from Record.

Reimplemented in RecordGeo, RecordMail, and RecordSMS.

Definition at line 126 of file RecordURI.h.

knowUriId_t get_uri_id (  ) const

Returns the URI type.

Returns:
URI type inside this record, UNKNOWN if unknown

Definition at line 134 of file RecordURI.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.

RecordURI * parse ( const RecordHeader header,
const uint8_t *  buffer 
) [static]

Load a record URI from a buffer.

Parameters:
headerRecord header.
bufferBuffer to read the tag playload from.
Returns:
record or NULL if it was not possible build it
User is in charge of freeing the pointer returned by this function.

Reimplemented in RecordGeo, RecordMail, and RecordSMS.

Definition at line 94 of file RecordURI.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_content ( const std::string &  URI )

Change the URI content.

Parameters:
URInew URI content.

Definition at line 156 of file RecordURI.h.

virtual uint16_t write ( uint8_t *  buffer ) [pure virtual, inherited]

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

Implemented in EmptyRecord, RecordAAR, RecordMimeType, RecordText, RecordVCard, and RecordWifiConf.