Haiku API Bindings
Flattenable
Not logged in

Documentation | SupportKit | Flattenable

SYNOPSIS

Perl

use HaikuR1::Flattenable;

# define MyFlattenable subclass here

my $flattenable = MyFlattenable->new();
my $flattened = $flattenable->Flatten();

my $unflattened = MyFlattenable->new();
$unflattened->Unflatten($flattened);

Python

from HaikuR1.SupportKit import Flattenable

# define MyFlattenable subclass here

flattenable = MyFlattenable()
flattened = flattenable.Flatten()

unflattened = MyFlattenable()
unflattened.Unflatten(flattened)

DESCRIPTION

Exposes the BFlattenable object.

For more information on Flattenable, see the Be Book class description, the Be Book overview, and the Haiku Book class description.

METHODS

Constructor

Creates a Flattenable.

Perl

HaikuR1::Flattenable->new();

Python

Flattenable()

AllowsTypeCode

Returns true if this class can flatten or unflatten the given type; false otherwise. The default version checks the given type against the type returned by TypeCode.

Perl

$flattenable->AllowsTypeCode($code);

Python

flattenable.AllowsTypeCode(code)

Flatten

Flattens the object and returns a string of bytes. Flattenable does not provide a default version, so subclasses must provide this method. Returns the flattened data or signal an error.

The returned string may contain null bytes.

Perl

$flattenable->Flatten();

Python

flattenable.Flatten()

FlattenedSize

Returns the size of the flattened object. Flattenable does not provide a default version, so subclasses must provide this method. Return the size or signal an error.

Perl

$flattenable->FlattenedSize();

Python

flattenable.FlattenedSize()

IsFixedSize

Returns true if instances of the class always flatten to the same size, false if the size is variable. Flattenable does not provide a default version, so subclasses must provide this method.

Perl

$flattenable->IsFixedSize();

Python

flattenable.IsFixedSize()

TypeCode

Returns a 32-bit integer that is the type for this object. (See TypeConstants.) Flattenable does not provide a default version, so subclasses must provide this method.

Perl

$flattenable->TypeCode();

Python

flattenable.TypeCode()

Unflatten

Unflattens the object from the given string of bytes. Flattenable does not provide a default version, so subclasses must provide this method. If your subclass does not handle this type, or if you are unable to unflatten the data, you should signal an error, such as B_BAD_TYPE or B_BAD_DATA, or simply B_ERROR.

Perl

$flattenable->Unflatten($code, $buffer);

Python

flattenable.Unflatten(code, buffer)

HOOKS

All methods may also be called as hooks; for example, when passing an instance of a subclass to Message.AddFlat, Message.FindFlat, or Message.ReplaceFlat.