libsswf: sswf Namespace Reference

# sswf Namespace Reference

The C++ SSWF library namespace. More...

## Classes
class | Action
| Holds an action. More...
class | ActionBranch
| An action to change the execution pointer. More...
class | ActionCallFrame
| Change the SWF pointer to the specified frame. More...
class | ActionDictionary
| Create a dictionary action. More...
class | ActionFunction
| The action to hold an ActionScript function. More...
class | ActionGoto
| A goto action to change the current frame. More...
class | ActionLabel
| Create a label in an action script. More...
class | ActionPushData
| The PushData action adds data on the ActionScript stack. More...
class | ActionSetTarget
| This class is used to define the sprite on which the actions apply. More...
class | ActionStoreRegister
| Store the top stack value in a register. More...
class | ActionStrictMode
| This action is used to define the current scripting mode. More...
class | ActionTry
| This action encompasses the Try, Catch and Finally actions. More...
class | ActionURL
| Go to a static or dynamic URL. More...
class | ActionWaitForFrame
| Create an action used to wait for a frame to be loaded. More...
class | ActionWith
| Block including variable member names refering to the With object. More...
class | BlendMode
| The mode used to render the object on the screen. More...
class | Buffer
| Linked list of memory buffers for easy memory management. More...
class | Color
| A small object to hold an SWF color. More...
class | ColorTransform
| The simple color transform of a TagPlace tag. More...
class | Data
| Buffer object used to save the SWF movie. More...
class | Edges
| List of coordinates to draw shapes. More...
class | Envelope
| An array of volumes for a sound effect. More...
class | ErrorManager
| This class helps the user to know what errors occur in the library. More...
class | Event
| The Event class used to declare the events a button or place object support. More...
class | ItemBase
| This class is used to derive from. More...
class | Matrix
| The position matrix. More...
class | MemBuffer
| A type of smart pointer used to manage memory buffers. More...
class | MemoryManager
| A garbage collector manager. More...
class | SoundInfo
| Information about out to playback a sound effect. More...
class | SRectangle
| The SWF rectangle. More...
class | State
| The state a button will react to. More...
class | Style
| Defines the style of a shape. More...
class | TagBase
| The base of all the tags. More...
class | TagBaseID
| The base of all the tags with an ID. More...
class | TagBinaryData
| Binary data reusable by the ActionScripts. More...
class | TagButton
| Create an active area. More...
class | TagCSMTextSettings
| Defines extraneous settings for text tags. More...
class | TagDoAction
| This tag hold an ActionScript. More...
class | TagEditText
| Defines a dynamic edit text box. More...
class | TagEnd
| Mark the end of a list of tags. More...
class | TagExport
| The object used to export objects to another movie. More...
class | TagFont
| Define a system or embedded font. More...
class | TagFrameLabel
| Defines a label (name) for a frame. More...
class | TagHeader
| The header or root of the SWF movie. More...
class | TagImage
| The image class in SWF. More...
class | TagImport
| Import a set of object defined in another movie. More...
class | TagInfo
| An attempt in creating a TagInfo. More...
class | TagMetadata
| The description of the SWF animation in humain language. More...
class | TagPlace
| Tag used to place (or remove) an object in the display list. More...
class | TagProductInfo
| Information about the software creating the output animation. More...
class | TagProtect
| Mark the movie as protected. More...
class | TagRemove
| Remove an object from the display list. More...
class | TagScalingGrid
| Defines a grid to scale windows, buttons and other objects with edges. More...
class | TagSceneFrameData
| Raw data for your scene and frame. More...
class | TagScriptLimits
| Defines the limits to the script interpreter. More...
class | TagSetBackgroundColor
| Set the background color of the movie. More...
class | TagSetTabIndex
| Set the tab key index for objects. More...
class | TagShape
| Defines an SWF shape. More...
class | TagShowFrame
| Tag marking the limit between each frame. More...
class | TagSound
| Declare a sound. More...
class | TagSprite
| Group shapes, sprites, texts, buttons, sound, etc. More...
class | TagStartSound
| Class used to start/stop a sound. More...
class | TagText
| Enter a label (text string) in an SWF file. More...
class | Vectors
| Manages an array of pointers to other objects. More...
## Typedefs
typedef unsigned short | sswf_frame_t
| Used to represent a frame number.
typedef unsigned short | sswf_id_t
| Type defining the identifier of an SWF object.
typedef int32_t | sswf_ucs4_t
| A type to support UCS-4 characters.
## Functions
void | assert (int cond, const char *format,...) __attribute__((format(printf
| Stop the processing with a message about the test.
int | mbtowc (const char *mb, size_t mb_len, sswf_ucs4_t *&wc, size_t &wc_len)
| Transform a multi-byte string in a wide character string.
const char * | sswf_version (void)
| Return the version of the SSWF library.
void | swap (void *s1, void *s2, size_t size)
| Swap the content of two buffers.
unsigned int | swap_int (unsigned int l)
| Swap the bytes of a 32 bits integer.
unsigned short | swap_short (unsigned short s)
| Swap the bytes of a 16 bits integer.
char * | wcname (sswf_ucs4_t wc, char *result)
| Transform a wide character in a display name.
long | wcslen (sswf_ucs4_t *wcstr)
| Compute the length of a wide character string.
int | wctomb (const sswf_ucs4_t *wc, size_t wc_len, char *mb, size_t &mb_len)
| Convert a wide character string to a multi-byte string.

## Detailed Description

The SSWF library is fully defined with the 'sswf' namespace.

Do 'using namespace sswf;' to "get rid of it".

The SSWF library is a full set of classes and functions used to create SWF binary files. The library supports most of the tags available in SWF and is used to compress them in the appropriate format for use by a Flash player.

One important point about this library: it hides from you, the user, the lower layers of the SWF tags. For one thing, you will never have to worry about how to compress the data in a valid SWF tag. But not only that, the library takes care of selecting the appropriate tag depending on the output movie version and what each tag support.

For instance, when you create a TagFont, the library hides from you the fact that it supports 3 different types of DefineFont tags (and once version 8 is supported, it will hide the DefineFontAlignZones). This means you don't need to know all the details of how to create a font. Such details are important for the library, but not to you.

None the less, it is complicated to create a valid SWF shape and the library does not do that automatically for you. For more information about each specific tag, please read the corresponding documentation.

## Typedef Documentation

unsigned short sswf::sswf_frame_t

This typedef is used anywhere a frame needs to be defined by number. The very first frame in a movie is frame 0. The very last frame is to the total number of frames minus one.

Note that there are frames within a sswf::TagSprite. Similarly, the very first frame starts at 0 and the last is the number of frames in that sprite minus one.

See also:
  sswf::TagHeader

  sswf::TagSprite

  sswf::ActionCallFrame

unsigned short sswf::sswf_id_t

Definitions in an SWF animation are given an identifier which can later be used to reference the definition. For instance, you create a sswf::TagSprite, assign it identifier 5, and later you display the sswf::TagSprite using a sswf::TagPlace and referencing the sswf::TagSprite number 5.

See also:
  class sswf::TagBaseID

  class sswf::TagSprite

  class sswf::TagPlace

int32_t sswf::sswf_ucs4_t

This type is used to represent UCS-4 strings. The wchar_t cannot be used since on some systems it is only 16 bits (and can therefore only represent UCS-2 or UTF-16).

The SSWF library supports functions to convert strings from UCS-4 to UTF-8 and vice versa.

See also:
  int sswf::wctomb(const sswf_ucs4_t *wc, size_t wc_len, char *mb, size_t& mb_size)

  int sswf::mbtowc(const char *mb, size_t mb_len, sswf_ucs4_t *& wc, size_t& wc_len)

  char *sswfwcname(sswf_ucs4_t wc, char *result)

  long sswf::wcslen(sswf_ucs4_t *wcstr)

  typedef unsigned int wint_t;

## Function Documentation

void sswf::assert | ( | int | cond,
|  | const char * | format,
|  |  | ... |
| ) |  |  | `[inline]`

This function is used to assert() when 'cond' is true.

The function prints out the message defined by format and optional parameters (as in a printf(3) call) and then it exists the process with a call to abort(3).

The function only works in debug mode. In release mode (or non-debug at least) it is transformed into a do nothing inline function.

Parameters:

  | cond | A true (i.e. do nothing) or false (abort the process) condition
  | format | A format string as in a printf(3)
  | ... | Optional parameter to the format string message

Referenced by sswf::Action::Action(), sswf::ActionBranch::ActionBranch(), sswf::ActionFunction::ActionFunction(), sswf::ActionGoto::ActionGoto(), sswf::ActionURL::ActionURL(), sswf::ActionWaitForFrame::ActionWaitForFrame(), sswf::ActionFunction::AddParameter(), sswf::MemBuffer::AttachBuffer(), sswf::TagShape::Bounds(), sswf::Buffer::Buffer(), sswf::TagText::DefineText(), sswf::ActionPushData::Duplicate(), sswf::Buffer::FindBuffer(), sswf::TagBase::FindID(), sswf::Vectors::Get(), sswf::Data::GetBits(), sswf::Data::GetByte(), sswf::ActionPushData::GetMaxRegister(), sswf::MemoryManager::MemClean(), sswf::TagHeader::MinimumVersion(), sswf::Data::Overwrite(), sswf::Data::OverwriteByte(), sswf::Data::OverwriteLong(), sswf::Data::OverwriteShort(), sswf::ActionGoto::ParseData(), sswf::Action::ParseData(), sswf::TagFont::PreSave2ndPass(), sswf::Data::ReadAlign(), sswf::Data::ReadBytes(), sswf::Buffer::Realloc(), sswf::TagSound::Resample(), sswf::TagText::Save(), sswf::TagSound::Save(), sswf::TagShape::Save(), sswf::TagRemove::Save(), sswf::TagImage::Save(), sswf::Style::Save(), sswf::ActionTry::SaveData(), sswf::ActionPushData::SaveData(), sswf::ActionGoto::SaveData(), sswf::Action::SaveData(), sswf::TagHeader::SaveEncodedString(), sswf::TagBaseID::SaveID(), sswf::Edges::Set(), sswf::TagSound::SetData(), sswf::TagProtect::SetPassword(), sswf::Data::SetReadPosition(), sswf::Data::SetSize(), sswf::Style::SetType(), sswfWriteData(), sswf::Event::StringToEvents(), swap(), sswf::TagBaseID::TagBaseID(), sswf::TagDoAction::TagDoAction(), sswf::TagPlace::TagPlace(), sswf::TagText::text_entry_t::text_entry_t(), sswf::Data::WriteBits(), sswf::Buffer::~Buffer(), and sswf::TagBase::~TagBase().

int sswf::mbtowc | ( | const char * | mb,
|  | size_t | mb_len,
|  | sswf_ucs4_t *& | wc,
|  | size_t & | wc_len |
| ) |  |  |

This function transforms a UTF-8 string in a UCS-4 string.

The function moves the 'wc' pointer to the end of the string and decrements the 'wc_len' parameter for each character added to the output string.

Parameters:

  | mb | The UTF-8 string to convert to UCS-4
  | mb_len | The length of the UTF-8 string
  | wc | A reference to a pointer to save the result
  | wc_len | A reference to the size of the wc buffer

Returns:
  Zero when no error occurs, EINVAL when an invalid input character is found (i.e. 0xFE or 0xFF) or ENOMEM when the output buffer is full before the convertion ends

See also:
  int sswf::wctomb(const sswf_ucs4_t *wc, size_t wc_len, char *mb, size_t& mb_len)

  long sswf::wcslen(sswf_ucs4_t *wcstr)

Referenced by sswf::TagText::AddText(), sswf::TagEditText::AddUsedString(), sswf::TagEditText::PreSave(), sswf::TagFont::SetUsedGlyphs(), and sswf::TagEditText::SetUsedGlyphs().

const char * sswf::sswf_version | ( | void |  | ) |

This function returns SSWF_VERSION as a string. (i.e. something like 1.7.5)

This string is a constant and cannot be written to.

Returns:
  The SSWF version string

References SSWF_VERSION, and TO_STR.

void sswf::swap | ( | void * | s1,
|  | void * | s2,
|  | size_t | size |
| ) |  |  |

The swap() function swaps the content of buffer s1 with buffer s2. 'size' bytes are swapped.

If you have a 64 bits system, s1 and s2 both point to a 64 bit value and the size is a multiple of 8 bytes, then the swap is done 64 bits at a time.

If s1 and s2 both point to a 32 bit value and the size is a multiple of 4 bytes, then the swap is done 32 bits at a time.

Otherwise the 8 bits (1 byte) at a time function is used.

Note:
  Modifications to support 64-bit by Fabio A. Correa <facorread at gmail>

Parameters:

  | s1 | One of the buffers to swap
  | s2 | One of the buffers to swap
  | size | The number of bytes to swap

See also:
  unsigned short sswf::swap_short(unsigned short s)

  unsigned int sswf::swap_int(unsigned int l)

References assert().

Referenced by sswf::TagImage::LoadTGA().

unsigned int sswf::swap_int | ( | unsigned int | l | ) | `[inline]`

This function takes a 32 bits integer as input and swaps each byte. In effect, it transforms the 32 bits integer from a little to a big endian or vice versa.

Calling the function again with the result value cancels the swapping effect.

Parameters:

  | l | The 32 bits integer to swap

Returns:
  The swapped 32 bits integer passed as input

See also:
  unsigned short sswf::swap_short(unsigned short s)

  void sswf::swap(void *s1, void *s2, size_t size)

Referenced by sswf::TagSound::LoadWaveFile(), and sswf::TagFont::PreSave2ndPass().

unsigned short sswf::swap_short | ( | unsigned short | s | ) | `[inline]`

This function takes a 16 bits integer as input and swaps each byte. In effect, it transforms the 16 bits integer from a little to a big endian or vice versa.

Calling the function again with the result cancels the swapping effect.

Parameters:

  | s | The 16 bits integer to swap

Returns:
  The swapped 16 bits integer passed as input

See also:
  unsigned int sswf::swap_int(unsigned int l)

  void sswf::swap(void *s1, void *s2, size_t size)

Referenced by sswf::TagSound::LoadWaveFile(), and sswf::TagFont::PreSave2ndPass().

char * sswf::wcname | ( | sswf_ucs4_t | wc,
|  | char * | result |
| ) |  |  |

This function transforms the given wide character in a string with a name one can display in a console or UI output.

A character between ' ' and 0x7E (127) are displayed as their ASCII character. Any other character is displayed as 'U+<number>'

Bug:
  This function takes a string where the result is saved without any safeguards (i.e. it uses sprintf() on that buffer).

Parameters:

  | wc | The character to transform
  | result | A pointer to a string to fill with the result (output)

Returns:
  The function returns 'result'.

See also:
  typedef int32_t sswf_ucs4_t

Referenced by sswf::TagText::DefineText(), sswf::TagEditText::PreSave(), and sswf::TagFont::SetUsedGlyphs().

long sswf::wcslen | ( | sswf_ucs4_t * | wcstr | ) |

This function computes the length, in character, of a wide character string (i.e. UCS-4 characters.)

The length does not include the null terminator.

Parameters:

  | wcstr | The string to size or NULL

Returns:
  The number of character in the string

See also:
  int sswf::mbtowc(const char *mb, size_t mb_len, sswf_ucs4_t *& wc, size_t& wc_len)

  int sswf::wctomb(const sswf_ucs4_t *wc, size_t wc_len, char *mb, size_t& mb_len)

Referenced by sswf::TagEditText::AddUsedString(), and sswf::TagText::text_entry_t::text_entry_t().

int sswf::wctomb | ( | const sswf_ucs4_t * | wc,
|  | size_t | wc_len,
|  | char * | mb,
|  | size_t & | mb_len |
| ) |  |  |

This function converts a UCS-4 string to a UTF-8 string.

Since version 6 of SWF, all strings in an SWF animations are assumed to be encoding using UTF-8.

The length of the output can be infered using 'mb_len' which is decremented by the number of bytes saved in 'mb'.

Parameters:

  | wc | A pointer to a wide character string (input)
  | wc_len | The number of characters to convert
  | mb | A pointer to the output string (output)
  | mb_len | A reference to a size_t value with the maximum number of bytes to write in this output buffer (in/out)

Returns:
  Zero when the function succeeds, EINVAL when an input wide character is erroneous (i.e. negative) and ENOMEM when the output buffer is full

See also:
  int sswf::mbtowc(const char *mb, size_t mb_len, sswf_ucs4_t *& wc, size_t& wc_len)

  long sswf::wcslen(sswf_ucs4_t *wcstr)