Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions | Private Attributes
CopyNormalizeNewlines< OutputIterator > Class Template Reference

List of all members.

Public Types

typedef OutputIterator::value_type value_type

Public Member Functions

 CopyNormalizeNewlines (OutputIterator *aDestination, PRBool aLastCharCR=PR_FALSE)
PRUint32 GetCharsWritten ()
PRBool IsLastCharCR ()
PRUint32 write (const typename OutputIterator::value_type *aSource, PRUint32 aSourceLength)

Private Attributes

PRBool mLastCharCR
OutputIterator * mDestination
PRUint32 mWritten

Detailed Description

template<class OutputIterator>
class CopyNormalizeNewlines< OutputIterator >

Definition at line 315 of file nsContentUtils.cpp.


Member Typedef Documentation

template<class OutputIterator>
typedef OutputIterator::value_type CopyNormalizeNewlines< OutputIterator >::value_type

Definition at line 318 of file nsContentUtils.cpp.


Constructor & Destructor Documentation

template<class OutputIterator>
CopyNormalizeNewlines< OutputIterator >::CopyNormalizeNewlines ( OutputIterator *  aDestination,
PRBool  aLastCharCR = PR_FALSE 
) [inline]

Definition at line 321 of file nsContentUtils.cpp.

                                                       :
      mLastCharCR(aLastCharCR),
      mDestination(aDestination),
      mWritten(0)
    { }

Member Function Documentation

template<class OutputIterator>
PRUint32 CopyNormalizeNewlines< OutputIterator >::GetCharsWritten ( ) [inline]

Definition at line 328 of file nsContentUtils.cpp.

                               {
      return mWritten;
    }

Here is the caller graph for this function:

template<class OutputIterator>
PRBool CopyNormalizeNewlines< OutputIterator >::IsLastCharCR ( ) [inline]

Definition at line 332 of file nsContentUtils.cpp.

                          {
      return mLastCharCR;
    }

Here is the caller graph for this function:

template<class OutputIterator>
PRUint32 CopyNormalizeNewlines< OutputIterator >::write ( const typename OutputIterator::value_type *  aSource,
PRUint32  aSourceLength 
) [inline]

Definition at line 336 of file nsContentUtils.cpp.

                                                                                             {

      const typename OutputIterator::value_type* done_writing = aSource + aSourceLength;

      // If the last source buffer ended with a CR...
      if (mLastCharCR) {
        // ..and if the next one is a LF, then skip it since
        // we've already written out a newline
        if (aSourceLength && (*aSource == value_type('\n'))) {
          ++aSource;
        }
        mLastCharCR = PR_FALSE;
      }

      PRUint32 num_written = 0;
      while ( aSource < done_writing ) {
        if (*aSource == value_type('\r')) {
          mDestination->writechar('\n');
          ++aSource;
          // If we've reached the end of the buffer, record
          // that we wrote out a CR
          if (aSource == done_writing) {
            mLastCharCR = PR_TRUE;
          }
          // If the next character is a LF, skip it
          else if (*aSource == value_type('\n')) {
            ++aSource;
          }
        }
        else {
          mDestination->writechar(*aSource++);
        }
        ++num_written;
      }

      mWritten += num_written;
      return aSourceLength;
    }

Member Data Documentation

template<class OutputIterator>
OutputIterator* CopyNormalizeNewlines< OutputIterator >::mDestination [private]

Definition at line 377 of file nsContentUtils.cpp.

template<class OutputIterator>
PRBool CopyNormalizeNewlines< OutputIterator >::mLastCharCR [private]

Definition at line 376 of file nsContentUtils.cpp.

template<class OutputIterator>
PRUint32 CopyNormalizeNewlines< OutputIterator >::mWritten [private]

Definition at line 378 of file nsContentUtils.cpp.


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