Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

CThingStack Class Reference

This class is a stack of rebi. More...

Collaboration diagram for CThingStack:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 CThingStack ()
 The CThingStack contstructor simply calls the Construct function.
 ~CThingStack ()
 The CThingStack destructor simply calls the Destruct function.
void Construct ()
 The Constructor function sets the head pointer to NULL.
void Destruct ()
 The Destruct function simply calls the Empty function.
void PushBareRef (CThing *objptr)
 This function creates a new bare reference type of stack object and pushes it to the top of the stack.
void PushStrRef (CThing *objptr, unsigned long offset)
 This function creates a new string reference type of stack object and pushes it to the top of the stack.
void PushStackBlock ()
 This function creates a new stack block type of StackObj and pushes it to the top of the stack.
void PushStackObject (StackObj *s)
 This function pushes a stack object "as is" to the top of the stack.
StackObjGetTop () const
 This function returns the first StackObj in the stack.
StackObjGetN (unsigned long depth) const
 This function returns the elemtent with the given distance from the top of the stack.
StackObjGetFunc ()
 This function returns the first StackObj before a stack block or before the end of the stack, whichever is first.
StackObjPop ()
 This function is the standard pop operation for stacks.
void Empty ()
 This function loops through the stack and releases the memory associated with each StackObj.
bool IsEmpty () const
 Determines if the stack has any elements in it.
void Reverse ()
 This function reverses the order of elements in the stack.
void ConvertStackToBares ()
 The ConvertStackToBares function turns all string reference objects in the stack into bare reference objects.
CThingStackGetASubStack ()
 Returns a sub-stack that has had all of its string reference type StackObj objects converted to bare references.
CThingStackGetASubStackUnsafe ()
 This function returns a new sub-stack from an existing stack.
unsigned int NumberOfObjects () const
 This function returns the number of elements that are a member of the stack.

Private Attributes

StackObjhead
 The top of the stack.

Detailed Description

This class is a stack of rebi.

It is often used to store the parameters, return values, usings, or current stack of a function call. A CThingStack may store several different kinds of references.

See also:
StackObj


Constructor & Destructor Documentation

CThingStack::CThingStack  ) 
 

The CThingStack contstructor simply calls the Construct function.

See also:
CThingStack::Construct()

CThingStack::~CThingStack  ) 
 

The CThingStack destructor simply calls the Destruct function.

See also:
CThingStack::Destruct()


Member Function Documentation

void CThingStack::ConvertStackToBares  ) 
 

The ConvertStackToBares function turns all string reference objects in the stack into bare reference objects.

This function is usually called before passing a stack to a function and on the return values from a function call, because in both these cases a string reference may be invalid.

See also:
ConvertSRefToBRef()

void CThingStack::Destruct  ) 
 

The Destruct function simply calls the Empty function.

See also:
CThingStack::Empty()

void CThingStack::Empty  ) 
 

This function loops through the stack and releases the memory associated with each StackObj.

Any CThing objects pointed to by StackObjs in the stack have ReleaseCThing called on them. After this function has finished head is NULL.

See also:
ReleaseCThing()

CThingStack * CThingStack::GetASubStack  ) 
 

Returns a sub-stack that has had all of its string reference type StackObj objects converted to bare references.

This is implemented though a call to CThingStack::GetASubStackUnsafe()

See also:
CThingStack::GetASubStackUnsafe()
Returns:
the sub-stack, which is no longer part of the stack it was taken from.

CThingStack * CThingStack::GetASubStackUnsafe  ) 
 

This function returns a new sub-stack from an existing stack.

A sub-stack consists of all the elements in the existing stack up until a stack block is enountered or the end of the stack. The elements in the new sub-stack are the reverse of what they were in the parent stack. The elements in the sub-stack are removed from the parent stack, as is the stack block it stopped at, if any. The stack block however is not put on the sub-stack. The new sub-stack has its memory allocated by the def memory manger variable.

See also:
CThingStack::GetASubStack()
Returns:
the new sub-stack, never NULL.

StackObj * CThingStack::GetFunc  ) 
 

This function returns the first StackObj before a stack block or before the end of the stack, whichever is first.

The StackObj returned by this function is removed from the stack. This function is used to find the rebi that should be called upon being executed, as the function to be called is the first rebi on the stack or the first one after a stack block.

Returns:
the function rebi, or NULL if the stack is empty or the first object in the stack is a stack block.

StackObj * CThingStack::GetN unsigned long  depth  )  const
 

This function returns the elemtent with the given distance from the top of the stack.

0 is considered the top of the stack.

Parameters:
depth the distance fromt the top of the stack.
Returns:
the StackObj at that position, or NULL if there are not enough elements in the stack.

StackObj * CThingStack::GetTop  )  const
 

This function returns the first StackObj in the stack.

This function does not pop the value from the stack.

Returns:
the top of the stack or NULL if the stack is empty.

bool CThingStack::IsEmpty  )  const
 

Determines if the stack has any elements in it.

Returns:
true if the stack has elements, false otherwise.

unsigned int CThingStack::NumberOfObjects  )  const
 

This function returns the number of elements that are a member of the stack.

Returns:
the number of elements.

StackObj * CThingStack::Pop  ) 
 

This function is the standard pop operation for stacks.

Returns:
the element of the stack that was previously the top, or null if the stack was empty.

void CThingStack::PushBareRef CThing objptr  ) 
 

This function creates a new bare reference type of stack object and pushes it to the top of the stack.

This function does not alter the reference count of the rebi.

See also:
StackObj
Parameters:
objptr the rebi to be pushed.

void CThingStack::PushStackBlock  ) 
 

This function creates a new stack block type of StackObj and pushes it to the top of the stack.

See also:
StackObj

void CThingStack::PushStackObject StackObj s  ) 
 

This function pushes a stack object "as is" to the top of the stack.

StackObj objects pushed in this way should be either returns from Pop or GetFunc calls, or dynamically allocated memory. Freeing the memory associated with a StackObj after it has been added to the stack, adding non-dynamically allocated StackObj objects, or adding the same StackObj to more than one stack or to the same stack more than once is an error.

Parameters:
s the StackObj to be pushed.

void CThingStack::PushStrRef CThing objptr,
unsigned long  offset
 

This function creates a new string reference type of stack object and pushes it to the top of the stack.

This function does not alter the reference count of the rebi.

See also:
StackObj
Parameters:
objptr the rebi to be pushed.
offset the string index of the rebi.


The documentation for this class was generated from the following files:
Generated on Sat Apr 16 16:31:09 2005 for Centum API by  doxygen 1.4.2