Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends
nsScannerSubstring Class Reference

nsScannerSubstring is the base class for nsScannerString. More...

#include <nsScannerString.h>

Inheritance diagram for nsScannerSubstring:
Inheritance graph
[legend]
Collaboration diagram for nsScannerSubstring:
Collaboration graph
[legend]

List of all members.

Public Types

typedef nsScannerBufferList::Buffer Buffer
typedef
nsScannerBufferList::Position 
Position
typedef PRUint32 size_type

Public Member Functions

 nsScannerSubstring ()
 nsScannerSubstring
 nsScannerSubstring (const nsAString &s)
 ~nsScannerSubstring ()
nsScannerIteratorBeginReading (nsScannerIterator &iter) const
nsScannerIteratorEndReading (nsScannerIterator &iter) const
size_type Length () const
PRInt32 CountChar (PRUnichar) const
void Rebind (const nsScannerSubstring &, const nsScannerIterator &, const nsScannerIterator &)
void Rebind (const nsAString &)
const nsSubstringAsString () const
PRBool GetNextFragment (nsScannerFragment &) const
PRBool GetPrevFragment (nsScannerFragment &) const

Static Public Member Functions

static BufferAllocBufferFromString (const nsAString &aStr)
static BufferAllocBuffer (size_type aCapacity)

Protected Member Functions

void acquire_ownership_of_buffer_list () const
void release_ownership_of_buffer_list ()
void init_range_from_buffer_list ()

Protected Attributes

Position mStart
Position mEnd
nsScannerBufferListmBufferList
size_type mLength
nsDependentSubstring mFlattenedRep
PRBool mIsDirty

Friends

class nsScannerSharedSubstring

Detailed Description

nsScannerSubstring is the base class for nsScannerString.

It provides access to iterators and methods to bind the substring to another substring or nsAString instance.

This class owns the buffer list.

Definition at line 211 of file nsScannerString.h.


Member Typedef Documentation

Definition at line 214 of file nsScannerString.h.

Definition at line 215 of file nsScannerString.h.

Definition at line 216 of file nsScannerString.h.


Constructor & Destructor Documentation

Definition at line 173 of file nsScannerString.cpp.

Here is the call graph for this function:

Definition at line 180 of file nsScannerString.cpp.

Here is the call graph for this function:


Member Function Documentation

Definition at line 243 of file nsScannerString.h.

Here is the call graph for this function:

Here is the caller graph for this function:

static Buffer* nsScannerSubstring::AllocBuffer ( size_type  aCapacity) [inline, static]

Definition at line 239 of file nsScannerString.h.

{ return nsScannerBufferList::AllocBuffer(aCapacity); }

Here is the caller graph for this function:

static Buffer* nsScannerSubstring::AllocBufferFromString ( const nsAString &  aStr) [inline, static]

Definition at line 238 of file nsScannerString.h.

Here is the caller graph for this function:

Definition at line 239 of file nsScannerString.cpp.

  {
    if (mIsDirty)
      {
        nsScannerSubstring* mutable_this = NS_CONST_CAST(nsScannerSubstring*, this);

        if (mStart.mBuffer == mEnd.mBuffer) {
          // We only have a single fragment to deal with, so just return it
          // as a substring.
          mutable_this->mFlattenedRep.Rebind(mStart.mPosition, mEnd.mPosition);
        } else {
          // Otherwise, we need to copy the data into a flattened buffer.
          nsScannerIterator start, end;
          CopyUnicodeTo(BeginReading(start), EndReading(end), mutable_this->mFlattenedRep);
        }

        mutable_this->mIsDirty = PR_FALSE;
      }

    return mFlattenedRep;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 262 of file nsScannerString.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 186 of file nsScannerString.cpp.

  {
      /*
        re-write this to use a counting sink
       */

    size_type result = 0;
    size_type lengthToExamine = Length();

    nsScannerIterator iter;
    for ( BeginReading(iter); ; )
      {
        PRInt32 lengthToExamineInThisFragment = iter.size_forward();
        const PRUnichar* fromBegin = iter.get();
        result += size_type(NS_COUNT(fromBegin, fromBegin+lengthToExamineInThisFragment, c));
        if ( !(lengthToExamine -= lengthToExamineInThisFragment) )
          return result;
        iter.advance(lengthToExamineInThisFragment);
      }
      // never reached; quiets warnings
    return 0;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 279 of file nsScannerString.cpp.

  {
    iter.mOwner = this;

    iter.mFragment.mBuffer = mEnd.mBuffer;
    iter.mFragment.mFragmentEnd = mEnd.mPosition;
    if (mStart.mBuffer == mEnd.mBuffer)
      iter.mFragment.mFragmentStart = mStart.mPosition;
    else
      iter.mFragment.mFragmentStart = mEnd.mBuffer->DataStart();

    iter.mPosition = mEnd.mPosition;
    // must not |normalize_backward| as that would likely invalidate tests like |while ( first != last )|
    return iter;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 296 of file nsScannerString.cpp.

  {
    // check to see if we are at the end of the buffer list
    if (frag.mBuffer == mEnd.mBuffer)
      return PR_FALSE;

    frag.mBuffer = NS_STATIC_CAST(const Buffer*, PR_NEXT_LINK(frag.mBuffer));

    if (frag.mBuffer == mStart.mBuffer)
      frag.mFragmentStart = mStart.mPosition;
    else
      frag.mFragmentStart = frag.mBuffer->DataStart();

    if (frag.mBuffer == mEnd.mBuffer)
      frag.mFragmentEnd = mEnd.mPosition;
    else
      frag.mFragmentEnd = frag.mBuffer->DataEnd();

    return PR_TRUE;
  }

Here is the call graph for this function:

Definition at line 318 of file nsScannerString.cpp.

  {
    // check to see if we are at the beginning of the buffer list
    if (frag.mBuffer == mStart.mBuffer)
      return PR_FALSE;

    frag.mBuffer = NS_STATIC_CAST(const Buffer*, PR_PREV_LINK(frag.mBuffer));

    if (frag.mBuffer == mStart.mBuffer)
      frag.mFragmentStart = mStart.mPosition;
    else
      frag.mFragmentStart = frag.mBuffer->DataStart();

    if (frag.mBuffer == mEnd.mBuffer)
      frag.mFragmentEnd = mEnd.mPosition;
    else
      frag.mFragmentEnd = frag.mBuffer->DataEnd();

    return PR_TRUE;
  }

Here is the call graph for this function:

Definition at line 259 of file nsScannerString.h.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 226 of file nsScannerString.h.

{ return mLength; }

Here is the caller graph for this function:

Definition at line 210 of file nsScannerString.cpp.

  {
    // allow for the case where &aString == this

    aString.acquire_ownership_of_buffer_list();
    release_ownership_of_buffer_list();

    mStart      = aStart;
    mEnd        = aEnd;
    mBufferList = aString.mBufferList;
    mLength     = Distance(aStart, aEnd);
    mIsDirty    = PR_TRUE;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void nsScannerSubstring::Rebind ( const nsAString &  aString)

Definition at line 249 of file nsScannerString.h.

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class nsScannerSharedSubstring [friend]

Definition at line 279 of file nsScannerString.h.


Member Data Documentation

Definition at line 272 of file nsScannerString.h.

Definition at line 271 of file nsScannerString.h.

Definition at line 276 of file nsScannerString.h.

Definition at line 277 of file nsScannerString.h.

Definition at line 273 of file nsScannerString.h.

Definition at line 270 of file nsScannerString.h.


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