Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Attributes
CMacros Class Reference

gess12/20/98 More...

Collaboration diagram for CMacros:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 CMacros ()
 CMacros (const CMacros &aCopy)
 ~CMacros ()
bool addMacro (char *aString)
int getCount ()
char * getMacro (int anIndex)
char * getFilename (void)
char * getRangeValueAt (char *aRange, int aRangeIndex)
bool first (void)
bool next (void)
bool consume (istrstream &aStream)
 gess12/23/98
void buildArgBuffer (char *aBuffer)
void dump (void)

Protected Attributes

int mCount
char * mKeys [100]
char * mRanges [100]
int mIndex [100]
char mFilename [125]
bool mBorrowedKeys

Detailed Description

gess12/20/98

Parameters:
@return

Definition at line 118 of file htmlgen.cpp.


Constructor & Destructor Documentation

CMacros::CMacros ( ) [inline]

Definition at line 120 of file htmlgen.cpp.

                  {
          mCount=0;
          mFilename[0]=0;
          memset(mKeys,0,sizeof(mKeys));
          memset(mRanges,0,sizeof(mRanges));
          memset(mIndex,0,sizeof(mIndex));
          mBorrowedKeys=false;
        }

Here is the call graph for this function:

CMacros::CMacros ( const CMacros aCopy) [inline]

Definition at line 129 of file htmlgen.cpp.

                                      {
          mBorrowedKeys=true;
          mCount=aCopy.mCount;
          strcpy(mFilename,aCopy.mFilename);
          memcpy(mKeys,aCopy.mKeys,sizeof(mKeys));
          memcpy(mIndex,aCopy.mIndex,sizeof(mIndex));
        }

Here is the call graph for this function:

CMacros::~CMacros ( ) [inline]

Definition at line 137 of file htmlgen.cpp.

                  {
          if(!mBorrowedKeys) {
            for(int i=0;i<mCount;i++){
              delete [] mKeys[i];
              mKeys[i]=0;
            }
          }
        }

Member Function Documentation

bool CMacros::addMacro ( char *  aString) [inline]

Definition at line 146 of file htmlgen.cpp.

                                {
    
          //copy a macro name...
          //start by stripping off the macro key (everything up to the equal sign...
          if(aString){
            int sLen=strlen(aString);
            if(sLen>0){
              if((strchr(aString,',')) || (strchr(aString,'-'))) {
                mRanges[mCount]=new char[sLen+1];
                strcpy(mRanges[mCount++],aString);
              }
              else {
                mKeys[mCount]=new char[sLen+1];
                strcpy(mKeys[mCount++],aString);
              }
              return true;
            }
          }
          return false;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

void CMacros::buildArgBuffer ( char *  aBuffer) [inline]

Definition at line 302 of file htmlgen.cpp.

                                      {
          aBuffer[0]=0;
          if(mFilename[0]) {
            sprintf(aBuffer,"-o %s -f %s ",gThisFile,mFilename);
          }
          for(int i=0;i<mCount;i++){
            if(mKeys[i]) {
              strcat(aBuffer,mKeys[i]);
              strcat(aBuffer," ");
            }
          }
        }
bool CMacros::consume ( istrstream &  aStream) [inline]

gess12/23/98

Parameters:
@return

Definition at line 271 of file htmlgen.cpp.

                                    {
          char theBuffer[100];
          bool readDefs=false; 

          while(!aStream.eof()){
            aStream >> theBuffer;
            if(!stricmp(theBuffer,"-F")){
              //copy the filename...
              aStream >> theBuffer;
              strcpy(mFilename,theBuffer);
              readDefs=false;
            }
#if 0
            else if(!stricmp(theBuffer,"-D")){
              readDefs=true;
            }
#endif
            else if(!stricmp(theBuffer,"-O")){
              aStream >> theBuffer;
              readDefs=false;
            }
            else {
              if(theBuffer[0]){
                addMacro(theBuffer);
                theBuffer[0]=0;
              }
            }
          }
          return true;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

void CMacros::dump ( void  ) [inline]

Definition at line 315 of file htmlgen.cpp.

                   {
          for(int i=0;i<mCount;i++){
            cout << mKeys[i] << " ";
          }
          cout << endl;
        }

Here is the caller graph for this function:

bool CMacros::first ( void  ) [inline]

Definition at line 219 of file htmlgen.cpp.

                    {
          bool result=true;
          for(int i=0;i<mCount;i++){
            mIndex[i]=0;
            if(mRanges[i]){
              char* key=getRangeValueAt(mRanges[i],mIndex[i]);
              if(key) {
                if(!mKeys[i])
                  mKeys[i]=new char[100];
                strcpy(mKeys[i],key);
              }
            }
            //otherwise key is already set...
          }
          sprintf(gThisFile,"out%i.html",gFileIndex++);
          sprintf(gNextFile,"out%i.html",gFileIndex);
          return result;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

int CMacros::getCount ( ) [inline]

Definition at line 167 of file htmlgen.cpp.

{return mCount;}
char* CMacros::getFilename ( void  ) [inline]

Definition at line 175 of file htmlgen.cpp.

{return mFilename;}

Here is the caller graph for this function:

char* CMacros::getMacro ( int  anIndex) [inline]

Definition at line 169 of file htmlgen.cpp.

                              {
          if(anIndex<mCount)
            return mKeys[anIndex];
          return 0;
        }

Here is the caller graph for this function:

char* CMacros::getRangeValueAt ( char *  aRange,
int  aRangeIndex 
) [inline]

Definition at line 177 of file htmlgen.cpp.

                                                      {
          static char theBuffer[100];
          char* result=0;
          char* p1=aRange;
          char* p2=0;
          int   offset=0;
          int   count=-1;
            
          theBuffer[0]=0;
          if(p2=strchr(&aRange[offset],',')) {
              //in this case, our keys are taken 1 at a time from the range itself.
            while((++count<aRangeIndex) && (p1) && (p2)) {  
              p1=p2+1;
              p2=strchr(p1,',');
            }
            if(p1 && (count==aRangeIndex)) {
              strncat(theBuffer,p1,p2-p1);
            }
            result=theBuffer;
          }
          else if(p2=strchr(&aRange[offset],'-')) {
              //in this case, our keys are computed based on HTMLTags within the given range (exclusive).
            strncat(theBuffer,p1,p2-p1); 
            char* tag=getNthTagAfter(aRangeIndex,theBuffer);
            p2++; //p2 now points at the last item...
            if(tag){
              int end=findNearestTag(p2);
              char* endTag=tagTable[end];
              if(endTag){
                int icmp=stricmp(tag,endTag);
                if(icmp<=0){
                  strcpy(theBuffer,tag);
                }
                else theBuffer[0]=0;
                result=theBuffer;
              }
              else result=0;
            }
          }
          return result;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

bool CMacros::next ( void  ) [inline]

Definition at line 238 of file htmlgen.cpp.

                   {

          //the trick here is to find the rightmost range and increment it.
          //if it wraps, then reset it to 0, and increment the next range to the left.
          int rangeIndex=mCount;
          bool done=false;
          while((0<=--rangeIndex) && (!done)) {
            if(mRanges[rangeIndex]) {
              //ok, now we know the right most range object.
              //let's see if it can be incremented...
              char* key=getRangeValueAt(mRanges[rangeIndex],++mIndex[rangeIndex]);
              if((0==key)  || (0==key[0])){
                mIndex[rangeIndex]=0;
                char* key=getRangeValueAt(mRanges[rangeIndex],mIndex[rangeIndex]);
              }//if
              else done=true;
              mKeys[rangeIndex][0]=0;
              if(key)
                strcpy(mKeys[rangeIndex],key);
            }//if
          }//while
          strcpy(gPrevFile,gThisFile);
          sprintf(gThisFile,"out%i.html",gFileIndex++);
          sprintf(gNextFile,"out%i.html",gFileIndex);
          return done;
        }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 328 of file htmlgen.cpp.

int CMacros::mCount [protected]

Definition at line 323 of file htmlgen.cpp.

char CMacros::mFilename[125] [protected]

Definition at line 327 of file htmlgen.cpp.

int CMacros::mIndex[100] [protected]

Definition at line 326 of file htmlgen.cpp.

char* CMacros::mKeys[100] [protected]

Definition at line 324 of file htmlgen.cpp.

char* CMacros::mRanges[100] [protected]

Definition at line 325 of file htmlgen.cpp.


The documentation for this class was generated from the following file: