libsswf: sswf::TagBinaryData Class Reference

# sswf::TagBinaryData Class Reference

Binary data reusable by the ActionScripts. More...

`#include <libsswf.h>`

Inheritance diagram for sswf::TagBinaryData:

List of all members.

## Public Member Functions
void | GetData (const char *&data, size_t &size) const
| Retrieve the current data.
virtual ErrorManager::error_code_t | Save (Data &data)
| Save the binary data tag in the Data buffer.
void | SetData (const char *data, size_t size)
| Save the specified data in the tag.
| TagBinaryData (TagBase *parent)
| Initializes the TagBinaryData.
virtual swf_type_t | TypeFlags (void) const
| The type of this tag.
virtual | ~TagBinaryData ()
| Cleanup the TagBinaryData.
## Private Member Functions
virtual ErrorManager::error_code_t | ParseTag (swf_tag_t tag, const Data &data)
| Parse data from a file into a BinaryData tag.
virtual ErrorManager::error_code_t | PreSave (void)
| This tag appeared in version 9 of SWF.
## Private Attributes
char * | f_data
size_t | f_size

## Detailed Description

This tag supports any type of binary data that the ActionScripts may need at some point.

The data is identifier with an ID like other objects, for later reference.

See also:
  SWF Alexis' Reference—Binary Data

  SWF Alexis' Reference—swf_tag

## Constructor & Destructor Documentation

TagBinaryData::TagBinaryData | ( | TagBase * | parent | ) |

By default, the TagBinaryData is empty.

Parameters:

  `[in]` | parent | a TagHeader tag

References f_data, and f_size.

TagBinaryData::~TagBinaryData | ( |  | ) | `[virtual]`

This function cleans up the Binary Data tag objects.

## Member Function Documentation

void TagBinaryData::GetData | ( | const char *& | data,
|  | size_t & | size |
| ) |  |  | const

This function retreives a direct reference pointer to the internal buffer of the Binary Data tag and its size.

Warning:
  If the size is zero, the pointer will be NULL. This is a valid case that you must be prepared to manage.

Parameters:

  `[out]` | data | A reference to a pointer where the tag buffer pointer is saved
  `[out]` | size | A reference to a size_t variable to receive the size

Bug:
  Do NOT free the memory buffer returned to you. The TagBinaryData is responsible for that task. If you want to free the buffer, call the SetData() function with a size of zero and any data pointer.

Bug:
  Also, do NOT use the pointer and size returned by this function after calling the SetData() function since the buffer is likely to move.

See also:
  void sswf::TagBinaryData::SetData(const char *data, size_t size)

References f_data, and f_size.

ErrorManager::error_code_t TagBinaryData::ParseTag | ( | swf_tag_t | tag,
|  | const Data & | data |
| ) |  |  | `[private, virtual]`

This function reads the data associated with this binary data object.

Parameters:

  `[in]` | tag | The tag that generated this call
  `[in]` | data | The Data buffer from the Flash file being loaded

Returns:
  An error if one occurs, or ErrorManager::ERROR_CODE_NONE

Implements sswf::TagBase.

References sswf::Data::ByteSize(), sswf::ErrorManager::ERROR_CODE_NONE, f_data, f_size, sswf::Data::GetLong(), sswf::MemoryManager::MemRealloc(), sswf::TagBaseID::ParseID(), and sswf::Data::ReadBytes().

ErrorManager::error_code_t TagBinaryData::PreSave | ( | void |  | ) | `[private, virtual]`

Tells the TagHeader that a version 9+ movie is required.

Returns:
  ErrorManager::ERROR_CODE_NONE or some other ErrorManager error

Reimplemented from sswf::TagBase.

References sswf::ErrorManager::ERROR_CODE_NONE, and sswf::TagBase::MinimumVersion().

ErrorManager::error_code_t TagBinaryData::Save | ( | Data & | data | ) | `[virtual]`

This function saves the Binary Data tag in the specified Data buffer. The tag must have an identifier for later reference.

Parameters:

  `[in,out]` | data | The Data buffer where the result is saved

Returns:
  And sswf::ErrorManager error (ErrorManager::ERROR_CODE_NONE when no errors)

Implements sswf::TagBase.

References sswf::ErrorManager::ERROR_CODE_NONE, f_data, f_size, sswf::Data::PutLong(), sswf::TagBaseID::SaveID(), sswf::TagBase::SaveTag(), sswf::TagBase::SWF_TAG_DEFINE_BINARY_DATA, and sswf::Data::Write().

void TagBinaryData::SetData | ( | const char * | data,
|  | size_t | size |
| ) |  |  |

This function makes a copy of the specified data in this tag. Later, it is saved in the SWF animation with the Save() function.

A size of zero is valid.

Parameters:

  `[in]` | data | A valid pointer to the data to save in the tag
  `[in]` | size | The number of bytes of data to save in the tag

See also:
  void sswf::TagBinaryData::GetData(const char *& data, size_t& size)

References f_data, f_size, sswf::MemoryManager::MemAlloc(), and sswf::MemoryManager::MemFree().

TagBase::swf_type_t TagBinaryData::TypeFlags | ( | void |  | ) | const`[virtual]`

The TagProductInfo is a DEFINE type.

Returns:
  SWF_TYPE_DEFINE

See also:
  TagBase::swf_type_t sswf::TagBase::TypeFlags(void) const

Implements sswf::TagBase.

References SWF_TYPE_DEFINE.

## Member Data Documentation

char* sswf::TagBinaryData::f_data`[private]`

Referenced by GetData(), ParseTag(), Save(), SetData(), and TagBinaryData().

size_t sswf::TagBinaryData::f_size`[private]`

Referenced by GetData(), ParseTag(), Save(), SetData(), and TagBinaryData().

The documentation for this class was generated from the following files:

- libsswf.h
- libsswf_tag_binarydata.c++