Classes


Classes

This section introduces the ``built-in'' VCV data classes as used in the vcv:type attribute. The class names are case sensitve, even if your VCV programming language is not.

String

This is just a string containing any data passed to VCV. Using String as content type and omitting a vcv:type declaration is the same.

Number

This is a string that can be converted to a numerical value.

Integer

This class is more specific, because the Number must not be an integer value. Numbers starting with a - are treated as negative, without a - or with a leading + they are treated as positive.

Float

This one defines a floating point value as known from many programming languages: The value may start with a leading - or +, some (or even none) digit before the decimal point, maybe some trailing digits and at least there could be an exponent. See the following examples for details: 1. = 1.0, .17 = 0.17, 1.E4 = 10000, .5E1 = 5, -5.23E-17 = -5.23*10^-17 or even -5.23*10^-17 meaning exactly this.

Currency

This is a special case of Float: It has only two digits after the decimal point.

Date

This is a string representing a date; it currently supports the forms YYYY-MM-DD (see SQL Date), MM/DD/YYYY (english notation), DD.MM.YYYY (german notation).

Time

This is a string representing a timestamp. The time may be written in the following ways: As Unix timestamp (32 bit signed integer), as seen on most clocks hh:mm with hh as the hours and mm the minutes and in the form hh:mm:ss with seconds.

Date-Time

This is a combination of Date and Time with a blank space between the Date and the Time part, such as DD.MM.YYYY hh:mm:ss.

Database Support

SQL Date

This is a string of the form YYYY-MM-DD with YYYY as the year, MM the numerical value for a month and DD the months day.

SQL Time

This is an alias for Time

SQL Date-Time

As Date-Time, this is the combination of SQL Date and SQL Time.

Custom Classes

You can also add your own classes to the VCV classes repository by writing a either a (perl) regular expression or a validation function for it. Take the following example: We would like to use a content class named BrowserVersion that recognizes values like Mozilla/5.0. A RegExp for this would be (([[:alpha:]]+)\/(\d+)\.(\d+)). So you only need to call the VCV method registerClass() and VCV will use your class like any of the built-in ones:

        registerClass("BrowserVersion", "(([[:alpha:]]+)\/(\d+)\.(\d+))");

If you cannot describe the class using a single regex, you write a validation function that performs certain checks on the submitted value:

        registerClass("BrowserVersion", function_handle);

(Implementations that do not allow function overloading may rename both versions of registerClass(), e.g. registerClassRegExp() and registerClassFunc().)


Revision

This document: $Id: vcv-classes.pod,v 1.1 2005/07/22 16:28:03 robertbienert Exp $

See http://vcv.sourceforge.net/spec/ for the latest revision.

 Classes