List Class Reference

#include <Util.h>

Collaboration diagram for List:

Collaboration graph
[legend]

Public Member Functions

 List ()
DbRetVal append (void *elem)
DbRetVal remove (void *elem)
void * get (int index)
bool exists (void *elem)
ListIterator getIterator ()
void reset ()
int size ()

Detailed Description

Definition at line 74 of file Util.h.


Constructor & Destructor Documentation

List::List (  )  [inline]

Definition at line 79 of file Util.h.

00079 { head = NULL; totalElements = 0;}


Member Function Documentation

DbRetVal List::append ( void *  elem  )  [inline]

Definition at line 81 of file Util.h.

References ListNode::element, ListNode::next, and OK.

Referenced by SqlLogConnection::addPacket(), SqlLogConnection::addPreparePacket(), PacketCommit::getExecPacketList(), TableImpl::getFieldNameList(), CatalogTableTABLE::getTableList(), ParsedData::insertCondValueAndGetPtr(), ParsedData::insertField(), ParsedData::insertFieldValue(), ParsedData::insertInValue(), ParsedData::insertUpdateValue(), ParsedData::insertValue(), CacheTableLoader::load(), SqlLogStatement::prepare(), SqlOdbcStatement::prepare(), SqlNetworkHandler::processPrepare(), and verifyPrimKeyFldVal().

00082     {
00083         ListNode *newNode = new ListNode();
00084         newNode->element = elem;
00085         newNode->next = NULL;
00086         totalElements++;
00087         //If this is the first node, set it as head
00088         if (NULL == head) { head = newNode; return OK; }
00089 
00090         ListNode *iter = head;
00091         while (NULL != iter->next) iter = iter->next;
00092         iter->next = newNode;
00093         return OK;
00094     }

Here is the caller graph for this function:

bool List::exists ( void *  elem  )  [inline]

Definition at line 135 of file Util.h.

References ListNode::element, and ListNode::next.

00136     {
00137         ListNode *iter = head;
00138         while (iter != NULL)
00139         {
00140             if (elem == iter->element)
00141             {
00142                 return true;
00143             }
00144             iter = iter->next;
00145         }
00146         return false;
00147     }

void* List::get ( int  index  )  [inline]

Definition at line 123 of file Util.h.

References ListNode::element, and ListNode::next.

Referenced by SqlOdbcStatement::bindField(), PacketExecute::marshall(), SqlLogStatement::setByteIntParam(), SqlOdbcStatement::setByteIntParam(), SqlLogStatement::setDateParam(), SqlOdbcStatement::setDateParam(), SqlLogStatement::setDoubleParam(), SqlOdbcStatement::setDoubleParam(), PacketCommit::setExecPackets(), SqlLogStatement::setFloatParam(), SqlOdbcStatement::setFloatParam(), SqlLogStatement::setIntParam(), SqlOdbcStatement::setIntParam(), SqlLogStatement::setLongLongParam(), SqlOdbcStatement::setLongLongParam(), SqlLogStatement::setLongParam(), SqlOdbcStatement::setLongParam(), PacketExecute::setParams(), SqlLogStatement::setShortParam(), SqlOdbcStatement::setShortParam(), SqlLogStatement::setStringParam(), SqlOdbcStatement::setStringParam(), SqlLogStatement::setTimeParam(), SqlOdbcStatement::setTimeParam(), SqlLogStatement::setTimeStampParam(), and SqlOdbcStatement::setTimeStampParam().

00124     {
00125         ListNode *localIter = head;
00126         if (localIter == NULL) return NULL;
00127         for (int i=0; i <index -1; i++) {
00128            localIter = localIter->next;
00129            if (localIter == NULL) break;
00130         }
00131         return localIter->element;
00132     }

Here is the caller graph for this function:

ListIterator List::getIterator (  )  [inline]

Definition at line 149 of file Util.h.

Referenced by SqlLogConnection::commit(), CreateIdxStatement::execute(), CreateTblStatement::execute(), SqlOdbcStatement::execute(), SqlOdbcStatement::fetch(), SqlOdbcStatement::fetchAndPrint(), SqlOdbcStatement::free(), SelStatement::getFieldName(), SqlOdbcStatement::getParamFldInfo(), SelStatement::getProjFldInfo(), SqlOdbcStatement::getProjFldInfo(), handleEchoAndComment(), insert(), SqlLogConnection::isTableCached(), CacheTableLoader::load(), main(), SqlLogConnection::removePreparePacket(), ParsedData::reset(), SelStatement::resolve(), InsStatement::resolve(), CreateTblStatement::resolve(), UpdStatement::resolveForAssignment(), DelStatement::resolveForCondition(), SqlLogConnection::rollback(), PacketExecute::unmarshall(), verifyPrimKeyFldVal(), and yyparse().

00150     {
00151         ListIterator iter(head);
00152         return iter;
00153     }

Here is the caller graph for this function:

DbRetVal List::remove ( void *  elem  )  [inline]

Definition at line 97 of file Util.h.

References ListNode::element, ErrNotExists, ErrNotFound, ListNode::next, OK, and printError.

Referenced by SqlLogConnection::removePreparePacket().

00098     {
00099         if (NULL == head)
00100         {
00101             printError(ErrNotExists, "There are no elements in the list. Empty list");
00102             return ErrNotExists;
00103         }
00104         ListNode *iter = head, *prev = head;
00105         while (iter != NULL)
00106         {
00107             if (elem == iter->element)
00108             {
00109                 prev->next = iter->next;
00110                 delete iter;
00111                 totalElements--;
00112                 if (iter == head) { head = NULL; return OK;}
00113                 return OK;
00114             }
00115             prev = iter;
00116             iter = iter->next;
00117         }
00118         printError(ErrNotFound, "There are no elements in the list");
00119         return ErrNotFound;
00120     }

Here is the caller graph for this function:

void List::reset (  )  [inline]

Definition at line 154 of file Util.h.

References ListNode::next.

Referenced by ParsedData::clearFieldNameList(), SqlLogConnection::commit(), SqlLogStatement::free(), SqlOdbcStatement::free(), CacheTableLoader::load(), main(), ParsedData::reset(), InsStatement::resolve(), SqlLogConnection::rollback(), and verifyPrimKeyFldVal().

00155     {
00156         if (NULL == head) return;
00157         ListNode *iter = head, *prevIter = head;
00158         while (iter->next != NULL)
00159         {
00160             prevIter = iter;
00161             iter = iter->next;
00162             delete prevIter;
00163 
00164         }
00165         delete iter;
00166         head = NULL;
00167         totalElements = 0;
00168         return;
00169     }

Here is the caller graph for this function:

int List::size (  )  [inline]

Definition at line 170 of file Util.h.

Referenced by SqlLogConnection::commit(), SqlLogConnection::connect(), CreateIdxStatement::execute(), CreateTblStatement::execute(), SqlOdbcStatement::noOfParamFields(), SqlOdbcStatement::noOfProjFields(), InsStatement::resolve(), PacketCommit::setExecPackets(), PacketExecute::setParams(), and verifyPrimKeyFldVal().

00171     {
00172         return totalElements;
00173     }

Here is the caller graph for this function:


The documentation for this class was generated from the following file:
Generated on Mon Jun 9 22:48:22 2008 for csql by  doxygen 1.4.7