gnash::as_array_object Class Reference

The Array ActionScript object. More...

#include <array.h>

Inheritance diagram for gnash::as_array_object:

gnash::as_object gnash::ref_counted

List of all members.

Public Types

enum  SortFlags {
  fCaseInsensitive = (1<<0), fDescending = (1<<1), fUniqueSort = (1<<2), fReturnIndexedArray = (1<<3),
  fNumeric = (1<<4)
}
 Sort flags. More...
typedef std::deque< as_valuecontainer
typedef container::const_iterator const_iterator
typedef container::iterator iterator

Public Member Functions

template<class V>
void visitAll (V &v)
 Visit all elements.
 as_array_object ()
 as_array_object (const as_array_object &other)
 ~as_array_object ()
std::deque< indexed_as_valueget_indexed_elements ()
const_iterator begin ()
const_iterator end ()
void push (const as_value &val)
 Push an element to the end of the array.
void unshift (const as_value &val)
as_value shift ()
as_value pop ()
as_value at (unsigned int index)
as_array_objectget_indices (std::deque< indexed_as_value > origElems)
void reverse ()
void set_indexed (unsigned int index, const as_value &v)
std::string join (const std::string &separator, as_environment *env) const
std::string toString (as_environment *env=NULL) const
std::string get_text_value () const
 Return a text representation for this object.
unsigned int size () const
void resize (unsigned int)
void concat (const as_array_object &other)
std::auto_ptr< as_array_objectslice (unsigned int start, unsigned int one_past_end)
 Return a newly created array containing elements from 'start' up to but not including 'end'.
bool removeFirst (const as_value &v)
 Remove first element matching the given value.
std::auto_ptr< as_array_objectsplice (unsigned start, unsigned len, const std::vector< as_value > &replacement)
 Substitute 'len' elements from 'start' with elements from the given array.
template<class AVCMP>
void sort (AVCMP avc)
 Sort the array, using given values comparator.
template<class AVCMP, class AVEQ>
as_value sort (AVCMP avc, AVEQ ave)
 Attempt to sort the array using given values comparator, avc. If two or more elements in the array are equal, as determined by the equality comparator ave, then the array is not sorted and 0 is returned. Otherwise the array is sorted and returned.
template<class AVCMP>
as_array_objectsort_indexed (AVCMP avc)
 Return a new array containing sorted index of this array.
template<class AVCMP, class AVEQ>
as_value sort_indexed (AVCMP avc, AVEQ ave)
 Return a new array containing sorted index of this array. If two or more elements in the array are equal, as determined by the equality comparator ave, then 0 is returned instead.
virtual bool get_member (string_table::key name, as_value *val, string_table::key nsname=0)
 Overridden to provide 'length' member.
virtual void set_member (string_table::key name, const as_value &val, string_table::key nsname=0)
 Overridden to provide array[#]=x semantic.
virtual void enumerateNonProperties (as_environment &) const
 Enumerate elements.


Detailed Description

The Array ActionScript object.

Member Typedef Documentation

typedef std::deque<as_value> gnash::as_array_object::container

typedef container::const_iterator gnash::as_array_object::const_iterator

typedef container::iterator gnash::as_array_object::iterator


Member Enumeration Documentation

enum gnash::as_array_object::SortFlags

Sort flags.

Enumerator:
fCaseInsensitive  Case-insensitive (z precedes A).
fDescending  Descending order (b precedes a).
fUniqueSort  If two or more elements in the array have identical sort fields, return 0 and don't modify the array. Otherwise proceed to sort the array.
fReturnIndexedArray  Don't modify the array, rather return a new array containing indexes into it in sorted order.
fNumeric  Numerical sort (9 preceeds 10).


Constructor & Destructor Documentation

gnash::as_array_object::as_array_object (  ) 

gnash::as_array_object::as_array_object ( const as_array_object other  ) 

gnash::as_array_object::~as_array_object (  ) 


Member Function Documentation

template<class V>
void gnash::as_array_object::visitAll ( V &  v  )  [inline]

Visit all elements.

The visitor class will have to expose a visit(as_value&) method

std::deque< indexed_as_value > gnash::as_array_object::get_indexed_elements (  ) 

std::deque< as_value >::const_iterator gnash::as_array_object::begin (  ) 

std::deque< as_value >::const_iterator gnash::as_array_object::end (  ) 

void gnash::as_array_object::push ( const as_value val  ) 

Push an element to the end of the array.

Parameters:
val The element to add

void gnash::as_array_object::unshift ( const as_value val  ) 

as_value gnash::as_array_object::shift (  ) 

as_value gnash::as_array_object::pop (  ) 

as_value gnash::as_array_object::at ( unsigned int  index  ) 

as_array_object * gnash::as_array_object::get_indices ( std::deque< indexed_as_value origElems  ) 

void gnash::as_array_object::reverse (  ) 

void gnash::as_array_object::set_indexed ( unsigned int  index,
const as_value v 
)

std::string gnash::as_array_object::join ( const std::string &  separator,
as_environment env 
) const

Parameters:
env If not-null will be used to properl invoke the toString() method against member values.

std::string gnash::as_array_object::toString ( as_environment env = NULL  )  const

Parameters:
env If not-null will be used to properly invoke the toString() method against member values.

std::string gnash::as_array_object::get_text_value (  )  const [inline, virtual]

Return a text representation for this object.

Reimplemented from gnash::as_object.

unsigned int gnash::as_array_object::size (  )  const

void gnash::as_array_object::resize ( unsigned int  newsize  ) 

void gnash::as_array_object::concat ( const as_array_object other  ) 

std::auto_ptr< as_array_object > gnash::as_array_object::slice ( unsigned int  start,
unsigned int  one_past_end 
)

Return a newly created array containing elements from 'start' up to but not including 'end'.

NOTE: assertions are:

assert(one_past_end >= start); assert(one_past_end <= size()); assert(start <= size());

Parameters:
start index to first element to include in result 0-based index.
one_past_end index to one-past element to include in result 0-based index.

bool gnash::as_array_object::removeFirst ( const as_value v  ) 

Remove first element matching the given value.

Return true if any element was removed, false otherwise

Parameters:
v The value to compare elements against
env The environment to use when comparing (needed by as_value::equals)

std::auto_ptr< as_array_object > gnash::as_array_object::splice ( unsigned  start,
unsigned  len,
const std::vector< as_value > &  replacement 
)

Substitute 'len' elements from 'start' with elements from the given array.

NOTE: assertions are:

assert(len <= size()-start); assert(start <= size());

Parameters:
start 0-index based offset of first element to replace.
len Number of elements to replace.
replacement The element to use as replacement
TODO: should we return by intrusive_ptr instead ?

template<class AVCMP>
void gnash::as_array_object::sort ( AVCMP  avc  )  [inline]

Sort the array, using given values comparator.

Parameters:
avc boolean functor or function comparing two as_value& objects

template<class AVCMP, class AVEQ>
as_value gnash::as_array_object::sort ( AVCMP  avc,
AVEQ  ave 
) [inline]

Attempt to sort the array using given values comparator, avc. If two or more elements in the array are equal, as determined by the equality comparator ave, then the array is not sorted and 0 is returned. Otherwise the array is sorted and returned.

Parameters:
avc boolean functor or function comparing two as_value& objects used to determine sort-order
ave boolean functor or function comparing two as_value& objects used to determine equality

template<class AVCMP>
as_array_object* gnash::as_array_object::sort_indexed ( AVCMP  avc  )  [inline]

Return a new array containing sorted index of this array.

Parameters:
avc boolean functor or function comparing two as_value& objects

template<class AVCMP, class AVEQ>
as_value gnash::as_array_object::sort_indexed ( AVCMP  avc,
AVEQ  ave 
) [inline]

Return a new array containing sorted index of this array. If two or more elements in the array are equal, as determined by the equality comparator ave, then 0 is returned instead.

Parameters:
avc boolean functor or function comparing two as_value& objects used to determine sort-order
ave boolean functor or function comparing two as_value& objects used to determine equality

bool gnash::as_array_object::get_member ( string_table::key  name,
as_value val,
string_table::key  nsname = 0 
) [virtual]

Overridden to provide 'length' member.

TODO: use a property for handling 'length'

Reimplemented from gnash::as_object.

void gnash::as_array_object::set_member ( string_table::key  name,
const as_value val,
string_table::key  nsname = 0 
) [virtual]

Overridden to provide array[#]=x semantic.

Reimplemented from gnash::as_object.

void gnash::as_array_object::enumerateNonProperties ( as_environment env  )  const [virtual]

Enumerate elements.

See as_object::enumerateNonProperties(as_environment&) for more info.

Reimplemented from gnash::as_object.


The documentation for this class was generated from the following files:
Generated on Thu Mar 6 18:25:10 2008 for Gnash by  doxygen 1.5.4