proj home

Files   Classes   Functions   Hierarchy  

cfcontainervec.cpp

Go to the documentation of this file.
00001 #include <cfcontainervec.h>
00002 
00003 #include <iostream>
00004 using namespace std;
00005 
00006 //compilationfile* cfcontainervec::access(stringc & filename) const
00007 compilationfile* cfcontainervec::operator [](stringc & filename) const
00008 {
00009   uint imax=vi.size();
00010   for (uint i=0; i<imax; ++i)
00011   {
00012     if (!vi[i])
00013       continue;
00014 
00015     if (vi[i]->filename == filename)
00016       return vi[i];  
00017   }
00018 
00019   return 0;
00020 }
00021 
00022 boolc cfcontainervec::add(compilationfile* cf)
00023 {
00024   assert(cf);
00025 
00026   //compilationfile* x = access(cf->filename);
00027   compilationfile* x = (*this)[cf->filename];
00028   if (x!=0)
00029     return false;
00030 
00031   vi.push_back(cf);
00032 
00033   return true;
00034 }
00035 
00036 void cfcontainervec::reset()
00037 {
00038   current=0;
00039 }
00040 
00041 boolc cfcontainervec::operator ! () 
00042 {
00043   // As this operator is called before accessing and ++,
00044   //   it has the responsibility of incrementing to a valid state.
00045   uint currentmax=vi.size();
00046   if (current >=currentmax)
00047     return false;
00048   
00049   while (vi[current]==0)
00050   {
00051     ++current;
00052     if (current==currentmax)
00053       return false;
00054   }
00055 
00056   return true;
00057 
00058 /*
00059   while ((current<currentmax)&&(vi[current]==0))
00060   {
00061     ++current;
00062   }
00063 */
00064 
00065  // return (current < currentmax);
00066 }
00067 
00068 void cfcontainervec::operator ++ ()
00069 {
00070   ++current;
00071 }
00072 
00073 compilationfile* cfcontainervec::operator() () const 
00074 {
00075   assert(current < vi.size());
00076 
00077   return vi[current];
00078 }
00079 
00080 boolc cfcontainervec::remove(stringc & filename)
00081 {
00082 //cout << filename << endl; 
00083 //if (filename=="main.h")
00084 //  cout << "* main.h" << endl;
00085 
00086   uint imax=vi.size();
00087   for (uint i=0; i<imax; ++i)
00088   {
00089     if (!vi[i])
00090       continue;
00091 
00092     if (vi[i]->filename == filename)
00093     {
00094       vi[i] = 0;
00095       return true;
00096     } 
00097   }
00098 
00099   return false;
00100 }
00101 
00102 
00103 

Generated on Fri Mar 4 00:49:27 2011 for Chelton Evans Source by  doxygen 1.5.8