Data::Sofu::Object - Sofud compatibility layer.
Provides a interface similar to the original SofuD (sofu.sf.net)
require Data::Sofu::Object; my $map = Data::Sofu::Object->new({Text=>"Hello World"}); print ref $map; # Data::Sofu::Map; $map->write(\*STDOUT); # Text = "Hello World" $map->write("file.sofu"); # Text = "Hello World" #You don't need Data::Sofu::Object: use Data::Sofu; $map = loadSofu("file.sofu"); $map->write(\*STDOUT);
This Module is pure OO, exports nothing
Data::Sofu::Object is the base class for Map, Value, List, Reference and Undefined.
Data::Sofu::Object
Map
Value
List
Reference
Undefined
All Methods in here might be overwritten, but work the same way
Converts DATA to appropriate Objects
Note
There is no need to call Data::Sofu::Object without DATA.
Internal Function to create indentation during write()
LEVEL is the amount of indentation requested
Returns Indentation x LEVEL as a string
Allows different indentations to be used (default is "\t")
Returns the current indentation
Clears the Buffer of seen Objects only used during the old Data::Sofu::from() and Data::Sofu::toObjects()
Data::Sofu::from()
Data::Sofu::toObjects()
Returns the Object as a C>Data::Sofu::Value> or throws an error if it can't be converted
Returns the Object as a Data::Sofu::List or throws an error if it can't be converted
Data::Sofu::List
Returns the Object as a Data::Sofu::Map or throws an error if it can't be converted
Data::Sofu::Map
Returns the Object as a Data::Sofu::Reference or throws an error if it can't be converted
Data::Sofu::Reference
Returns a string representation of the Object, used during write(), should not be called alone
LEVEL is the current indentation level.
TREE is the current position in the TREE (used for Reference building)
Returns a binary representation of the Object, used during writeBinary(), should never be called alone.
BINARY DRIVER is a Data::Sofu::Binary instance which is initialized with a Encoding, ByteOrder and Sofumark properties.
Data::Sofu::Binary
Recursivly stores a comment identified by TREE, is used to store a single comment of the hash returned by Data::Sofu::getSofucomments();
Data::Sofu::getSofucomments()
Takes a Hashref (as returned by Data::Sofu::getSofucomments()) and gives every Object its fitting Comment
Data::Sofu::getSofucomments())
COMMENTS is a reference to a Hash
Normally Data::Sofu->new->toObjects($data,$comments) should have done this.
Return 1 if this Object is a Data::Sofu::Value instance, 0 otherwise.
Data::Sofu::Value
Return 1 if this Object is a Data::Sofu::List instance, 0 otherwise.
Return 1 if this Object is a Data::Sofu::Map instance, 0 otherwise.
Returns the current Objects comment as a string (inculding the # sign)
Returns the current comment as an arrayref (One string for each line)
Returns the amount of comment lines.
Sets the comments for this Object.
COMMENT should be a reference to an Array
Appends to the comments for this Object.
Returns 1 if the Object is not an instance of Data::Sofu::Undefined
Data::Sofu::Undefined
Returns 0 if the Object is not an instance of Data::Sofu::Reference
Returns a string representation of the current Object and all Objects it might include
Returns a string of that represents the current Object according the the Binary Sofu specification.
Only works on Data::Sofu::Map's other Objects are getting boxed in a Map
A helper function to detect multiple references and convert them to Sofu References, calls stringify with its arguments
$o->string(-1,"") === $o->pack(); print $map->string(0,"") === $o->write(\*STDOUT);
Returns the Objects Comments packed by a BINARY DRIVER, used by binaryPack() and writeBinary()
Never call this one alone.
A helper function to detect multiple references and convert them to Sofu References, calls stringify with its arguments. Should never be called alone, because the result will miss its header.
Writes the string representation of this Object to a file
File can be:
A filename,
a filehandle or
a reference to a scalar.
Writes the binary representation of this Object to a file
Note: the filehandle will be set to binmode
Uses Data::Sofu::Binary::Bin0200 as driver.
Data::Sofu::Binary::Bin0200
Comment and Binary Modes are not really sofud complient, might change in the future
Data::Sofu, Data::Sofu::Binary, Data::Sofu::Map, Data::Sofu::List, 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.