Class::Struct::FIELDS 1.1
Sponsored Links
Class::Struct::FIELDS 1.1 Ranking & Summary
File size:
0.018 MB
Platform:
Any Platform
License:
Perl Artistic License
Price:
Downloads:
835
Date added:
2007-07-11
Publisher:
B. K. Oxley
Class::Struct::FIELDS 1.1 description
Class::Struct::FIELDS module combine Class::Struct, base and fields.
SYNOPSIS
(This page documents Class::Struct::FIELDS v.1.1.)
use Class::Struct::FIELDS;
# declare struct, based on fields, explicit class name:
struct (CLASS_NAME => { ELEMENT_NAME => ELEMENT_TYPE, ... });
use Class::Struct::FIELDS;
# declare struct, based on fields, explicit class name
# with inheritance:
struct (CLASS_NAME => [qw(BASE_CLASSES ...)],
{ ELEMENT_NAME => ELEMENT_TYPE, ... });
package CLASS_NAME;
use Class::Struct::FIELDS;
# declare struct, based on fields, implicit class name:
struct (ELEMENT_NAME => ELEMENT_TYPE, ...);
package CLASS_NAME;
use Class::Struct::FIELDS;
# declare struct, based on fields, implicit class name
# with inheritance:
struct ([qw(BASE_CLASSES ...)], ELEMENT_NAME => ELEMENT_TYPE, ...);
package MyObj;
use Class::Struct::FIELDS;
# declare struct with four types of elements:
struct (s => $, a => @, h => %, x => &, c => My_Other_Class);
$obj = new MyObj; # constructor
# scalar type accessor:
$element_value = $obj->s; # element value
$obj->s (new value); # assign to element
# array type accessor:
$ary_ref = $obj->a; # reference to whole array
$ary_element_value = $obj->a->[2]; # array element value
$ary_element_value = $obj->a (2); # same thing
$obj->a->[2] = new value; # assign to array element
$obj->a (2, newer value); # same thing
# hash type accessor:
$hash_ref = $obj->h; # reference to whole hash
$hash_element_value = $obj->h->{x}; # hash element value
$hash_element_value = $obj->h (x); # same thing
$obj->h->{x} = new value; # assign to hash element
$obj->h (x, newer value); # same thing
# code type accessor:
$code_ref = $obj->x; # reference to code
$obj->x->(...); # call code
$obj->x (sub {...}); # assign to element
# regexp type accessor:
$regexp = $obj->r; # reference to code
$string =~ m/$obj->r/; # match regexp
$obj->r (qr/ ... /); # assign to element
# class type accessor:
$element_value = $obj->c; # object reference
$obj->c->method (...); # call method of object
$obj->c (My_Other_Class::->new); # assign a new object
Class::Struct::FIELDS exports a single function, struct. Given a list of element names and types, and optionally a class name and/or an array reference of base classes, struct creates a Perl 5 class that implements a "struct-like" data structure with inheritance.
The new class is given a constructor method, new, for creating struct objects.
Each element in the struct data has an accessor method, which is used to assign to the element and to fetch its value. The default accessor can be overridden by declaring a sub of the same name in the package. (See Example 2.)
Each elements type can be scalar, array, hash, code or class.
SYNOPSIS
(This page documents Class::Struct::FIELDS v.1.1.)
use Class::Struct::FIELDS;
# declare struct, based on fields, explicit class name:
struct (CLASS_NAME => { ELEMENT_NAME => ELEMENT_TYPE, ... });
use Class::Struct::FIELDS;
# declare struct, based on fields, explicit class name
# with inheritance:
struct (CLASS_NAME => [qw(BASE_CLASSES ...)],
{ ELEMENT_NAME => ELEMENT_TYPE, ... });
package CLASS_NAME;
use Class::Struct::FIELDS;
# declare struct, based on fields, implicit class name:
struct (ELEMENT_NAME => ELEMENT_TYPE, ...);
package CLASS_NAME;
use Class::Struct::FIELDS;
# declare struct, based on fields, implicit class name
# with inheritance:
struct ([qw(BASE_CLASSES ...)], ELEMENT_NAME => ELEMENT_TYPE, ...);
package MyObj;
use Class::Struct::FIELDS;
# declare struct with four types of elements:
struct (s => $, a => @, h => %, x => &, c => My_Other_Class);
$obj = new MyObj; # constructor
# scalar type accessor:
$element_value = $obj->s; # element value
$obj->s (new value); # assign to element
# array type accessor:
$ary_ref = $obj->a; # reference to whole array
$ary_element_value = $obj->a->[2]; # array element value
$ary_element_value = $obj->a (2); # same thing
$obj->a->[2] = new value; # assign to array element
$obj->a (2, newer value); # same thing
# hash type accessor:
$hash_ref = $obj->h; # reference to whole hash
$hash_element_value = $obj->h->{x}; # hash element value
$hash_element_value = $obj->h (x); # same thing
$obj->h->{x} = new value; # assign to hash element
$obj->h (x, newer value); # same thing
# code type accessor:
$code_ref = $obj->x; # reference to code
$obj->x->(...); # call code
$obj->x (sub {...}); # assign to element
# regexp type accessor:
$regexp = $obj->r; # reference to code
$string =~ m/$obj->r/; # match regexp
$obj->r (qr/ ... /); # assign to element
# class type accessor:
$element_value = $obj->c; # object reference
$obj->c->method (...); # call method of object
$obj->c (My_Other_Class::->new); # assign a new object
Class::Struct::FIELDS exports a single function, struct. Given a list of element names and types, and optionally a class name and/or an array reference of base classes, struct creates a Perl 5 class that implements a "struct-like" data structure with inheritance.
The new class is given a constructor method, new, for creating struct objects.
Each element in the struct data has an accessor method, which is used to assign to the element and to fetch its value. The default accessor can be overridden by declaring a sub of the same name in the package. (See Example 2.)
Each elements type can be scalar, array, hash, code or class.
Class::Struct::FIELDS 1.1 Screenshot
Class::Struct::FIELDS 1.1 Keywords
FIELDS
ELEMENT
NAME
TYPE
CLASS
FIELDS 1.1
assign to
same thing
reference to
value
struct
hash
new
X
assign
Class::Struct::FIELDS
Bookmark Class::Struct::FIELDS 1.1
Class::Struct::FIELDS 1.1 Copyright
WareSeeker periodically updates pricing and software information of Class::Struct::FIELDS 1.1 full version from the publisher, so some information may be slightly out-of-date. You should confirm all information before relying on it. Software piracy is theft, Using crack, password, serial numbers, registration codes, key generators is illegal and prevent future development of Class::Struct::FIELDS 1.1 Edition. Download links are directly from our publisher sites, torrent files or links from rapidshare.com, yousendit.com or megaupload.com are not allowed
Featured Software
Want to place your software product here?
Please contact us for consideration.
Contact WareSeeker.com
Related Information
fieldstone mortgage
elementary
value city department store
structural pest control board
structural engineering
periodic table of elements
blue book value
marshall fields
value city furniture store
elementary schools
fieldstone cinemas
structured settlement
structuralism
fields of gold lyrics
hashim thaqi
value city furniture
name definitions
elements
Related Software
Class::ArrayObjects is a Perl utility class for array based objects. Free Download
Class::Date provides a date datatype for Perl. Free Download
Class::Accessor::Fast::Contained is a Perl module for fast accessors with data containment. Free Download
Class::Bits is a Perl module with class wrappers around bit vectors. Free Download
Validate_fields Class is an easy-to-use form field validation PHP script. Free Download
Streams is an I/O library designed to eventually replace the current I/O facilities based on using Handles. Free Download
C::DynaLib::Struct is a tool for handling the C `struct data type. Free Download
Class::Method::hash is a Perl module that helps you create methods for handling a hash value. Free Download
Latest Software
Popular Software
Favourite Software