memory/scopedptrarray.bi

Summary
memory/scopedptrarray.bi
LicenseCopyright © 2007-2011, FreeBASIC Extended Library Development Group
ext
ScopedArrayThis class implements a pointer array container similiar to boost::scoped_array.
Functions
constuctorThis constructor takes another ScopedArray as its argument and transfers ownership to the newly created ScopedArray.
constructorThis constructor takes a pointer array of (type) and becomes responsible for its deletion.
constructorThis constructor takes a pointer of (type) and will call a user passed subroutine to free the memory.
Operator LetTransfers ownership of a pointer to the lhs ScopedArray.
Operator CastProvided to allow passing a ScopedArray(type) to a procedure requiring a (type) ptr
GetProvided to allow passing a ScopedArray(type) to a procedure requiring a (type) ptr
indexProvided to allow accessing values in the pointer array.
* (dereference)Dereferences the (type) pointer owned by a ScopedArray returning the value pointed to by the pointer.

License

Copyright © 2007-2011, FreeBASIC Extended Library Development Group

Distributed under the FreeBASIC Extended Library Group license.  See accompanying file LICENSE.txt or copy at http://code.google.com/p/fb-extended-lib/wiki/License

ext

ScopedArray

This class implements a pointer array container similiar to boost::scoped_array.

Description

A ScopedArray is guaranteed to be deleted when it goes out of scope.

A ScopedArray has sole ownership of a pointer array, if assigned to another ScopedArray the new ScopedArray will gain ownership of the pointer array and the original ScopedArray is now invalid.

Summary
Functions
constuctorThis constructor takes another ScopedArray as its argument and transfers ownership to the newly created ScopedArray.
constructorThis constructor takes a pointer array of (type) and becomes responsible for its deletion.
constructorThis constructor takes a pointer of (type) and will call a user passed subroutine to free the memory.
Operator LetTransfers ownership of a pointer to the lhs ScopedArray.
Operator CastProvided to allow passing a ScopedArray(type) to a procedure requiring a (type) ptr
GetProvided to allow passing a ScopedArray(type) to a procedure requiring a (type) ptr
indexProvided to allow accessing values in the pointer array.
* (dereference)Dereferences the (type) pointer owned by a ScopedArray returning the value pointed to by the pointer.

Functions

constuctor

This constructor takes another ScopedArray as its argument and transfers ownership to the newly created ScopedArray.

constructor

declare constructor (byval p as fbext_TypeName(T_) ptr =  null)

This constructor takes a pointer array of (type) and becomes responsible for its deletion.

Description

When constructing a ScopedArray with this constructor delete[] will be used to free the memory.

constructor

declare constructor (byval p as fbext_TypeName(T_) ptr,
byval destroy as fbext_DestroyProc(T_))

This constructor takes a pointer of (type) and will call a user passed subroutine to free the memory.

Operator Let

Transfers ownership of a pointer to the lhs ScopedArray.

Usage

var myptr = type<ScopedArrayinteger>(new integer[10])
var mysecondptr = myptr

mysecondptr now has control of the pointer array and myptr is invalid.

Operator Cast

Provided to allow passing a ScopedArray(type) to a procedure requiring a (type) ptr

Get

declare function Get () as fbext_TypeName(T_) ptr

Provided to allow passing a ScopedArray(type) to a procedure requiring a (type) ptr

index

declare function index (byval rhs as integer) as fbext_TypeName(T_)

Provided to allow accessing values in the pointer array.

* (dereference)

declare operator * (
   byref rhs as fbext_ScopedPtrArray(T_)
) as fbext_TypeName(T_)

Dereferences the (type) pointer owned by a ScopedArray returning the value pointed to by the pointer.

declare constructor (byval p as fbext_TypeName(T_) ptr =  null)
This constructor takes a pointer array of (type) and becomes responsible for its deletion.
declare function Get () as fbext_TypeName(T_) ptr
Provided to allow passing a ScopedArray(type) to a procedure requiring a (type) ptr
declare function index (byval rhs as integer) as fbext_TypeName(T_)
Provided to allow accessing values in the pointer array.
declare operator * (
   byref rhs as fbext_ScopedPtrArray(T_)
) as fbext_TypeName(T_)
Dereferences the (type) pointer owned by a ScopedArray returning the value pointed to by the pointer.