Data::Sofu::Reference - A Sofu Reference
Provides a interface similar to the original SofuD (sofu.sf.net).
References present a transparent interface to the object referenced. Normally they shouldn't even bother you one bit.
require Data::Sofu::Map; require Data::Sofu::Reference; my $map = Data::Sofu::Map->new(); $map->setAttribute("myself",Data::Sofu::Reference->new($map)); #Reference to itself. $map->map("myself"); #Will return $map not the Reference. $map->object("myself")->asReference(); #Will return the Reference. $map->object("myself")->asMap(); #will return the Map. $map->object("myself")->isMap(); #True $map->map("myself")->isMap(); #Also true $map->object("myself")->isReference(); #True $map->map("myself")->isReference(); #false (you skipped the reference when using map()); #You can also: my $map = Data::Sofu::Map->new(); $map->setAttribute("myself",$map); #Will be converted to Reference as soon as it is written to a file or string.
This Module is pure OO, exports nothing
Also look at Data::Sofu::Object for methods, cause Reference inherits from it
Data::Sofu::Object
Data::Sofu::Reference
$ref = Data::Sofu::Reference->new("->myself"); #Tree form, not valid (just for saving data) my $map = Data::Sofu::Map->new(); $ref = Data::Sofu::Reference->new($map); #Valid
Changes the target of the Reference to Data
Return 1 if the Reference is there and points to something that is a Data::Sofu::Object
Returns 1
Returns the referenced object, valid or not.
Returns the referenced objects asValue() call.
Which Returns either the referenced object or throws an exception
Returns the referenced objects asMap() call.
Returns the referenced objects asList() call.
Returns 1 if the Reference is valid and the referenced Object is a List.
Returns 1 if the Reference is valid and the referenced Object is a Value.
Returns 1 if the Reference is valid and the referenced Object is a Map.
Returns 1 if the Reference is valid and the referenced Object is defined (i.e. not a Data::Sofu::Undefined).
Data::Sofu::Undefined
Returns itself
Referencing something else than a Data::Sofu::Object or derieved will not convert the referenced thing and it will confuse the write() to produce invalid sofu files.
Data::Sofu, Data::Sofu::Value, Data::Sofu::Object, Data::Sofu::Map, Data::Sofu::Value, Data::Sofu::Undefined, http://sofu.sf.net
To install Data::Sofu, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Sofu
CPAN shell
perl -MCPAN -e shell install Data::Sofu
For more information on module installation, please visit the detailed CPAN module installation guide.