From: <sja...@us...> - 2003-08-14 00:47:22
|
Update of /cvsroot/binaryphp/binaryphp In directory sc8-pr-cvs1:/tmp/cvs-serv16464 Added Files: arg_list.cpp arg_list.hpp Log Message: Add arg_list class. --- NEW FILE: arg_list.cpp --- #include "arg_list.hpp" arg_list::arg_list() : length(0), first(NULL), current(NULL) { this->first = this->current = this->last = new arg_item; this->first->index = 0; this->first->value = NULL; this->first->next = NULL; } arg_list::~arg_list() { this->current = this->first; while( this->current != this->last ) { arg_item *temp = this->current->next; delete this->current; this->current = temp; } delete this->last; } void arg_list::add( php_var *arg ) { this->last->value = arg; this->last->next = new arg_item; this->last->next->index = this->last->index + 1; this->last = this->last->next; this->length++; } const php_var* arg_list::cur() { if( this->current != NULL ) return this->current->value; else return NULL; } const php_var* arg_list::fetch() { php_var *temp = this->current->value; if( this->current != this->last ) { this->current = this->current->next; } return temp; } int arg_list::pos() { if( this->current != NULL ) return this->current->index; else return -1; } int arg_list::len() { return this->length; } void arg_list::start() { this->current = this->first; } void arg_list::skip( int num ) { while( --num ) { if( this->current != NULL && this->current != this->last ) this->current = this->current->next; else return; } } void arg_list::end() { while( this->current->next != this->last ) this->skip(); } --- NEW FILE: arg_list.hpp --- #include "php_var.hpp" #ifndef __arg_list #define __arg_list class arg_list { private: struct arg_item { int index; php_var *value; arg_item *next; arg_item() { index = 0; value = NULL; next = NULL; } }; int length; arg_item *first; arg_item *current; arg_item *last; public: arg_list(); ~arg_list(); void add( php_var* ); // Add an argument const php_var* cur(); // Return current arg (does *not* iterate) const php_var* fetch(); // Return current arg, and iterate int pos(); // Current offset int len(); // Number of items void start(); // Set current arg to the first in the list void skip( int = 1 ); // Skip args void end(); // Set current arg to the last in the list }; //define FUNCTION(name) php_var name(arg_list args) //define RETURN(var) return php_var(var) #endif |