Made to Order Software Corporation Logo

libsswf: sswf::Vectors Class Reference

Manages an array of pointers to other objects. More...

#include <libsswf.h>

Inheritance diagram for sswf::Vectors:

:MemoryManager :MemBuffer

List of all members.


Public Member Functions

int Count (void) const
 Return the size of the vectors.
void Empty (void)
 Make the vectors empty.
ItemBaseGet (int index) const
 Get an item out of the vectors.
void Insert (int index, ItemBase *vector)
 Insert the specified item at the specified index.
Vectorsoperator= (const Vectors &vectors)
 Copy a vector in another.
void Set (int index, ItemBase *vector)
 Replace an item in a vector.
void SetSize (int size)
 Change the size of the vectors.
 Vectors (const Vectors &vector)
 Copy a vector in another.
 Vectors (void)
 Initialize an empty vector.
 ~Vectors ()
 The destructor ensures that the vectors is empty.

Private Attributes

int f_count
int f_max
ItemBase ** f_vectors

Detailed Description

This class is similar to the std::vector class from the STL.

Constructor & Destructor Documentation

Vectors::Vectors ( void   ) 

This function initializes the corresponding vector to an empty vector.

References f_count, f_max, and f_vectors.

Vectors::Vectors ( const Vectors vectors  ) 

This function is the copy operator which copies the specified vector in this vector.

Parameters:
[in] vectors The vector to be copied

References f_count, f_max, f_vectors, and SetSize().

Vectors::~Vectors (  ) 

This function reset the size of the vectors to zero. This means anything still allocated by this vector is removed.

Bug:
This function does not clean up what is pointed to by this vector. It only clears the vector itself.

References SetSize().


Member Function Documentation

sswf::Vectors::Count ( void   )  const [inline]

This function returns the current size of the vectors.

All the items defined in the vectors can be retrieved using the Get() function. These items have index starting at zero and ending at Count() - 1. If Count() is zero, then one cannot call the Get() function since the vectors is empty.

See also:
sswf::Vectors::SetSize()

References f_count.

Referenced by sswf::TagShape::AddEdge(), sswf::SoundInfo::AddEnvelope(), sswf::TagShape::AddStyle(), sswf::TagText::AddText(), sswf::TagText::DefineText(), sswf::ActionWith::Duplicate(), sswf::ActionWaitForFrame::Duplicate(), sswf::ActionTry::Duplicate(), sswf::ActionPushData::Duplicate(), sswf::ActionFunction::Duplicate(), sswf::ActionDictionary::Duplicate(), sswf::TagFont::FindGlyph(), sswf::Action::FindLabel(), sswf::Action::FindLabelAtOffset(), sswf::Action::GetMaximumRegister(), sswf::ActionPushData::GetMaxRegister(), sswf::TagFont::GlyphInfo(), sswf::TagFont::HasGlyph(), sswf::TagImport::HasID(), sswf::TagImport::HasName(), sswf::TagShape::IsEmpty(), sswf::Action::MinimumListVersion(), sswf::TagFont::ParseTag(), sswf::TagText::PreSave(), sswf::TagPlace::PreSave(), sswf::TagFont::PreSave(), sswf::TagExport::PreSave(), sswf::TagButton::PreSave(), sswf::TagFont::PreSave2ndPass(), sswf::TagText::RecordSetup(), sswf::Event::Reset(), sswf::TagText::Save(), sswf::SoundInfo::Save(), sswf::TagShape::Save(), sswf::TagPlace::Save(), sswf::TagImport::Save(), sswf::TagFont::Save(), sswf::TagExport::Save(), sswf::TagDoAction::Save(), sswf::TagButton::Save(), sswf::Edges::Save(), sswf::ActionWaitForFrame::SaveData(), sswf::ActionPushData::SaveData(), sswf::ActionFunction::SaveData(), sswf::ActionDictionary::SaveData(), sswf::Action::SaveList(), sswf::TagShape::SaveShape(), sswf::TagShape::SaveStyles(), sswf::TagShape::SaveWithoutStyles(), sswf::Edges::Set(), and sswf::TagFont::SetUsedGlyphs().

sswf::Vectors::Empty ( void   )  [inline]

This function marks the vectors as empty.

The vectors buffer is kept so it can be reused avoiding allocating and deallocating it for no reason.

In order for the vectors to lose their buffer, call SetSize() with zero as the size.

See also:
sswf::Vectors::SetSize()

References f_count.

Referenced by sswf::TagShape::NewStyles(), and sswf::Event::Reset().

ItemBase * Vectors::Get ( int  index  )  const

This function is used to read one item out of the vectors.

In debug mode, the function asserts if the index is out of range (i.e. negative or larger or equal to the number if items available.)

Parameters:
[in] index 
Returns:
The item at the specified index.

References sswf::assert(), f_count, and f_vectors.

Referenced by sswf::SoundInfo::AddEnvelope(), sswf::TagShape::AddStyle(), sswf::TagText::DefineText(), sswf::ActionWith::Duplicate(), sswf::ActionWaitForFrame::Duplicate(), sswf::ActionTry::Duplicate(), sswf::ActionPushData::Duplicate(), sswf::ActionFunction::Duplicate(), sswf::ActionDictionary::Duplicate(), sswf::TagFont::FindGlyph(), sswf::Action::FindLabel(), sswf::Action::FindLabelAtOffset(), sswf::Action::GetMaximumRegister(), sswf::ActionPushData::GetMaxRegister(), sswf::TagFont::GlyphInfo(), sswf::TagImport::HasID(), sswf::TagImport::HasName(), sswf::Action::MinimumListVersion(), sswf::TagFont::ParseTag(), sswf::TagText::PreSave(), sswf::TagPlace::PreSave(), sswf::TagFont::PreSave(), sswf::TagExport::PreSave(), sswf::TagButton::PreSave(), sswf::TagFont::PreSave2ndPass(), sswf::Event::Reset(), sswf::TagText::Save(), sswf::SoundInfo::Save(), sswf::TagShape::Save(), sswf::TagPlace::Save(), sswf::TagImport::Save(), sswf::TagFont::Save(), sswf::TagExport::Save(), sswf::TagDoAction::Save(), sswf::TagButton::Save(), sswf::Edges::Save(), sswf::ActionPushData::SaveData(), sswf::ActionFunction::SaveData(), sswf::ActionDictionary::SaveData(), sswf::Action::SaveList(), sswf::TagShape::SaveShape(), sswf::TagShape::SaveStyles(), sswf::TagShape::SaveWithoutStyles(), sswf::Edges::Set(), and sswf::TagFont::SetUsedGlyphs().

void Vectors::Insert ( int  index,
ItemBase ptr 
)

This function is used to add an item at the specified index.

If items exist after the specified position, then their index position is incremented by one each before the new item is saved.

Parameters:
[in] index The position where the new item is saved
[in] ptr The pointer to be saved at that specific position

References f_count, f_vectors, and SetSize().

Referenced by sswf::TagFont::AddGlyph(), and sswf::Action::FindLabelAtOffset().

Vectors & Vectors::operator= ( const Vectors vectors  ) 

This is the equal operator which copies the source vector to this vector. Anything in the old vector will be freed as required.

Parameters:
[in] vectors The source vector to be copied

References f_count, f_vectors, and SetSize().

void Vectors::Set ( int  index,
ItemBase ptr 
)

This function sets the specified item at the specified index in the vectors. If another item was defined at that index, it is overwritten.

It is possible to set an item at an index which does not exist yet. If the index is beyond of the last item, the pointers in between are set to all zeroes.

Parameters:
[in] index The index (position) where the item is saved
[in] ptr The pointer to save at the specified position

References f_count, f_vectors, and SetSize().

Referenced by sswf::ActionWith::AddAction(), sswf::ActionWaitForFrame::AddAction(), sswf::ActionFunction::AddAction(), sswf::ActionPushData::AddBoolean(), sswf::ActionTry::AddCatchAction(), sswf::ActionPushData::AddDouble(), sswf::SoundInfo::AddEnvelope(), sswf::TagPlace::AddEvent(), sswf::TagButton::AddEvent(), sswf::ActionTry::AddFinallyAction(), sswf::ActionPushData::AddFloat(), sswf::ActionPushData::AddInteger(), sswf::TagFont::AddKern(), sswf::ActionPushData::AddLookup(), sswf::TagShape::AddMove(), sswf::TagImport::AddName(), sswf::ActionPushData::AddNull(), sswf::ActionFunction::AddParameter(), sswf::ActionPushData::AddRegister(), sswf::ActionPushData::AddString(), sswf::ActionDictionary::AddString(), sswf::TagShape::AddStyle(), sswf::TagText::AddText(), sswf::ActionTry::AddTryAction(), sswf::ActionPushData::AddUndefined(), sswf::TagShape::NewStyles(), sswf::Action::Parse(), sswf::ActionPushData::ParseData(), sswf::ActionDictionary::ParseData(), sswf::TagExport::ParseTag(), sswf::TagShape::RecordEdges(), sswf::TagText::RecordSetup(), sswf::TagShape::RecordSetup(), sswf::TagShape::Save(), sswf::Edges::Set(), sswf::TagDoAction::SetAction(), sswf::TagButton::SetAction(), sswf::TagExport::SetObject(), and sswf::TagButton::SetState().

void Vectors::SetSize ( int  size  ) 

This function sets the new size of the vectors internal buffer. If the internal buffer is already large enough, then nothing happens (i.e. the size is not reduced.)

A size of zero (or negative) means that the vectors should be emptied. Thus the array is freed and the counters are reset.

Note that this function does not change the count unless the new size is smaller than the current count or is zero. In the latter case, the count is set to zero also.

Note:
At this time, the size is always rounded up to the next multiple of 256. This ensures that vectors aren't grown too often.
Parameters:
[in] size The size of the buffer used to save the pointers
See also:
sswf::Vectors::Count()

sswf::Vectors::Empty()

References f_count, f_max, f_vectors, sswf::MemoryManager::MemClean(), and sswf::MemoryManager::MemRealloc().

Referenced by Insert(), operator=(), Set(), Vectors(), and ~Vectors().


Member Data Documentation

int sswf::Vectors::f_max [private]

Referenced by SetSize(), and Vectors().


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


Generated on Wed Mar 18 15:14:00 2009 for libsswf by  doxygen 1.5.5