Back to index

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

nsTSubstringTuple_CharT More...

#include <nsTSubstringTuple.h>

Collaboration diagram for nsTSubstringTuple_CharT:
Collaboration graph
[legend]

List of all members.

Public Types

typedef CharT char_type
typedef nsCharTraits< char_typechar_traits
typedef nsTSubstringTuple_CharT self_type
typedef nsTSubstring_CharT substring_type
typedef nsTSubstring_CharT base_string_type
typedef PRUint32 size_type

Public Member Functions

 nsTSubstringTuple_CharT (const base_string_type *a, const base_string_type *b)
 nsTSubstringTuple_CharT (const self_type &head, const base_string_type *b)
NS_COM size_type Length () const
 computes the aggregate string length
NS_COM void WriteTo (char_type *buf, PRUint32 bufLen) const
 writes the aggregate string to the given buffer.
NS_COM PRBool IsDependentOn (const char_type *start, const char_type *end) const
 returns true if this tuple is dependent on (i.e., overlapping with) the given char sequence.

Private Attributes

const self_typemHead
const base_string_typemFragA
const base_string_typemFragB

Detailed Description

nsTSubstringTuple_CharT

Represents a tuple of string fragments. Built as a recursive binary tree. It is used to implement the concatenation of two or more string objects.

NOTE: This class is a private implementation detail and should never be referenced outside the string code.

Definition at line 49 of file nsTSubstringTuple.h.


Member Typedef Documentation

Definition at line 62 of file nsTSubstringTuple.h.

Definition at line 54 of file nsTSubstringTuple.h.

Definition at line 53 of file nsTSubstringTuple.h.

Definition at line 56 of file nsTSubstringTuple.h.

Definition at line 64 of file nsTSubstringTuple.h.

Definition at line 57 of file nsTSubstringTuple.h.


Constructor & Destructor Documentation

Definition at line 68 of file nsTSubstringTuple.h.

        : mHead(nsnull)
        , mFragA(a)
        , mFragB(b) {}

Definition at line 73 of file nsTSubstringTuple.h.

        : mHead(&head)
        , mFragA(nsnull) // this fragment is ignored when head != nsnull
        , mFragB(b) {}

Member Function Documentation

returns true if this tuple is dependent on (i.e., overlapping with) the given char sequence.

Definition at line 116 of file nsTSubstringTuple.cpp.

  {
    // we start with the right-most fragment since it is faster to check.

    if (TO_SUBSTRING(mFragB).IsDependentOn(start, end))
      return PR_TRUE;

    if (mHead)
      return mHead->IsDependentOn(start, end);

    return TO_SUBSTRING(mFragA).IsDependentOn(start, end);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

computes the aggregate string length

Definition at line 45 of file nsTSubstringTuple.cpp.

  {
    PRUint32 len;
    if (mHead)
      len = mHead->Length();
    else
      len = TO_SUBSTRING(mFragA).Length();

    return len + TO_SUBSTRING(mFragB).Length();
  }

Here is the call graph for this function:

Here is the caller graph for this function:

writes the aggregate string to the given buffer.

bufLen is assumed to be equal to or greater than the value returned by the Length() method. the string written to |buf| is not null-terminated.

Definition at line 64 of file nsTSubstringTuple.cpp.

  {
    const substring_type& b = TO_SUBSTRING(mFragB);

    NS_ASSERTION(bufLen >= b.Length(), "buffer too small");
    PRUint32 headLen = bufLen - b.Length();
    if (mHead)
      {
        mHead->WriteTo(buf, headLen);
      }
    else
      {
        const substring_type& a = TO_SUBSTRING(mFragA);

        NS_ASSERTION(a.Length() == headLen, "buffer incorrectly sized");
        char_traits::copy(buf, a.Data(), a.Length());
      }

    char_traits::copy(buf + headLen, b.Data(), b.Length());

#if 0
    // we need to write out data into |buf|, ending at |buf+bufLen|.  so our
    // data needs to precede |buf+bufLen| exactly.  we trust that the buffer
    // was properly sized!

    const substring_type& b = TO_SUBSTRING(mFragB);

    NS_ASSERTION(bufLen >= b.Length(), "buffer is too small");
    char_traits::copy(buf + bufLen - b.Length(), b.Data(), b.Length());

    bufLen -= b.Length();

    if (mHead)
      {
        mHead->WriteTo(buf, bufLen);
      }
    else
      {
        const substring_type& a = TO_SUBSTRING(mFragA);
        NS_ASSERTION(bufLen == a.Length(), "buffer is too small");
        char_traits::copy(buf, a.Data(), a.Length());
      }
#endif
  }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 99 of file nsTSubstringTuple.h.

Definition at line 100 of file nsTSubstringTuple.h.

Definition at line 98 of file nsTSubstringTuple.h.


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