Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes
CWordTokenizer< CharT > Class Template Reference

List of all members.

Public Member Functions

 CWordTokenizer (const CharT *aBuffer, PRInt32 aStartOffset, PRInt32 aMaxOffset)
PRInt32 GetNextWord (PRBool aSkipQuotes=PR_FALSE)
PRInt32 GetLength () const

Public Attributes

PRInt32 mOffset
PRInt32 mMaxOffset
PRInt32 mLength
const CharTmBuffer
const CharTmEndBuffer

Detailed Description

template<class CharT>
class CWordTokenizer< CharT >

Definition at line 633 of file nsParser.cpp.


Constructor & Destructor Documentation

template<class CharT >
CWordTokenizer< CharT >::CWordTokenizer ( const CharT aBuffer,
PRInt32  aStartOffset,
PRInt32  aMaxOffset 
) [inline]

Definition at line 635 of file nsParser.cpp.

                                                                               {
    mLength=0;
    mOffset=aStartOffset;
    mMaxOffset=aMaxOffset;
    mBuffer=aBuffer;
    mEndBuffer=mBuffer+mMaxOffset;
  }

Member Function Documentation

template<class CharT >
PRInt32 CWordTokenizer< CharT >::GetLength ( ) const [inline]

Definition at line 741 of file nsParser.cpp.

                            {
    return mLength;
  }
template<class CharT >
PRInt32 CWordTokenizer< CharT >::GetNextWord ( PRBool  aSkipQuotes = PR_FALSE) [inline]

Definition at line 652 of file nsParser.cpp.

                                                   {
    
    if(mOffset == kNotFound) {
      return kNotFound; // Ref. bug 89732
    }

    if (mOffset >= 0) {
      const CharT *cp=mBuffer+mOffset+mLength;  //skip last word

      mLength=0;  //reset this
      mOffset=-1; //reset this        

      //now skip whitespace...

      CharT target=0;
      PRBool    done=PR_FALSE;

      while((!done) && (cp++<mEndBuffer)) {
        switch(*cp) {
          case kSpace:  case kNewLine:
          case kCR:     case kTab:
          case kEqual:
            continue;

          case kQuote:
            target=*cp;
            if (aSkipQuotes) {
              ++cp;
            }
            done=PR_TRUE;
            break;

          case kMinus:
            target=*cp;
            done=PR_TRUE;
            break;

          default:
            done=PR_TRUE;
            break;
        }
      }

      if(cp<mEndBuffer) {  

        const CharT *firstcp=cp; //hang onto this...      
        PRInt32 theDashCount=2;

        ++cp; //just skip first letter to simplify processing...

        //ok, now find end of this word
        while(cp++<mEndBuffer) {
          if(kQuote==target) {
            if(kQuote==*cp) {
              ++cp;
              break; //we found our end...
            }
          }
          else if(kMinus==target) {
            //then let's look for SGML comments
            if(kMinus==*cp) {
              if(4==++theDashCount) {
                ++cp;
                break;
              }
            }
          }
          else {
            if((kSpace==*cp) ||
               (kNewLine==*cp) ||
               (kGreaterThan==*cp) ||
               (kQuote==*cp) ||
               (kCR==*cp) ||
               (kTab==*cp) || 
               (kEqual == *cp)) {
              break;
            }
          }
        }

        mLength=cp-firstcp;
        mOffset = (0<mLength) ? firstcp-mBuffer : -1;

      }
    }

    return mOffset;
  }

Here is the call graph for this function:


Member Data Documentation

template<class CharT >
const CharT* CWordTokenizer< CharT >::mBuffer

Definition at line 748 of file nsParser.cpp.

template<class CharT >
const CharT* CWordTokenizer< CharT >::mEndBuffer

Definition at line 749 of file nsParser.cpp.

template<class CharT >
PRInt32 CWordTokenizer< CharT >::mLength

Definition at line 747 of file nsParser.cpp.

template<class CharT >
PRInt32 CWordTokenizer< CharT >::mMaxOffset

Definition at line 746 of file nsParser.cpp.

template<class CharT >
PRInt32 CWordTokenizer< CharT >::mOffset

Definition at line 745 of file nsParser.cpp.


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