nsScanner Class Reference

#include <nsScanner.h>

Inheritance diagram for nsScanner:

Inheritance graph
[legend]
Collaboration diagram for nsScanner:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsScanner (const nsAString &anHTMLString, const nsACString &aCharset, PRInt32 aSource)
 Use this constructor if you want i/o to be based on a single string you hand in during construction.
 nsScanner (nsString &aFilename, PRBool aCreateStream, const nsACString &aCharset, PRInt32 aSource)
 Use this constructor if you want i/o to be based on a file (therefore a stream) or just data you provide via Append().
 ~nsScanner ()
 default destructor
nsresult GetChar (PRUnichar &ch)
 retrieve next char from internal input stream
nsresult Peek (PRUnichar &ch, PRUint32 aOffset=0)
 peek ahead to consume next char from scanner's internal input buffer
nsresult Peek (nsAString &aStr, PRInt32 aNumChars, PRInt32 aOffset=0)
nsresult SkipOver (PRUnichar aSkipChar)
 Skip over chars as long as they equal given char.
nsresult SkipWhitespace (PRInt32 &aNewlinesSkipped)
 Skip whitespace on scanner input stream.
nsresult ReadTagIdentifier (nsScannerSharedSubstring &aString)
 Consume characters until you run into space, a '<', a '>', or a '/'.
nsresult ReadEntityIdentifier (nsString &aString)
 Consume characters until you run into a char that's not valid in an entity name.
nsresult ReadNumber (nsString &aString, PRInt32 aBase)
 Consume digits.
nsresult ReadWhitespace (nsScannerSharedSubstring &aString, PRInt32 &aNewlinesSkipped, PRBool &aHaveCR)
 Consume characters until you find the terminal char.
nsresult ReadWhitespace (nsScannerIterator &aStart, nsScannerIterator &aEnd, PRInt32 &aNewlinesSkipped)
nsresult ReadUntil (nsAString &aString, PRUnichar aTerminal, PRBool addTerminal)
 Consume characters until you find the terminal char.
nsresult ReadUntil (nsAString &aString, const nsReadEndCondition &aEndCondition, PRBool addTerminal)
 Consume characters until you find one contained in given terminal set.
nsresult ReadUntil (nsScannerSharedSubstring &aString, const nsReadEndCondition &aEndCondition, PRBool addTerminal)
nsresult ReadUntil (nsScannerIterator &aStart, nsScannerIterator &aEnd, const nsReadEndCondition &aEndCondition, PRBool addTerminal)
void Mark (void)
 Records current offset position in input stream.
void RewindToMark (void)
 Resets current offset position of input stream to marked position.
PRBool UngetReadable (const nsAString &aBuffer)
 harishd 01/12/99
nsresult Append (const nsAString &aBuffer)
 gess 5/13/98
nsresult Append (const char *aBuffer, PRUint32 aLen, nsIRequest *aRequest)
 gess 5/21/98
void CopyUnusedData (nsString &aCopyBuffer)
 Call this to copy bytes out of the scanner that have not yet been consumed by the tokenization process.
nsStringGetFilename (void)
 Retrieve the name of the file that the scanner is reading from.
nsresult SetDocumentCharset (const nsACString &aCharset, PRInt32 aSource)
 Use this setter to change the scanner's unicode decoder.
void BindSubstring (nsScannerSubstring &aSubstring, const nsScannerIterator &aStart, const nsScannerIterator &aEnd)
void CurrentPosition (nsScannerIterator &aPosition)
void EndReading (nsScannerIterator &aPosition)
void SetPosition (nsScannerIterator &aPosition, PRBool aTruncate=PR_FALSE, PRBool aReverse=PR_FALSE)
void ReplaceCharacter (nsScannerIterator &aPosition, PRUnichar aChar)
PRBool IsIncremental (void)
 Internal method used to cause the internal buffer to be filled with data.
void SetIncremental (PRBool anIncrValue)
PRInt32 FirstNonWhitespacePosition ()
 Return the position of the first non-whitespace character.
void SetParser (nsParser *aParser)

Static Public Member Functions

static void SelfTest ()
 Conduct self test.

Protected Member Functions

void AppendToBuffer (nsScannerString::Buffer *, nsIRequest *aRequest)
void AppendToBuffer (const nsAString &aStr)

Protected Attributes

nsScannerStringmSlidingBuffer
nsScannerIterator mCurrentPosition
nsScannerIterator mMarkPosition
nsScannerIterator mEndPosition
nsString mFilename
PRUint32 mCountRemaining
PRPackedBool mIncremental
PRInt32 mFirstNonWhitespacePosition
PRInt32 mCharsetSource
nsCString mCharset
nsIUnicodeDecodermUnicodeDecoder
nsParsermParser


Constructor & Destructor Documentation

nsScanner::nsScanner ( const nsAString anHTMLString,
const nsACString aCharset,
PRInt32  aSource 
)

This short cut was added for Javascript.

ftang 3/02/99

Parameters:
aCharset charset
aCharsetSource - where the charset info came from
aMode represents the parser mode (nav, other)
Returns:
This short cut was added for Javascript.

gess 5/12/98

Parameters:
aMode represents the parser mode (nav, other)
Returns:

nsScanner::nsScanner ( nsString aFilename,
PRBool  aCreateStream,
const nsACString aCharset,
PRInt32  aSource 
)

Use this constructor if you want i/o to be based on strings the scanner receives.

ftang 3/02/99

Parameters:
aCharset charset
aCharsetSource - where the charset info came from
aMode represents the parser mode (nav, other)
Returns:
If you pass a null filename, you can still provide data to the scanner via append.

gess 5/12/98

Parameters:
aFilename --
Returns:

nsScanner::~nsScanner (  ) 

gess 3/25/98

Parameters:
@return 


Member Function Documentation

nsresult nsScanner::GetChar ( PRUnichar aChar  ) 

retrieve next char from scanners internal input stream

gess 3/25/98

Parameters:
ch is the char to accept new value
Returns:
error code reflecting read status
gess 3/25/98
Parameters:
@return error code reflecting read status

nsresult nsScanner::Peek ( PRUnichar aChar,
PRUint32  aOffset = 0 
)

gess 3/25/98

Parameters:
ch is the char to accept new value
Returns:
error code reflecting read status
gess 3/25/98
Parameters:
@return 

nsresult nsScanner::Peek ( nsAString aStr,
PRInt32  aNumChars,
PRInt32  aOffset = 0 
)

nsresult nsScanner::SkipOver ( PRUnichar  aSkipChar  ) 

gess 3/25/98

Parameters:
char to be skipped
Returns:
error code
gess 3/25/98
Parameters:
@return error code

nsresult nsScanner::SkipWhitespace ( PRInt32 aNewlinesSkipped  ) 

gess 3/25/98

Returns:
error status
gess 3/25/98
Parameters:
@return error status

nsresult nsScanner::ReadTagIdentifier ( nsScannerSharedSubstring aString  ) 

Parameters:
aString - receives new data from stream
Returns:
error code

nsresult nsScanner::ReadEntityIdentifier ( nsString aString  ) 

Parameters:
aString - receives new data from stream
Returns:
error code

nsresult nsScanner::ReadNumber ( nsString aString,
PRInt32  aBase 
)

Parameters:
aString - should contain digits
Returns:
error code

nsresult nsScanner::ReadWhitespace ( nsScannerSharedSubstring aString,
PRInt32 aNewlinesSkipped,
PRBool aHaveCR 
)

gess 3/25/98

Parameters:
aString receives new data from stream
addTerminal tells us whether to append terminal to aString
Returns:
error code

nsresult nsScanner::ReadWhitespace ( nsScannerIterator aStart,
nsScannerIterator aEnd,
PRInt32 aNewlinesSkipped 
)

nsresult nsScanner::ReadUntil ( nsAString aString,
PRUnichar  aTerminalChar,
PRBool  addTerminal 
)

Consumes chars until you see the given terminalChar.

gess 3/25/98

Parameters:
aString receives new data from stream
aTerminal contains terminating char
addTerminal tells us whether to append terminal to aString
Returns:
error code
gess 3/25/98
Parameters:
@return error code

nsresult nsScanner::ReadUntil ( nsAString aString,
const nsReadEndCondition aEndCondition,
PRBool  addTerminal 
)

Consume characters until you encounter one contained in given input set.

gess 3/25/98

Parameters:
aString receives new data from stream
aTermSet contains set of terminating chars
addTerminal tells us whether to append terminal to aString
Returns:
error code
gess 3/25/98
Parameters:
aString will contain the result of this method
aTerminalSet is an ordered string that contains the set of INVALID characters
Returns:
error code

nsresult nsScanner::ReadUntil ( nsScannerSharedSubstring aString,
const nsReadEndCondition aEndCondition,
PRBool  addTerminal 
)

nsresult nsScanner::ReadUntil ( nsScannerIterator aStart,
nsScannerIterator aEnd,
const nsReadEndCondition aEndCondition,
PRBool  addTerminal 
)

void nsScanner::Mark ( void   ) 

This allows us to back up to this point if the need should arise, such as when tokenization gets interrupted.

gess 5/12/98

Parameters:
@return 
This allows us to back up to this point if the need should arise, such as when tokenization gets interrupted.

gess 7/29/98

Parameters:
@return 

void nsScanner::RewindToMark ( void   ) 

This allows us to back up to this point if the need should arise, such as when tokenization gets interrupted. NOTE: IT IS REALLY BAD FORM TO CALL RELEASE WITHOUT CALLING MARK FIRST!

gess 5/12/98

Parameters:
@return 

PRBool nsScanner::UngetReadable ( const nsAString aBuffer  ) 

Insert data to our underlying input buffer as if it were read from an input stream.

Parameters:
@return 
harishd 01/12/99
Returns:
error code

nsresult nsScanner::Append ( const nsAString aBuffer  ) 

Append data to our underlying input buffer as if it were read from an input stream.

Parameters:
@return 
gess4/3/98
Returns:
error code

nsresult nsScanner::Append ( const char aBuffer,
PRUint32  aLen,
nsIRequest aRequest 
)

Parameters:
@return 

void nsScanner::CopyUnusedData ( nsString aCopyBuffer  ) 

call this to copy bytes out of the scanner that have not yet been consumed by the tokenization process.

gess 5/12/98

Parameters:
aCopyBuffer is where the scanner buffer will be copied to
Returns:
nada

nsString & nsScanner::GetFilename ( void   ) 

In some cases, it's just a given name, because the scanner isn't really reading from a file.

gess 5/12/98

Returns:

void nsScanner::SelfTest ( void   )  [static]

Actually, selftesting for this class occurs in the parser selftest.

gess 3/25/98

Parameters:
@return 

nsresult nsScanner::SetDocumentCharset ( const nsACString aCharset,
PRInt32  aSource 
)

ftang 3/02/99

Parameters:
aCharset a normalized (alias resolved) charset name
aCharsetSource- where the charset info came from
Returns:

void nsScanner::BindSubstring ( nsScannerSubstring aSubstring,
const nsScannerIterator aStart,
const nsScannerIterator aEnd 
)

void nsScanner::CurrentPosition ( nsScannerIterator aPosition  ) 

void nsScanner::EndReading ( nsScannerIterator aPosition  ) 

void nsScanner::SetPosition ( nsScannerIterator aPosition,
PRBool  aTruncate = PR_FALSE,
PRBool  aReverse = PR_FALSE 
)

void nsScanner::ReplaceCharacter ( nsScannerIterator aPosition,
PRUnichar  aChar 
)

PRBool nsScanner::IsIncremental ( void   )  [inline]

gess4/3/98

void nsScanner::SetIncremental ( PRBool  anIncrValue  )  [inline]

PRInt32 nsScanner::FirstNonWhitespacePosition (  )  [inline]

This is only reliable before consumers start reading from this scanner.

void nsScanner::SetParser ( nsParser aParser  )  [inline]

void nsScanner::AppendToBuffer ( nsScannerString::Buffer aBuf,
nsIRequest aRequest 
) [protected]

void nsScanner::AppendToBuffer ( const nsAString aStr  )  [inline, protected]


Member Data Documentation


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

Generated Mozilla by doxygen 1.5.6