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

RecordVCard Class Reference

Specialize the RecordMimeType to store VCard information. More...

#include <RecordVCard.h>

Inherits NDefLib::RecordMimeType.

Public Types

enum  VCardField_t {
  ADDRESS, ADDRESS_HOME, ADDRESS_WORK, AGENT,
  BIRDAY, CATEGORIES, EMAIL, EMAIL_HOME,
  EMAIL_WORK, FORMATTED_NAME, GEO, IMPP,
  PGPKEY_URL, PGPGKEY_BASE64, LOGO, LOGO_URI,
  LOGO_BASE64, NAME, NICKNAME, NOTE,
  ORGANIZATION, PHOTO_URI, PHOTO_BASE64, REVISION,
  SOURCE_URL, TEL, TEL_HOME, TEL_WORK,
  TEL_MOBILE, TITLE, URL
}
 

Type of information that you can store inside the tag.

More...
typedef std::map< VCardField_t,
std::string > 
VCardInfo_t
 Type used to store the vcard information.
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

 RecordVCard (const VCardInfo_t &info=VCardInfo_t())
 Create a record with the specific information.
const std::string & operator[] (const VCardField_t &type) const
 Get the specific information stored in this record.
std::string & operator[] (const VCardField_t &type)
 Get or set/change an information associated with this record.
virtual RecordType_t get_type () const
 Get the record type.
virtual uint16_t get_byte_length ()
virtual uint16_t write (uint8_t *buffer)
 Update the content and write it on the buffer.
bool operator== (const RecordVCard &other)
 Compare two objects.
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.
const std::string & get_mime_type () const
 Return the mime type of the content.
void set_mime_data_pointer (uint8_t *data, uint32_t dataLength)
 Change the data pointer used by this record.
void copy_mime_data (const uint8_t *data, uint32_t dataLength)
 Change the data linked with this record, with this function the data are copied inside the object.
uint32_t get_mime_data_lenght () const
uint8_t const * get_mime_data () const
bool operator== (const RecordMimeType &other) const
 Compare two objects.

Static Public Member Functions

static RecordVCardparse (const RecordHeader &header, const uint8_t *buffer)
 Create a RecordVCard reading the data from the buffer.

Detailed Description

Specialize the RecordMimeType to store VCard information.

This record handles the VCard version 3 format.

See also:
https://en.wikipedia.org/wiki/VCard

Definition at line 52 of file RecordVCard.h.


Member Typedef Documentation

typedef std::map<VCardField_t, std::string> VCardInfo_t

Type used to store the vcard information.

Definition at line 95 of file RecordVCard.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.

Type of information that you can store inside the tag.

Enumerator:
ADDRESS 

ADDRESS.

ADDRESS_HOME 

ADDRESS_HOME.

ADDRESS_WORK 

ADDRESS_WORK.

AGENT 

AGENT.

BIRDAY 

BIRDAY.

CATEGORIES 

CATEGORIES.

EMAIL 

EMAIL.

EMAIL_HOME 

EMAIL_HOME.

EMAIL_WORK 

EMAIL_WORK.

FORMATTED_NAME 

FORMATTED_NAME.

GEO 

GEO latitude and longitude ; separated.

IMPP 

IMPP.

PGPKEY_URL 

PGPKEY_URL.

PGPGKEY_BASE64 

PGPGKEY_BASE64.

LOGO 

LOGO.

LOGO_URI 

LOGO_URI.

LOGO_BASE64 

generic hardcoded image add TYPE=XXXX:imagebyte

NAME 

NAME.

NICKNAME 

NICKNAME.

NOTE 

NOTE.

ORGANIZATION 

ORGANIZATION.

PHOTO_URI 

PHOTO_URI.

PHOTO_BASE64 

generic hardcoded image add TYPE=XXXX:imagebyte

REVISION 

REVISION.

SOURCE_URL 

SOURCE_URL.

TEL 

TEL.

TEL_HOME 

TEL_HOME.

TEL_WORK 

TEL_WORK.

TEL_MOBILE 

TEL_MOBILE.

TITLE 

TITLE.

URL 

URL.

Definition at line 58 of file RecordVCard.h.


Constructor & Destructor Documentation

RecordVCard ( const VCardInfo_t info = VCardInfo_t() ) [explicit]

Create a record with the specific information.

Parameters:
Infooptional information to store into the record.

Definition at line 59 of file RecordVCard.cpp.


Member Function Documentation

void copy_mime_data ( const uint8_t *  data,
uint32_t  dataLength 
) [inherited]

Change the data linked with this record, with this function the data are copied inside the object.

Parameters:
dataPointer to the data buffer.
dataLengthNumber of bytes to write.

Definition at line 105 of file RecordMimeType.cpp.

virtual uint16_t get_byte_length (  ) [virtual]
Returns:
update the record content and return the number of bytes needed to store this record

Reimplemented from Record.

Definition at line 149 of file RecordVCard.h.

const RecordHeader& get_header (  ) const [inherited]

Get the record header.

Returns:
record header

Definition at line 132 of file Record.h.

uint8_t const* get_mime_data (  ) const [inherited]
Returns:
pointer to the content data
DO NOT free this pointer, it is managed by the class.

Definition at line 124 of file RecordMimeType.h.

uint32_t get_mime_data_lenght (  ) const [inherited]
Returns:
number of bytes used to store the content data

Definition at line 116 of file RecordMimeType.h.

const std::string& get_mime_type (  ) const [inherited]

Return the mime type of the content.

Returns:
the mime type of the content.

Definition at line 87 of file RecordMimeType.h.

virtual RecordType_t get_type (  ) const [virtual]

Get the record type.

Returns:
TYPE_MIME_VCARD

Reimplemented from RecordMimeType.

Definition at line 141 of file RecordVCard.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 RecordVCard other )

Compare two objects.

Returns:
true if the records have the same Vcard information

Definition at line 169 of file RecordVCard.h.

bool operator== ( const RecordMimeType other ) const [inherited]

Compare two objects.

Returns:
true if the 2 records have the same mime type, length and data.

Definition at line 150 of file RecordMimeType.h.

const std::string& operator[] ( const VCardField_t type ) const

Get the specific information stored in this record.

Parameters:
Typetype of information to get.
Returns:
if present, the information or an empty string

Definition at line 118 of file RecordVCard.h.

std::string& operator[] ( const VCardField_t type )

Get or set/change an information associated with this record.

Parameters:
typeType of information to change.
Returns:
reference to the string information

Definition at line 132 of file RecordVCard.h.

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

Create a RecordVCard reading the data from the buffer.

Parameters:
headerRecord header.
bufferBuffer to read the data from.
Returns:
an object of type RecordVCard or NULL
User is in charge of freeing the pointer returned by this function.

Reimplemented from RecordMimeType.

Definition at line 105 of file RecordVCard.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_mime_data_pointer ( uint8_t *  data,
uint32_t  dataLength 
) [inherited]

Change the data pointer used by this record.

Parameters:
dataPointer used by this record.
dataLengthNumber of byte to write in this record.
The buffer is not copied or freed by this class.
With this function only the data pointer is copied, so it must not be freed before the object is deallocated.

Definition at line 98 of file RecordMimeType.h.

virtual uint16_t write ( uint8_t *  buffer ) [virtual]

Update the content and write it on the buffer.

Parameters:
[out]bufferbuffer to write the record content into.
Returns:
number of bytes written
See also:
Record::write

Reimplemented from RecordMimeType.

Definition at line 160 of file RecordVCard.h.