Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Attributes
nsManifestLineReader Class Reference

#include <nsManifestLineReader.h>

List of all members.

Public Member Functions

 nsManifestLineReader ()
 ~nsManifestLineReader ()
void Init (char *base, PRUint32 flen)
PRBool NextLine ()
int ParseLine (char **chunks, int *lengths, int maxChunks)
char * LinePtr ()
PRUint32 LineLength ()
PRBool IsEOL (char c)

Private Attributes

char * mCur
PRUint32 mLength
char * mNext
char * mBase
char * mLimit

Detailed Description

Definition at line 44 of file nsManifestLineReader.h.


Constructor & Destructor Documentation

Definition at line 47 of file nsManifestLineReader.h.

: mBase(nsnull) {} 

Definition at line 48 of file nsManifestLineReader.h.

{}

Member Function Documentation

void nsManifestLineReader::Init ( char *  base,
PRUint32  flen 
) [inline]

Definition at line 50 of file nsManifestLineReader.h.

    {
        mBase = mCur = mNext = base; 
        mLength = 0;
        mLimit = base + flen;
    }

Here is the caller graph for this function:

PRBool nsManifestLineReader::IsEOL ( char  c) [inline]

Definition at line 112 of file nsManifestLineReader.h.

{return c == '\n' || c == '\r';}

Here is the caller graph for this function:

Definition at line 110 of file nsManifestLineReader.h.

{return mLength;}    

Here is the caller graph for this function:

char* nsManifestLineReader::LinePtr ( ) [inline]

Definition at line 109 of file nsManifestLineReader.h.

{return mCur;}    

Here is the caller graph for this function:

Definition at line 57 of file nsManifestLineReader.h.

    {
        if(mNext >= mLimit)
            return PR_FALSE;
        
        mCur = mNext;
        mLength = 0;
        
        while(mNext < mLimit)
        {
            if(IsEOL(*mNext))
            {
                *mNext = '\0';
                for(++mNext; mNext < mLimit; ++mNext)
                    if(!IsEOL(*mNext))
                        break;
                return PR_TRUE;
            }
            ++mNext;
            ++mLength;
        }
        return PR_FALSE;        
    }

Here is the call graph for this function:

Here is the caller graph for this function:

int nsManifestLineReader::ParseLine ( char **  chunks,
int lengths,
int  maxChunks 
) [inline]

Definition at line 81 of file nsManifestLineReader.h.

    {
        NS_ASSERTION(mCur && maxChunks && chunks, "bad call to ParseLine");
        int found = 0;
        chunks[found++] = mCur;

        if(found < maxChunks)
        {
            char *lastchunk = mCur;
            int *lastlength = lengths;
            for(char* cur = mCur; *cur; cur++)
            {
                if(*cur == ',')
                {
                    *cur = 0;
                    // always fill in the previous chunk's length
                    *lastlength++ = cur - lastchunk;
                    chunks[found++] = lastchunk = cur+1;
                    if(found == maxChunks)
                        break;
                }
            }
            // crazy pointer math - calculate the length of the final chunk
            *lastlength = (mCur + mLength) - lastchunk;
        }
        return found;
    }

Here is the caller graph for this function:


Member Data Documentation

char* nsManifestLineReader::mBase [private]

Definition at line 117 of file nsManifestLineReader.h.

char* nsManifestLineReader::mCur [private]

Definition at line 114 of file nsManifestLineReader.h.

Definition at line 115 of file nsManifestLineReader.h.

Definition at line 118 of file nsManifestLineReader.h.

char* nsManifestLineReader::mNext [private]

Definition at line 116 of file nsManifestLineReader.h.


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