Main > Free Download Search >

Free accessor software for linux

accessor

Sponsored Links
Sponsored Links
Secleted [ 0 ] software to compare
Results 1 - 15 of about 62
Class::Accessor::Named 0.005

Class::Accessor::Named 0.005


Class::Accessor::Named is a great way to automate the tedious task of generating accessors and mutators. more>>
Class::Accessor::Named is a great way to automate the tedious task of generating accessors and mutators. One small drawback is that due to the details of the implemenetation, you only get one "__ANON__" entry in profiling output.

That entry contains all your accessors, which can be a real pain if youre attempting to figure out _ w_ h_ i_ c_ h of your accessors is being called six billion times.

This module is a development aid which uses Hook::LexWrap and Sub::Name to talk your accessors into identifying themselves. While it shouldnt add much additional runtime overhead (as it acts only Class::Accessors generator functions), it has not been designed for production deployment.

<<less
Download (0.020MB)
Added: 2006-09-06 License: Perl Artistic License Price:
1143 downloads
Object::AutoAccessor 0.06

Object::AutoAccessor 0.06


Object::AutoAccessor is an accessor class by using AUTOLOAD. more>>
Object::AutoAccessor is an accessor class by using AUTOLOAD.

SYNOPSIS

use Object::AutoAccessor;

my $struct = {
foo => {
bar => {
baz => BUILD OK,
},
},
};

# Now lets easily accomplish it.
my $obj = Object::AutoAccessor->build($struct);

print $obj->foo->bar->baz; # prints BUILD OK

# OK, now reverse it!
$obj->foo->bar->baz(TO HASHREF);
my $hashref = $obj->as_hashref;
print $hashref->{foo}->{bar}->{baz}; # prints TO HASHREF;

# Of course, new() can be used.
$obj = Object::AutoAccessor->new();

# setter methods
$obj->foo(bar);
$obj->set_foo(bar);
$obj->param(foo => bar);

# getter methods
$obj->foo();
$obj->get_foo();
$obj->param(foo);

# $obj->param() is compatible with HTML::Template->param()
my @keywords = $obj->param();
my $val = $obj->param(hash);
$obj->param(key => val);

my $tmpl = HTML::Template->new(..., associate => [$obj], ...);

Object::AutoAccessor is a Accessor class to get/set values by AUTOLOADed method automatically. Moreover, param() is compatible with HTML::Template module, so you can use Object::AutoAccessor object for HTML::Templates associate option.

<<less
Download (0.006MB)
Added: 2007-05-18 License: Perl Artistic License Price:
889 downloads
Class::Accessor::Fast::Contained 0.05

Class::Accessor::Fast::Contained 0.05


Class::Accessor::Fast::Contained is a Perl module for fast accessors with data containment. more>>
Class::Accessor::Fast::Contained is a Perl module for fast accessors with data containment.

SYNOPSIS

package Foo;
use base qw(Class::Accessor::Fast::Contained);

# The rest is the same as Class::Accessor::Fast

This module does two things differently to the venerable Class::Accessor::Fast :

Fields are stored at arms-length within a single hash value of $self, rather than directly in the $self blessed referent.
new() allows mixin into an existing object, rather than creating and returning a new blessed hashref. To do this, just call something like:

my $self = Some::Other::Class->new;
$self = $self->Class::Accessor::Fast::Contained::new;

Note that the mixin code only supports objects which use a blessed hash reference or a blessed typeglob reference.
An alias setup() is available which does the same as new() but might make more sense if being used in this way.

<<less
Download (0.005MB)
Added: 2007-03-15 License: GPL (GNU General Public License) Price:
953 downloads
Class::Declare 0.08

Class::Declare 0.08


Class::Declare is a Perl module created to declare classes with public, private and protected attributes and methods. more>>
Class::Declare is a Perl module created to declare classes with public, private and protected attributes and methods.

SYNOPSIS

package My::Class;

use strict;
use warnings;
use base qw( Class::Declare );

__PACKAGE__->declare(

public => { public_attr => 42 } ,
private => { private_attr => Foo } ,
protected => { protected_attr => Bar } ,
class => { class_attr => [ 3.141 ] }
static => { static_attr => { a => 1 } } ,
restricted => { restricted_attr => string } ,
abstract => abstract_attr ,
friends => main::trustedsub ,
new => [ public_attr , private_attr ] ,
init => sub { # object initialisation
...
1;
} ,
strict => 0

);

sub publicmethod {
my $self = __PACKAGE__->public( shift );
...
}

sub privatemethod {
my $self = __PACKAGE__->private( shift );
...
}

sub protectedmethod {
my $self = __PACKAGE__->protected( shift );
...
}

sub classmethod {
my $self = __PACKAGE__->class( shift );
...
}

sub staticmethod {
my $self = __PACKAGE__->static( shift );
...
}

sub restrictedmethod {
my $self = __PACKAGE__->restricted( shift );
...
}

sub abstractmethod { __PACKAGE__->abstract }

1;

...

my $obj = My::Class->new( public_attr => fish );

MOTIVATION

One of Perls greatest strengths is its flexible object model. You can turn anything (so long as its a reference, or you can get a reference to it) into an object. This allows coders to choose the most appropriate implementation for each specific need, and still maintain a consistent object oriented approach.
A common paradigm for implementing objects in Perl is to use a blessed hash reference, where the keys of the hash represent attributes of the class. This approach is simple, relatively quick, and trivial to extend, but its not very secure. Since we return a reference to the hash directly to the user they can alter hash values without using the classs accessor methods. This allows for coding "short-cuts" which at best reduce the maintainability of the code, and at worst may introduce bugs and inconsistencies not anticipated by the original module author.

On some systems, this may not be too much of a problem. If the developer base is small, then we can trust the users of our modules to Do The Right Thing. However, as a modules user base increases, or the complexity of the systems our modules are embedded in grows, it may become desirable to control what users can and cant access in our module to guarantee our codes behaviour. A traditional method of indicating that an objects data and methods are for internal use only is to prefix attribute and method names with underscores. However, this still relies on the end user Doing The Right Thing.

Class::Declare provides mechanisms for module developers to explicitly state where and how their class attributes and methods may be accessed, as well as hiding the underlying data store of the objects to prevent unwanted tampering with the data of the objects and classes. This provides a robust framework for developing Perl modules consistent with more strongly-typed object oriented languages, such as Java and C++, where classes provide public, private, and protected interfaces to object and class data and methods.

<<less
Download (0.075MB)
Added: 2007-06-20 License: Perl Artistic License Price:
856 downloads
databeans 1.0

databeans 1.0


databeans is a fully object oriented (not relational) persistence framework for Java. more>>
databeans is a fully object oriented (not relational) persistence framework for Java, based on the use of the JavaBeans accessor methods to read and write data on disk instead of in the classes instance fields.
Main features:
- based on the use of the javabeans accessor methods to read/write data on disk in place of in the classes instance fields
- distributed (through RMI)
- transactional (with the 4 ANSI isolation levels supported)
- garbage collected (backed by an on-disk heap "heapspace")
- with persistent versions of the Collection classes
Installation:
Extract the archive into any appropriate directory on your hard drive. It will create a "databeans" directory with the following contents:
build.xml
api
[api documentation as generated by javadoc]
bin
databeans_admin
databeans_admin.bat
databeans_export
databeans_export.bat
databeans_import
databeans_import.bat
export.bsh
import.bsh
mkheapspace
mkheapspace.bat
mkheapspace.bsh
docs
getting_started.txt
gpl.txt
lib
databeans_admin.jar
databeans_client.jar
databeans.jar
security
databeans.policy
sample
client
build.xml
Department.java
Employee.java
policy
Sample.java
server
build.xml
DepartmentImpl.java
Department.java
EmployeeImpl.java
Employee.java
policy
src
[java source files]
The most interesting part for now is the file getting_started.txt located in the docs/ directory. It will guide you through running a sample application (which is located in the sample/ directory). That done, go on and read the manual (below) for a complete view of the products features.
<<less
Download (0.64MB)
Added: 2006-07-06 License: GPL (GNU General Public License) Price:
1205 downloads
Class::Generate 1.09

Class::Generate 1.09


Class::Generate is a Perl module that can generate Perl class hierarchies. more>>
Class::Generate is a Perl module that can generate Perl class hierarchies.

SYNOPSIS

use Class::Generate qw(class subclass delete_class);

# Declare class Class_Name, with the following types of members:
class
Class_Name => [
s => $, # scalar
a => @, # array
h => %, # hash
c => Class, # Class
c_a => @Class, # array of Class
c_h => %Class, # hash of Class
&m => body, # method
];

# Allocate an instance of class_name, with members initialized to the
# given values (pass arrays and hashes using references).
$obj = Class_Name->new ( s => scalar,
a => [ values ],
h => { key1 => v1, ... },
c => Class->new,
c_a => [ Class->new, ... ],
c_h => [ key1 => Class->new, ... ] );

# Scalar type accessor:
$obj->s($value); # Assign $value to member s.
$member_value = $obj->s; # Access members value.

# (Class) Array type accessor:
$obj->a([value1, value2, ...]); # Assign whole array to member.
$obj->a(2, $value); # Assign $value to array member 2.
$obj->add_a($value); # Append $value to end of array.
@a = $obj->a; # Access whole array.
$ary_member_value = $obj->a(2); # Access array member 2.
$s = $obj->a_size; # Return size of array.
$value = $obj->last_a; # Return last element of array.

# (Class) Hash type accessor:
$obj->h({ k_1=>v1, ..., k_n=>v_n }) # Assign whole hash to member.
$obj->h($key, $value); # Assign $value to hash member $key.
%hash = $obj->h; # Access whole hash.
$hash_member_value = $obj->h($key); # Access hash member value $key.
$obj->delete_h($key); # Delete slot occupied by $key.
@keys = $obj->h_keys; # Access keys of member h.
@values = $obj->h_values; # Access values of member h.

$another = $obj->copy; # Copy an object.
if ( $obj->equals($another) ) { ... } # Test equality.

subclass s => [ ], -parent => class_name;

The Class::Generate package exports functions that take as arguments a class specification and create from these specifications a Perl 5 class. The specification language allows many object-oriented constructs: typed members, inheritance, private members, required members, default values, object methods, class methods, class variables, and more.

CPAN contains similar packages. Why another? Because object-oriented programming, especially in a dynamic language like Perl, is a complicated endeavor. I wanted a package that would work very hard to catch the errors you (well, I anyway) commonly make. I wanted a package that could help me enforce the contract of object-oriented programming. I also wanted it to get out of my way when I asked.

<<less
Download (0.052MB)
Added: 2007-07-31 License: Perl Artistic License Price:
815 downloads
Class::InsideOut 1.02

Class::InsideOut 1.02


Class::InsideOut is a Perl module with a safe, simple inside-out object construction kit. more>>
Class::InsideOut is a Perl module with a safe, simple inside-out object construction kit.
SYNOPSIS
package My::Class;
use Class::InsideOut qw( public private register id );
public name => my %name; # accessor: name()
private age => my %age; # no accessor
sub new { register( shift ) }
sub greeting {
my $self = shift;
return "Hello, my name is $name{ id $self }";
}
This is a simple, safe and streamlined toolkit for building inside-out objects. Unlike most other inside-out object building modules already on CPAN, this module aims for minimalism and robustness:
- Does not require derived classes to subclass it
- Uses no source filters, attributes or CHECK blocks
- Supports any underlying object type including black-box inheritance
- Does not leak memory on object destruction
- Overloading-safe
- Thread-safe for Perl 5.8 or better
- mod_perl compatible
- Makes no assumption about inheritance or initializer needs
It provides the minimal support necessary for creating safe inside-out objects and generating flexible accessors.
<<less
Download (0.047MB)
Added: 2006-09-27 License: Perl Artistic License Price:
1122 downloads
Class::Agreement 0.02

Class::Agreement 0.02


Class::Agreement is a Perl module that add contracts to your Perl classes easily. more>>
Class::Agreement is a Perl module that add contracts to your Perl classes easily.

SYNOPSIS

package SomeClass;

use Class::Agreement;

# use base Class::Accessor or Class::MethodMaker,
# or roll your own:
sub new { ... }

invariant {
my ($self) = @_;
$self->count > 0;
};

precondition add_a_positive => sub {
my ( $self, $value ) = @_;
return ( $value >= 0 );
};
sub add_a_positive {
my ( $self, $value ) = @_;
...
}

sub choose_word {
my ( $self, $value ) = @_;
...
}
postcondition choose_word => sub {
return ( result >= 0 );
};

dependent increase_foo => sub {
my ( $self, $amount ) = @_;
my $old_foo = $self->foo;
return sub {
my ( $self, $amount ) = @_;
return ( $old_foo < $self->get_foo );
}
};
sub increase_foo {
my ( $self, $amount ) = @_;
$self->set_foo( $self->get_foo + $amount );
}

Class::Agreement is an implementation of behavioral contracts for Perl5. This module allows you to easily add pre- and postconditions to new or existing Perl classes.
This module provides contracts such as dependent contracts, contracts for higher-order functions, and informative messages when things fail.

At the time of this writing, Class::Agreement is one of only two contract implementations that blames contract-breaking components correctly. (See: "Object-oriented Programming Languages Need Well-founded Contracts" at http://citeseer.ist.psu.edu/findler01objectoriented.html.)
Using Class::Agreement lets you specify proper input and output of your functions or methods, thus strengthening your code and allowing you to spot bugs earlier.

<<less
Download (0.027MB)
Added: 2007-02-28 License: Perl Artistic License Price:
968 downloads
Class::DBI::FormBuilder 0.481

Class::DBI::FormBuilder 0.481


Class::DBI::FormBuilder is a Perl module with Class::DBI/CGI::FormBuilder integration. more>>
Class::DBI::FormBuilder is a Perl module with Class::DBI/CGI::FormBuilder integration.

SYNOPSIS

package Film;
use strict;
use warnings;

use base Class::DBI;
use Class::DBI::FormBuilder;

# for indented output:
# use Class::DBI::FormBuilder PrettyPrint => ALL;

# POST all forms to server
Film->form_builder_defaults->{method} = post;

# customise how some fields are built:
# actor is a has_a field, and the
# related table has 1000s of rows, so we dont want the default popup widget,
# we just want to show the current value
Film->form_builder_defaults->{process_fields}->{actor} = VALUE;

# trailer stores an mpeg file, but CDBI::FB cannot automatically detect
# file upload fields, so need to tell it:
Film->form_builder_defaults->{process_fields}->{trailer} = FILE;

# has_a fields will be automatically set to required. Additional fields can be specified:
Film->form_builder_defaults->{required} = qw( foo bar );



# In a nearby piece of code...

my $film = Film->retrieve( $id );
print $film->as_form( params => $q )->render; # or $r if mod_perl

# For a search app:
my $search_form = Film->search_form; # as_form plus a few tweaks


# A fairly complete mini-app:

my $form = Film->as_form( params => $q ); # or $r if mod_perl

if ( $form->submitted and $form->validate )
{
# whatever you need:

my $obj = Film->create_from_form( $form );
my $obj = Film->update_from_form( $form );
my $obj = Film->update_or_create_from_form( $form );
my $obj = Film->retrieve_from_form( $form );

my $iter = Film->search_from_form( $form );
my $iter = Film->search_like_from_form( $form );
my $iter = Film->search_where_from_form( $form );

my $obj = Film->find_or_create_from_form( $form );
my $obj = Film->retrieve_or_create_from_form( $form );

print $form->confirm;
}
else
{
print $form->render;
}

# See CGI::FormBuilder docs and website for lots more information.

Errata: use of column name/accessor/mutator is currently broken if your column accessors/mutators are different from the column name. The documentation is also broken w.r.t. this.

This module creates a CGI::FormBuilder form from a CDBI class or object. If from an object, it populates the form fields with the objects values.

Column metadata and CDBI relationships are analyzed and the fields of the form are modified accordingly. For instance, MySQL enum and set columns are configured as select, radiobutton or checkbox widgets as appropriate, and appropriate widgets are built for has_a, has_many and might_have relationships. Further relationships can be added by subclassing. has_a columns are set as required fields in create/update forms.

<<less
Download (0.045MB)
Added: 2006-10-25 License: Perl Artistic License Price:
1094 downloads
DB_DataContainer 1.3.1

DB_DataContainer 1.3.1


DB_DataContainer is a PEAR compliant database persistence layer and data encapsulation class. more>>
DB_DataContainer is a PEAR compliant database persistence layer and data encapsulation class. A persistence layer can encapsulate the behaviour needed to make objects persistent like for exemple: to load, save and delete objects to and from persistent storage. Currently the only supported persistence mechanisms are relational databases. Database abstraction is provided by PEAR DB.
Data encapsulation is provided by overloaded accessor methods. This means that if you have a property named $foo and you do not write getFoo() and setFoo() methods in the extending class yourself, they will be automatically provided by DB_DataContainer.
As a result of the provided persistence mechanism and data encapsulation DB_DataContainer together with few lines of extra code can be used to implement the Active Record Pattern as described by Martin Fowler:
An object that wraps a row in a database table or view, encapsulates the database access, and adds domain logic on that data.
The class does not use any external configuration files. The extending class itself IS the configuration. All you need to take care about is to have matching propertyname - columname pairs in the class and the database table.
If your database schema changes, for example you add an column foo to the table, all you need to do is to add a property name foo to your class which extends DB_DataContainer. There is no need to rewrite any internal SQL queries.
The class does not provide direct support for JOIN:s or table linking. For extreme cases it is still possible to pass hardcoded SQL queries. This usage is discouraged since it breaks the basic idea of using DB_DataContainer.
Main features:
- Simple API
- Persistence mechanism encapsulation. You only need to call load(), save() or delete(). Note that there are no separate methods for INSERT and UPDATE. save() figures itself out which query to use.
- Overloaded accessor methods for class properties without such methods.
- PEAR DB supported databases as persistence mechanisms (tested with Postgres, MySQL, MSSQL and SQLite).
- Multi-object actions provided by a static getObjects() call.
- Possibility to use hardcoded SQL queries in multi-object actions.
- Regression tests.
- Supports PHP4 and PHP5 (starting from version 1.3.0)
Enhancements:
- This release fixes problems with protected and private data members when using PHP5.
<<less
Download (0.009MB)
Added: 2005-12-22 License: BSD License Price:
1403 downloads
CPAN::WWW::Testers 0.31

CPAN::WWW::Testers 0.31


CPAN::WWW::Testers is present CPAN testers data. more>>
CPAN::WWW::Testers is present CPAN testers data.

SYNOPSIS

my $t = CPAN::WWW::Testers->new();
$t->directory($directory);
$t->generate;

The distribution can present CPAN Testers data. cpan-testers is a group which was initially setup by Graham Barr and Chris Nandor. The objective of the group is to test as many of the distributions on CPAN as possible, on as many platforms as possible. The ultimate goal is to improve the portability of the distributions on CPAN, and provide good feedback to the authors.

CPAN Testers is really a mailing list with a web interface, testers.cpan.org. testers.cpan.org was painfully slow. I happened to be doing metadata stuff for Module::CPANTS. This is the result. Its alpha code, but using it anyone can host their CPAN Testers website.

Unpack the distribution and look at examples/generate.pl. Wait patiently. Send patches and better design.

At the moment I am running the output of this at http://testers.astray.com/

INTERFACE

The Constructor

new
Instatiates the object CPAN::WWW::Testers.

Methods

directory
Accessor to set/get the directory where the webpages are to be created. Note this also where the local copy of testers.db will reside.

generate
Initiates the $obj->download and $obj->write method calls.

download
Downloads the latest article updates from the NNTP server for the cpan-testers newgroup. Articles are then stored in the news.db SQLite database.

database
Path to the SQLite database.

write
Reads the local copy of the testers.db, and creates the alphabetic index, distribution and main index web pages, together with the YAML and RSS pages for each distribution.

<<less
Download (0.011MB)
Added: 2006-12-14 License: Perl Artistic License Price:
1044 downloads
SDL::Color 2.1.3

SDL::Color 2.1.3


SDL::Color is a SDL perl extension. more>>
SDL::Color is a SDL perl extension.

SYNOPSIS

$color = new SDL::Color ( -r => 0xde, -g => 0xad, -b =>c0 );
$color = new SDL::Color -surface => $app, -pixel => $app->pixel($x,$y);
$color = new SDL::Color -color => SDL::NewColor(0xff,0xaa,0xdd);

SDL::Color is a wrapper for display format independent color representations, with the same interface as SDL::Color.

new ( -color => )

SDL::Color::new with a -color option will construct a new object referencing the passed SDL_Color*.

new (-r => , -g => , -b => )

SDL::Color::new with -r,-g,-b options will construct both a SDL_Color structure, and the associated object with the specified vales.

new (-pixel =>, -surface =>)

SDL::Color::new with -pixel,-surface options will generate a SDL_Color* with the r,g,b values associated with the integer value passed by -pixel for the given -surfaces format.

r ( [ red ] ), g( [ green ] ), b( [ blue ] )

SDL::Color::r, SDL::Color::g, SDL::Color::b are accessor methods for the red, green, and blue components respectively. The color value can be set by passing a byte value (0-255) to each function.

pixel ( surface )

SDL::Color::pixel takes a SDL::Surface object and r,g,b values, and returns the integer representation of the closest color for the given surface.

<<less
Download (0.21MB)
Added: 2007-08-09 License: Perl Artistic License Price:
806 downloads
classesfaq 0.943

classesfaq 0.943


classesfaq is a Perl module with frequently asked questions about the Perl classes pragma. more>>
classesfaq is a Perl module with frequently asked questions about the Perl classes pragma.
Main features:
- Compile-time classes, no base class required
- Dynamic classes, alter or create at run-time
- Attributes, class and object, private, read-only, public
- Mixins, methods by name or regx, attributes also
- Single and multiple inheritance
- Accessors, optimized, overridable with read-only
- Accessor dispatch methods set and get
- Method declaration, delegation, ABSTRACT and EMPTY
- Separate new and clone methods, overridable
- Optional initialize method, aggregation
- Utility methods: dump, load, CLASS, SUPER
- Dynamically preserved declaration and mixin tracking
- Simplified exceptions, one line exception classes with inheritance trees
- Base exception class, light, robust, traceable
- 8 reusable exception classes in X:: namespace
- Compatible standard internals, easy porting, no surprises
What is the classes pragma?
A simple, stable, fast, and flexible way to use Perl 5 classes. If you look at no other Perl OO module look at this one, really. If you have done OO in Perl you will find this comfortably familiar. If not you may save yourself time and pain learning the classes pragma first or as you learn Perl OO--many have already.
Why should I use the classes pragma?
- Relevant: fills real-world need for conventional Perl OO
- Lazy: 100+ conventional lines reduced to 1
- Simple: standard readable terms, UML friendly
- Stable: 1000+ unit test points, used reliably in large applications
- Portable: OS independent, single file, 100% pure perl
- Fast: benchmarks faster or equal to the long way
- Light: only standard deps, requires greater than 5.6.1
- Sustainable: tag model, clean, commented
- Open: Perl artistic license, multi-language friendly
- Supported: mailing list, site, documented, actively maintained
If for no other reason because it is a new approach.
<<less
Download (0.12MB)
Added: 2007-06-06 License: Perl Artistic License Price:
870 downloads
Class::Bits 0.05

Class::Bits 0.05


Class::Bits is a Perl module with class wrappers around bit vectors. more>>
Class::Bits is a Perl module with class wrappers around bit vectors.

SYNOPSIS

package MyClass;
use Class::Bits;

make_bits( a => 4, # 0..15
b => 1, # 0..1
c => 1, # 0..1
d => 2, # 0..3
e => s4 # -8..7
f => s1 # -1..0
);

package;

$o=MyClass->new(a=>12, d=>2);
print "o->b is ", $o->b, "n";

print "bit vector is ", unpack("h*", $$o), "n";

$o2=$o->new();
$o3=MyClass->new($string);

ABSTRACT

Class::Bits creates class wrappers around bit vectors.

Class::Bits defines classes using bit vectors as storage.
Object attributes are stored in bit fields inside the bit vector. Bit field sizes have to be powers of 2 (1, 2, 4, 8, 16 or 32).

There is a class constructor subroutine:

make_bits( field1 => size1, field2 => size2, ...)

exports in the calling package a ctor, accessor methods, some utility methods and some constants:

Sizes can be prefixed by s or u to define signedness of the field. Default is unsigned.

$class->new()

creates a new object with all zeros.

$class->new($bitvector)

creates a new object over $bitvector.

$class->new(%fields)

creates a new object and initializes its fields with the values in %fields.

$obj->new()

clones an object.

$obj->$field()
$obj->$field($value)

gets or sets the value of the bit field $field inside the bit vector.

$class->length
$obj->lenght

returns the size in bits of the bit vector used for storage.

$class->keys
$obj->keys

returns an array with the names of the object attributes

$obj->as_hash

returns a flatten hash with the object attributes, i.e.:
my %values=$obj->as_hash;

%INDEX

hash with offsets as used by vec perl operator (to get an offset in bits, the value has to be multiplied by the corresponding bit field size).

%SIZES

hash with bit field sizes in bits.

%SIGNED

hash with signedness of the fields

Bit fields are packed in the bit vector in the order specified as arguments to make_bits.

Bit fields are padded inside the bit vector, i.e. a class created like

make_bits(A=>1, B=>2, C=>1, D=>4, E=>8, F=>16);

will have the layout

AxBBCxxx DDDDxxxx EEEEEEEE xxxxxxxx FFFFFFFF FFFFFFFF

<<less
Download (0.004MB)
Added: 2007-07-30 License: Perl Artistic License Price:
816 downloads
Class::Struct::FIELDS 1.1

Class::Struct::FIELDS 1.1


Class::Struct::FIELDS module combine Class::Struct, base and fields. more>>
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.

<<less
Download (0.018MB)
Added: 2007-07-11 License: Perl Artistic License Price:
835 downloads
Secleted [ 0 ] software to compare
  • Page: 1 of 5
  • 1
  • 2
  • 3
  • 4
  • 5