FieldList Class Reference

#include <Field.h>

Collaboration diagram for FieldList:

Collaboration graph
[legend]

Public Member Functions

 FieldList ()
DbRetVal append (FieldDef fDef)
DbRetVal remove (const char *fldName)
DbRetVal removeAll ()
DbRetVal updateBindVal (const char *fldName, void *val)
int getFieldOffset (const char *fldName)
int getFieldOffset (int fldpos)
int getFieldPosition (const char *fldName)
DataType getFieldType (const char *fldName)
size_t getFieldLength (const char *fldName)
DbRetVal getFieldInfo (const char *fldName, FieldInfo *&info)
int getTupleSize ()
FieldIterator getIterator ()

Data Fields

FieldNodehead

Detailed Description

Definition at line 95 of file Field.h.


Constructor & Destructor Documentation

FieldList::FieldList (  )  [inline]

Definition at line 99 of file Field.h.

References head.

00099 { head = NULL;}


Member Function Documentation

DbRetVal FieldList::append ( FieldDef  fDef  ) 

Definition at line 23 of file FieldList.cxx.

References FieldNode::fldDef, head, FieldNode::next, and OK.

Referenced by TableDef::addField(), CatalogTableFIELD::getFieldInfo(), and ParsedData::insertFldDef().

00024 {
00025     FieldNode *newNode = new FieldNode();
00026     newNode->fldDef = fDef;
00027     newNode->next = NULL;
00028     //If this is the first node, set it as head
00029     if (NULL == head) { head = newNode; return OK; }
00030 
00031     FieldNode *iter = head;
00032     while (NULL != iter->next) iter = iter->next;
00033     iter->next = newNode;
00034     return OK;
00035 }

Here is the caller graph for this function:

DbRetVal FieldList::getFieldInfo ( const char *  fldName,
FieldInfo *&  info 
)

Definition at line 117 of file FieldList.cxx.

References FieldInfo::defaultValueBuf, FieldDef::defaultValueBuf_, ErrNotFound, FieldNode::fldDef, FieldInfo::fldName, FieldDef::fldName_, getFieldOffset(), head, FieldInfo::isDefault, FieldDef::isDefault_, FieldInfo::isNull, FieldDef::isNull_, FieldInfo::isPrimary, FieldDef::isPrimary_, FieldInfo::length, FieldDef::length_, FieldNode::next, FieldInfo::offset, OK, FieldInfo::type, and FieldDef::type_.

Referenced by TableImpl::getFieldInfo().

00118 {
00119     FieldNode *iter = head;
00120     while(iter != NULL)
00121     {
00122         if (0 == strcmp(iter->fldDef.fldName_, fldName))
00123         {
00124             strcpy(info->fldName , iter->fldDef.fldName_);
00125             info->length = iter->fldDef.length_;
00126             info->type   = iter->fldDef.type_;
00127             info->offset = getFieldOffset(fldName);
00128             info->isDefault = iter->fldDef.isDefault_;
00129             strcpy(info->defaultValueBuf, iter->fldDef.defaultValueBuf_);
00130             info->isNull = iter->fldDef.isNull_;
00131             info->isPrimary = iter->fldDef.isPrimary_;
00132             return OK;
00133 
00134         }
00135         iter = iter ->next;
00136     }
00137     return ErrNotFound;
00138 }

Here is the call graph for this function:

Here is the caller graph for this function:

size_t FieldList::getFieldLength ( const char *  fldName  ) 

Definition at line 222 of file FieldList.cxx.

References FieldNode::fldDef, FieldDef::fldName_, head, FieldDef::length_, and FieldNode::next.

Referenced by TableImpl::getFieldLength(), and DatabaseManagerImpl::openTable().

00223 {
00224     FieldNode *iter = head;
00225     int offset = 0;
00226     while(iter != NULL)
00227     {
00228         if (0 == strcmp(iter->fldDef.fldName_, fldName))
00229         {
00230             return iter->fldDef.length_;
00231         }
00232         iter = iter ->next;
00233     }
00234     return -1;
00235 }

Here is the caller graph for this function:

int FieldList::getFieldOffset ( int  fldpos  ) 

Definition at line 155 of file FieldList.cxx.

References os::align(), FieldNode::fldDef, head, FieldDef::length_, and FieldNode::next.

00156 {
00157     if (fldpos < 1) return -1;
00158     FieldNode *iter = head;
00159     int offset = 0;
00160     int counter =0;
00161     while(iter != NULL)
00162     {
00163         if (counter == fldpos -1)
00164         {
00165             return offset;
00166         }
00167         offset = offset + os::align(iter->fldDef.length_);
00168         iter = iter ->next;
00169         counter++;
00170     }
00171     return -1;
00172 }

Here is the call graph for this function:

int FieldList::getFieldOffset ( const char *  fldName  ) 

Definition at line 140 of file FieldList.cxx.

References os::align(), FieldNode::fldDef, FieldDef::fldName_, head, FieldDef::length_, and FieldNode::next.

Referenced by getFieldInfo(), TableImpl::getFieldOffset(), and DatabaseManagerImpl::openTable().

00141 {
00142     FieldNode *iter = head;
00143     int offset = 0;
00144     while(iter != NULL)
00145     {
00146         if (0 == strcmp(iter->fldDef.fldName_, fldName))
00147         {
00148             return offset;
00149         }
00150         offset = offset + os::align(iter->fldDef.length_);
00151         iter = iter ->next;
00152         }
00153         return -1;
00154 }

Here is the call graph for this function:

Here is the caller graph for this function:

int FieldList::getFieldPosition ( const char *  fldName  ) 

Definition at line 177 of file FieldList.cxx.

References FieldNode::fldDef, FieldDef::fldName_, head, and FieldNode::next.

Referenced by TableImpl::clearFldNull(), TableImpl::isFldNull(), and TableImpl::markFldNull().

00178 {
00179     int position = 1;
00180     FieldNode *iter = head;
00181     while(iter != NULL)
00182     {
00183         if (0 == strcmp(iter->fldDef.fldName_, fldName))
00184             return position;
00185         position++;
00186         iter  = iter->next;
00187     }
00188 
00189     return -1;
00190 }

Here is the caller graph for this function:

DataType FieldList::getFieldType ( const char *  fldName  ) 

Definition at line 206 of file FieldList.cxx.

References FieldNode::fldDef, FieldDef::fldName_, head, FieldNode::next, FieldDef::type_, and typeUnknown.

Referenced by TableImpl::getFieldType().

00207 {
00208     FieldNode *iter = head;
00209     int offset = 0;
00210     while(iter != NULL)
00211     {
00212         if (0 == strcmp(iter->fldDef.fldName_, fldName))
00213         {
00214             return iter->fldDef.type_;
00215         }
00216         iter = iter ->next;
00217         }
00218     return typeUnknown;
00219 }

Here is the caller graph for this function:

FieldIterator FieldList::getIterator (  )  [inline]

Definition at line 124 of file Field.h.

References head.

Referenced by TableDef::getFieldIterator(), TableImpl::getFieldNameList(), DatabaseManagerImpl::openTable(), CreateTblStatement::resolve(), and HashIndex::update().

00125     {
00126         FieldIterator iter(head);
00127         return iter;
00128     }

Here is the caller graph for this function:

int FieldList::getTupleSize (  ) 

Definition at line 192 of file FieldList.cxx.

References os::align(), FieldNode::fldDef, head, FieldDef::length_, and FieldNode::next.

00193 {
00194     FieldNode *iter = head;
00195     int offset = 0;
00196     while(iter != NULL)
00197     {
00198         offset = offset + os::align(iter->fldDef.length_);
00199         iter = iter ->next;
00200         }
00201         return offset;
00202 }

Here is the call graph for this function:

DbRetVal FieldList::remove ( const char *  fldName  ) 

Definition at line 38 of file FieldList.cxx.

References ErrNotExists, ErrNotFound, FieldNode::fldDef, FieldDef::fldName_, head, FieldNode::next, OK, and printError.

Referenced by TableDef::dropField().

00039 {
00040     if (NULL == head)
00041     {
00042         printError(ErrNotExists, "There are no elements in the list. Empty list");
00043         return ErrNotExists;
00044     }
00045     FieldNode *iter = head, *prev = head;
00046     while (iter->next != NULL)
00047     {
00048         if (0 == strcmp(iter->fldDef.fldName_, fldName))
00049         {
00050             prev->next = iter->next;
00051             delete iter;
00052         }
00053         prev = iter;
00054         iter = iter->next;
00055     }
00056     if( iter == head) // there is only one node in the list
00057     {
00058         if (0 == strcmp(iter->fldDef.fldName_, fldName))
00059         {
00060             delete head;
00061             head = NULL;
00062             return OK;
00063         }
00064 
00065     }
00066     if( prev == head) // there are only two node in the list
00067     {
00068         if (0 == strcmp(iter->fldDef.fldName_, fldName))
00069         {
00070             head->next = NULL;
00071             delete iter;
00072             return OK;
00073         }
00074     }
00075     printError(ErrNotFound, "There are no elements in the list");
00076     return ErrNotFound;
00077 }

Here is the caller graph for this function:

DbRetVal FieldList::removeAll (  ) 

Definition at line 79 of file FieldList.cxx.

References head, FieldNode::next, and OK.

Referenced by ParsedData::reset(), TableDef::reset(), and TableImpl::~TableImpl().

00080 {
00081     if (NULL == head) return OK;
00082     FieldNode *iter = head, *next = head;
00083     while (iter->next != NULL)
00084     {
00085         next = iter->next;
00086         delete iter;
00087         iter = next;
00088     }
00089     delete iter;  //deleting the last element
00090     head = NULL;
00091     return OK;
00092 }

Here is the caller graph for this function:

DbRetVal FieldList::updateBindVal ( const char *  fldName,
void *  val 
)

Definition at line 96 of file FieldList.cxx.

References FieldDef::bindVal_, ErrBadArg, ErrNotFound, FieldNode::fldDef, FieldDef::fldName_, head, FieldNode::next, OK, and printError.

Referenced by TableImpl::bindFld().

00097 {
00098     if (NULL == val)
00099     {
00100         printError(ErrBadArg, "Value passed is NULL");
00101         return ErrBadArg;
00102     }
00103     FieldNode *iter = head;
00104     while(NULL != iter)
00105     {
00106         if (strcmp(iter->fldDef.fldName_, fldName) == 0)
00107         {
00108             iter->fldDef.bindVal_ = val;
00109             return OK;
00110         }
00111         iter = iter ->next;
00112     }
00113     printError(ErrNotFound, "Field not present in the list");
00114     return ErrNotFound;
00115 }

Here is the caller graph for this function:


Field Documentation

FieldNode* FieldList::head

Definition at line 98 of file Field.h.

Referenced by append(), FieldList(), getFieldInfo(), getFieldLength(), getFieldOffset(), getFieldPosition(), getFieldType(), getIterator(), getTupleSize(), remove(), removeAll(), and updateBindVal().


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