Home modules.gotpike.org
Username: Password: [Create Account]
[Forgot Password?]

Modules

ADT
Database
GTK2
GUI
IP
PiJAX
Public
Sql
Stdio
Subversion
System
Tools
Xosd
lua
v4l2
wx

Recent Changes

Public.Parser.XML2 1.50
Public.ZeroMQ 1.1
Public.Template.Mustache 1.0
Public.Protocols.XMPP 1.4
Sql.Provider.jdbc 1.0

Popular Downloads

Public.Parser.JSON2 1.0
Public.Parser.JSON 0.2
GTK2 2.23
Public.Web.FCGI 1.8
Public.Parser.XML2 1.48


Pike Module Reference:

module version 0.2, prepared

  MODULE Public
Modules
Standards

  MODULE Public.Standards
Modules
vCard

  MODULE Public.Standards.vCard
Classes
ContentLine
LineParser
Object
Parser
vCard

Methods
non_strict_parser()
strict_parser()
Description

This module implements the vCard standard as specified in rfc 2426. It is also used to by Public.Standards.iCalendar because the format is almost the same in both cases.

Example
object parser = Public.Standards.vCard.strict_parser();
 	object vcard = parser->parse(data);
 	werror("name: %O\n", vcard->get_prop("N"));
 	vcard->del_prop("N"); // only one "N" property is allowed
 	vcard->add_prop("N", ([ 
 		"familyname" : "Doe",
 		"firstname" : "John",
 	]));
 	vcard->add_prop("TEL", ([ "number" : "+49 12345678", "home" : 1, "pref" : 1 ])); 
 	string s = vcard->render();
Note

Some vCard implementations do not follow the rfc. Therefore you might encounter cases where "\n" is used as a line delimiter. Its not easily possible to work around those cases automatically without breaking support in other cases. Hence this parser will not gracefully accept that as input.


Method strict_parser

object Public.Standards.vCard.strict_parser()

Description

Create a new strict parser object. Use this instead of manually creating an Public.Standards.Parser instances unless you know what you are doing. Will try to automatically detect the version of the vCard and format it accordingly.


Method non_strict_parser

object Public.Standards.vCard.non_strict_parser()

Description

Create a new non-strict parser object. Will create Public.Standards.vCard.Object object and hence not be too strict about the content of vCards.

  CLASS Public.Standards.vCard.Parser
Methods
create()
parse()
parse_all()
parse_cline()

Method create

void Public.Standards.vCard.Parser()->create(program|object|mapping(string : object)|function blueprint, void|object|mapping(string : object) parsers)

Description

Create a new Parser object.

Parameter blueprint

Use this if you want the parser to create something else than Public.Standards.vCard.Object instances.

Parameter parsers

Parsers to use for specific Components. This is used by the iCalendar module. There are no components in vCards.


Method parse

int|object Public.Standards.vCard.Parser()->parse(void|string data)

Description

Parse at most one Object. Call this every time when more data is available. Will return a parsed object if there is a complete one available. You probably want to put this into a while-loop in case data contained more than one object.


Method parse_cline

int|object Public.Standards.vCard.Parser()->parse_cline(object(.ContentLine) line)

Description

Same as parse() but is working on a Public.Parser.vCard.ContentLine instead.


Method parse_all

array(object) Public.Standards.vCard.Parser()->parse_all(string|void data)

Description

Convenient function that parses a list of vCards from data.

  CLASS Public.Standards.vCard.ContentLine
Methods
decode()
render()
Description

Represents one line in a vCard format.

See also

Public.Standards.vCard.LineParser


Variable name

string Public.Standards.vCard.ContentLine()->name

Description

Name of the content-line (e.g. "begin", "end", "N").


Variable params

mapping(string : array(string)|string|int) Public.Standards.vCard.ContentLine()->params

Description

Parameters of the content-line. Type int is used for parameters that do not have a value.


Variable value

array(string)|string Public.Standards.vCard.ContentLine()->value

Description

Value of the content-line.


Method decode

string Public.Standards.vCard.ContentLine()->decode()

Description

Returns the decoded value of the content-line.


Method render

string Public.Standards.vCard.ContentLine()->render()

Description

Render the content line. Folds lines according to the specification in rfc 2425.

  CLASS Public.Standards.vCard.Object
Methods
add_prop()
render()
Description

Simple class representing a vCard object. Use Public.Standards.vCard.vCard for a more convenient interface.


Inherit LowerCaseProperties

  • .LowerCaseProperties

  • Variable name

    string Public.Standards.vCard.Object()->name

    Description

    Name of the object. Usually "VCARD".


    Method render

    object(String.Buffer)|string Public.Standards.vCard.Object()->render(object(String.Buffer)|void buffer)

    Description

    Render the vCard to a string/String.Buffer.


    Method add_prop

    void Public.Standards.vCard.Object()->add_prop(mixed key, mixed val)

    Description

    Add a property.

      CLASS Public.Standards.vCard.vCard
    Methods
    add_prop()
    get_prop()
    get_props()
    Description

    Class representing a vCard. Is stricter than Object and tries to enforce correct properties. Additionally it transforms some properties into pike types automatically.


    Inherit Object

  • .Object

  • Variable version

    string Public.Standards.vCard.vCard()->version

    Description

    Version of the vCard specification that should be used in generating vCards. You can create a vCard that follows the vCard 3.0 standard by setting version to 3.0. The default is version 2.1 which should be supported by most applications.


    Method get_prop

    mixed Public.Standards.vCard.vCard()->get_prop(string key, void|int list)

    Description

    Retrieves the value of the Property key. In case of some properties the value is automatically transformed. Look at the description of set_prop for more details. In case several properties of the same name exist, this returns either the first or the preferred one (e.g. the "adr" and "tel" properties can have the "pref" parameter set).


    Method get_props

    array Public.Standards.vCard.vCard()->get_props(string key)

    Description

    Same as get_prop() but always return all properties of that name. If non can be found the return value will be an empty array.


    Method add_prop

    void Public.Standards.vCard.vCard()->add_prop(string key, mixed value)

    Description

    Add a property to the vCard. Depending on the key, this method expects the following as value:

    "adr"

    A mapping containing entries "officebox", "extended", "street", "city", "region", "postcode" and "country". Additionally its possible to add "postal", "work", "parcel", "home" or "intl" to further specify the type of the address entry.

    "tel"

    This may either be a string/int containing the telephone number or, alternatively, a mapping containing the entries "number" and optionally "home", "work", "cell", "bbs", "pager", "modem", "voice", "isdn", "pcs", "msg", "car", "fax", "video", "pref" to indicate the type of the telephone number.

    "email"

    A string or object containing the email address. In case of an object (e.g. Standards.URI) it is simply casted to a string.

    "n"

    A mapping containing the entries "familyname", "firstname", "middlename", "prefix" and "suffix".

    "photo"

    A string containing a jpeg encoded picture.

    "logo"

    A string containing a jpeg encoded picture.

    "version"

    A string or float containing the version of the vCard specification that should be used when rendering the vCard. Use either 2.1 or 3.0.

    The following properties have to be passed as strings and are used "as-is": "fn", "bday", "nickname", "label", "mailer", "tz", "geo", "title", "role", "agent", "org", "categories", "note", "prodid", "rev", "sort-string", "sound", "source", "url", "uid", "class", "key". Properties beginning with "x-" are also accepted. These are allowed by the vCard specification for extensions to the format.

    See also

    Have a look at the vCard specification for information about how those different properties are defined.

      CLASS Public.Standards.vCard.LineParser
    Methods
    add_data()
    parse()
    Description

    This class parses one line of the vCard/iCalendar format at a time.


    Method add_data

    void Public.Standards.vCard.LineParser()->add_data(string data)

    Description

    Add data to the internal buffer. Will be processed on parse().


    Method parse

    object(.ContentLine) Public.Standards.vCard.LineParser()->parse(void|string data)

    Description

    Parse at most one content-line. Returns 0 if no complete content-line can be found in the buffer.

    gotpike.org | Copyright © 2004 - 2019 | Pike is a trademark of Department of Computer and Information Science, Linköping University