NAME

Data::Sofu::Binary::Bin0200 - Driver for Sofu Binary version 0.2.0.0

DESCRIPTION

Driver for Data::Sofu::Binary and Data::Sofu

Synopsis

See Data::Sofu::Binary

SYNTAX

This Module is pure OO, exports nothing

METHODS

See also Data::Sofu::Binary for public methods.

All these methods are INTERNAL, not for use outside of this module...

Except pack().

new()

Creates a new Binary Driver using DRIVER or the latest one available.

require Data::Sofu::Binary;
$bsofu = Data::Sofu::Binary->new("000_002_000_000"); Taking this driver;
#You can call it directly:
require Data::Sofu::Binary::Bin0200;
$bsofu = Data::Sofu::Binary::Bin0200->new(); #The same

encoding(ID)

Switches and/or detetect the encoding.

See pack() for more on encodings.

byteorder(BOM)

Internal method.

Switches the byteorder.

See pack() for more on byteorders.

bom(BOM)

Internal method.

Detects the byteorder.

See pack() for more on byteorders.

packShort(INT)

Packs one int-16 to binary using the set byteorder

packLong(INT)

Packs one int-32 to binary using the set byteorder

packendian()

Returns the byte order mark for this file.

packversion()

Returns the version of this driver to put in the file.

packencoding()

Returns the current encoding to put in the output file.

getType()

Tries to find out what SofuObject to deserialise next

Returns:

0 for Undefined / undef

1 for Value / Scalar

2 for List / Array

3 for Map / Hash

4 for Reference / Ref

objectprocess()

Postprocess the SofuObjects, sets References to their targets.

postprocess()

Postprocess perl datastructures , sets References to their targets.

getLong()

Decodes one Int-32 from the input stream according to the byteorder and returns it.

getText()

Decodes one String according to encoding from the inputstream and returns it

getComment(TREE)

decodes one comment and sets it to TREE

TREE can be a string describing the tree or a Data::Sofu::Object.

unpackUndef(TREE)

Returns undef and packs it comment

unpackScalar(TREE)

Decodes one scalar and its comment.

unpackRef(TREE)

Decodes one ref and its comment.

unpackHash(TREE)

Decodes a hash, its comment and its content

unpackArray(TREE)

Decodes an array, its comment and its content

unpackType(TYPE,TREE)

Decodes a datastructure of TYPE.

unpack(BOM)

Starts unpacking using BOM, gets encoding and the contents

unpackUndefined(TREE)

Unpacks a Data::Sofu::Undefined and its comment.

unpackValue(TREE)

Unpacks a Data::Sofu::Value, its content and its comment.

unpackReference(TREE)

Unpacks a Data::Sofu::Reference, its content and its comment.

unpackMap(TREE)

Unpacks a Data::Sofu::Map, its content and its comment.

unpackMap2(TREE)

Unpacks a Data::Sofu::Map, its content and its comment.

(Speed optimized, but uses dirty tricks)

unpackList(TREE)

Unpacks a Data::Sofu::List, its content and its comment.

unpackList2(TREE)

Unpacks a Data::Sofu::List, its content and its comment.

(Speed optimized, but uses dirty tricks)

unpackObjectType(TYPE,TREE)

Unpacks a datastructure defined by TYPE

unpackObject(BOM)

Starts unpacking into a Data::Sofu::Object structure using BOM, gets encoding and the contents

packType(TYPE)

Encodes Type information and returns it.

packText(STRING)

Encodes a STRING using Encoding and returns it.

packData(DATA,TREE)

Encodes one perl datastructure and its contents and returns it.

packArray(DATA,TREE)

Encodes one perl array and its contents and returns it.

packHash(DATA,TREE)

Encodes one perl hash and its contents and returns it.

pack(TREE,[COMMENTS,[ENCODING,[BYTEORDER,[SOFUMARK]]]])

Packs a structure (TREE) into a string using the Sofu binary file format.

Returns a string representing TREE.

TREE

Perl datastructure to pack. Can be a hash, array or scalar (or array of hashes of hashes of arrays or whatever). Anything NOT a hash will be converted to TREE={Value=>TREE};

It can also be a Data::Sofu::Object or derived (Data::Sofu::Map, Data::Sofu::List, Data::Sofu::Value, Data::Sofu::...). Anything not a Data::Sofu::Map will be converted to one (A Map with one attribute called "Value" that holds TREE).

COMMENTS

Comment hash (as returned by Data::Sofu::getSofucomments() or Data::Sofu->new()->comments() after any file was read).

Can be undef or {}.

ENCODING

Specifies the encoding of the strings in the binary sofu file, which can be:

"0" or "UTF-8"

This is default.

Normal UTF-8 encoding (supports almost all chars)

"1" or "UTF-7"

This is default for byteorder = 7Bit (See below)

7Bit encoding (if your transport stream isn't 8-Bit safe

"2" or "UTF-16"

UTF 16 with byte order mark in EVERY string.

Byteoder depends on your machine

"3" or "UTF-16BE"

No BOM, always BigEndian

"4" or "UTF-16LE"

No BOM, always LittleEndian

"5" or "UTF-32"

UTF-32 with byte order mark in EVERY string.

Byteoder depends on your machine

"6" or "UTF-32BE"

No BOM, always BigEndian

"7" or "UTF-32LE"

No BOM, always LittleEndian

"8","9"

Reserved for future use

"10" or "ascii"

Normal ASCII encoding

Might not support all characters and will warn about that.

"11" or "cp1252"

Windows Codepage 1252

Might not support all characters and will warn about that.

"12" or "latin1"

ISO Latin 1

Might not support all characters and will warn about that.

"13" or "latin9"

ISO Latin 9

Might not support all characters and will warn about that.

"14" or "latin10"

ISO Latin 10

Might not support all characters and will warn about that.

BYTEORDER

Defines how the integers of the binary file are encoded.

undef

Maschine order

This is Default.

BOM is placed to detect the order used.

"LE"

Little Endian

BOM is placed to detect the order used.

Use this to give it to machines which are using Little Endian and have to read the file alot

"BE"

Big Endian

BOM is placed to detect the order used.

Use this to give it to machines which are using Big Endian and have to read the file alot

"7Bit"

Use this byteorder if you can't trust your transport stream to be 8-Bit save.

Encoding is forced to be UTF-7. No byte in the file will be > 127.

BOM is set to 00 00.

"NOFORCE7Bit"

Use this byteorder if you can't trust your transport stream to be 8-Bit save but you want another enconding than UTF-7

Encoding is NOT forced to be UTF-7.

BOM is set to 00 00.

SOFUMARK

Defines how often the string "Sofu" is placed in the file (to tell any user with a text-editor what type of file this one is).

undef

Only place one "Sofu" at the beginning of the file.

This is default.

"0" or ""

Place no string anywhere.

"1" or >1

Place a string on every place it is possible

Warning, the file might get big.

"0.000001" - "0.99999"

Place strings randomly.

NOTE:

Encoding, Byteorder and encoding driver (and Sofumark of course) are saved in the binary file. So you don't need to specify them for reading files, in fact just give them the Data::Sofu's readSofu() and all will be fine.

packObject(TREE,[COMMENTS,[ENCODING,[BYTEORDER,[SOFUMARK]]]])

Same as pack() but for Data::Sofu::Object's only

Will be called by pack().

Comments are taken from COMMENTS and from the Objects itself.

packObjectData(DATA,TREE)

Encodes one Data::Sofu::Object and its contents and returns it.

packList(DATA,TREE)

Encodes one Data::Sofu::List and its contents and returns it.

packMap(DATA,TREE)

Encodes one Data::Sofu::Map and its contents and returns it.

packComment(TREE,ADD)

Packs the comment for (TREE) + ADD and returns it.

packHeader([ENCODING,[BYTEORDER,[SOFUMARK]]])

Packs the header of the file and sets encoding and byteorder

BUGS

n/c

SEE ALSO

perl(1),http://sofu.sf.net

Data::Sofu::Object, Data::Sofu, Data::Sofu::Binary::*