improved documentation in headers
git-svn-id: svn://10.0.0.236/trunk@304 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -247,6 +247,28 @@ CHTMLToken::CHTMLToken(const nsString& aName) : CToken(aName) {
|
||||
mTagType=eHTMLTag_unknown;
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
eHTMLTags CHTMLToken::GetHTMLTag() {
|
||||
return mTagType;
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
void CHTMLToken::SetHTMLTag(eHTMLTags aTagType) {
|
||||
mTagType=aTagType;
|
||||
return;
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
* default constructor
|
||||
@@ -272,6 +294,50 @@ eHTMLTags CStartToken::GetHTMLTag(){
|
||||
return mTagType;
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
const char* CStartToken::GetClassName(void) {
|
||||
return "start";
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
PRInt32 CStartToken::GetTokenType(void) {
|
||||
return eToken_start;
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
void CStartToken::SetAttributed(PRBool aValue) {
|
||||
mAttributed=aValue;
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
PRBool CStartToken::IsAttributed(void) {
|
||||
return mAttributed;
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
* Consume the identifier portion of the start tag
|
||||
*
|
||||
@@ -376,6 +442,27 @@ eHTMLTags CEndToken::GetHTMLTag(){
|
||||
return mTagType;
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
const char* CEndToken::GetClassName(void) {
|
||||
return "/end";
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
PRInt32 CEndToken::GetTokenType(void) {
|
||||
return eToken_end;
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
* Dump contents of this token to givne output stream
|
||||
@@ -402,6 +489,28 @@ CTextToken::CTextToken(const nsString& aName) : CHTMLToken(aName) {
|
||||
mOrdinalValue=eToken_text;
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
const char* CTextToken::GetClassName(void) {
|
||||
return "text";
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
PRInt32 CTextToken::GetTokenType(void) {
|
||||
return eToken_text;
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
* Consume as much clear text from scanner as possible.
|
||||
*
|
||||
@@ -483,11 +592,28 @@ PRInt32 CCommentToken::Consume(PRUnichar aChar, CScanner* aScanner) {
|
||||
return result;
|
||||
};
|
||||
|
||||
const char* CCommentToken::GetClassName(void)
|
||||
{
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
const char* CCommentToken::GetClassName(void){
|
||||
return "/**/";
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
PRInt32 CCommentToken::GetTokenType(void) {
|
||||
return eToken_comment;
|
||||
}
|
||||
|
||||
#ifdef TOKENIZE_CRLF
|
||||
/**-------------------------------------------------------
|
||||
* default constructor
|
||||
@@ -500,6 +626,28 @@ CNewlineToken::CNewlineToken(const nsString& aName) : CHTMLToken(aName) {
|
||||
mOrdinalValue=eToken_newline;
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
const char* CNewlineToken::GetClassName(void) {
|
||||
return "crlf";
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
PRInt32 CNewlineToken::GetTokenType(void) {
|
||||
return eToken_newline;
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
* Consume as many cr/lf pairs as you can find.
|
||||
*
|
||||
@@ -535,6 +683,28 @@ CAttributeToken::CAttributeToken(const nsString& aName) : CHTMLToken(aName),
|
||||
mOrdinalValue=eToken_attribute;
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
const char* CAttributeToken::GetClassName(void) {
|
||||
return "attr";
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
PRInt32 CAttributeToken::GetTokenType(void) {
|
||||
return eToken_attribute;
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
* Dump contents of this token to givne output stream
|
||||
*
|
||||
@@ -698,6 +868,28 @@ CWhitespaceToken::CWhitespaceToken(const nsString& aName) : CHTMLToken(aName) {
|
||||
mOrdinalValue=eToken_whitespace;
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
const char* CWhitespaceToken::GetClassName(void) {
|
||||
return "ws";
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
PRInt32 CWhitespaceToken::GetTokenType(void) {
|
||||
return eToken_whitespace;
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
* This general purpose method is used when you want to
|
||||
* consume an aribrary sequence of whitespace.
|
||||
@@ -754,6 +946,28 @@ PRInt32 CEntityToken::Consume(PRUnichar aChar, CScanner* aScanner) {
|
||||
return result;
|
||||
};
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
const char* CEntityToken::GetClassName(void) {
|
||||
return "&entity";
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
PRInt32 CEntityToken::GetTokenType(void) {
|
||||
return eToken_entity;
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
* This general purpose method is used when you want to
|
||||
* consume an entity &xxxx;. Keep in mind that entities
|
||||
@@ -919,6 +1133,50 @@ void CEntityToken::DebugDumpSource(ostream& out) {
|
||||
delete cp;
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
const char* CScriptToken::GetClassName(void) {
|
||||
return "script";
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
PRInt32 CScriptToken::GetTokenType(void) {
|
||||
return eToken_script;
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
const char* CStyleToken::GetClassName(void) {
|
||||
return "style";
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
PRInt32 CStyleToken::GetTokenType(void) {
|
||||
return eToken_style;
|
||||
}
|
||||
|
||||
|
||||
/**-------------------------------------------------------
|
||||
* default constructor
|
||||
@@ -932,6 +1190,28 @@ CSkippedContentToken::CSkippedContentToken(const nsString& aName) : CAttributeTo
|
||||
mOrdinalValue=eToken_skippedcontent;
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
const char* CSkippedContentToken::GetClassName(void) {
|
||||
return "skipped";
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
PRInt32 CSkippedContentToken::GetTokenType(void) {
|
||||
return eToken_skippedcontent;
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
* Consume content until you find a sequence that matches
|
||||
* this objects mTextValue.
|
||||
|
||||
@@ -113,59 +113,94 @@ eHTMLTags DetermineHTMLTagType(const nsString& aString);
|
||||
eHTMLTokenTypes DetermineTokenType(const nsString& aString);
|
||||
|
||||
|
||||
/** -----------------------------------------------------
|
||||
* This declares the basic token type used in the html-
|
||||
* parser.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
*/ //---------------------------------------------------
|
||||
class CHTMLToken : public CToken {
|
||||
public:
|
||||
public:
|
||||
CHTMLToken(const nsString& aString);
|
||||
virtual eHTMLTags GetHTMLTag() {return mTagType;}
|
||||
void SetHTMLTag(eHTMLTags aTagType) {mTagType=aTagType; return;}
|
||||
protected:
|
||||
virtual eHTMLTags GetHTMLTag();
|
||||
void SetHTMLTag(eHTMLTags aTagType);
|
||||
protected:
|
||||
eHTMLTags mTagType;
|
||||
};
|
||||
|
||||
|
||||
/** -----------------------------------------------------
|
||||
* This declares start tokens, which always take the
|
||||
* form <xxxx>. This class also knows how to consume
|
||||
* related attributes.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
*/ //---------------------------------------------------
|
||||
class CStartToken: public CHTMLToken {
|
||||
public:
|
||||
CStartToken(const nsString& aString);
|
||||
virtual PRInt32 Consume(PRUnichar aChar,CScanner* aScanner);
|
||||
virtual const char* GetClassName(void) {return "start";}
|
||||
virtual PRInt32 GetTokenType(void) {return eToken_start;}
|
||||
virtual eHTMLTags GetHTMLTag();
|
||||
void SetAttributed(PRBool aValue) {mAttributed=aValue;}
|
||||
PRBool IsAttributed(void) {return mAttributed;}
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
void SetAttributed(PRBool aValue);
|
||||
PRBool IsAttributed(void);
|
||||
virtual void DebugDumpSource(ostream& out);
|
||||
|
||||
protected:
|
||||
PRBool mAttributed;
|
||||
PRBool mAttributed;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/** -----------------------------------------------------
|
||||
* This declares end tokens, which always take the
|
||||
* form </xxxx>. This class also knows how to consume
|
||||
* related attributes.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
*/ //---------------------------------------------------
|
||||
class CEndToken: public CHTMLToken {
|
||||
public:
|
||||
CEndToken(const nsString& aString);
|
||||
virtual PRInt32 Consume(PRUnichar aChar,CScanner* aScanner);
|
||||
virtual const char* GetClassName(void) {return "/end";}
|
||||
virtual PRInt32 GetTokenType(void) {return eToken_end;}
|
||||
virtual eHTMLTags GetHTMLTag();
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual void DebugDumpSource(ostream& out);
|
||||
};
|
||||
|
||||
|
||||
/** -----------------------------------------------------
|
||||
* This declares comment tokens. Comments are usually
|
||||
* thought of as tokens, but we treat them that way
|
||||
* here so that the parser can have a consistent view
|
||||
* of all tokens.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
*/ //---------------------------------------------------
|
||||
class CCommentToken: public CHTMLToken {
|
||||
public:
|
||||
CCommentToken(const nsString& aString);
|
||||
virtual PRInt32 Consume(PRUnichar aChar,CScanner* aScanner);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void) {return eToken_comment;}
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
char mLeadingChar;
|
||||
};
|
||||
|
||||
|
||||
/** -----------------------------------------------------
|
||||
* This class declares entity tokens, which always take
|
||||
* the form &xxxx;. This class also offers a few utility
|
||||
* methods that allow you to easily reduce entities.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
*/ //---------------------------------------------------
|
||||
class CEntityToken : public CHTMLToken {
|
||||
public:
|
||||
CEntityToken(const nsString& aString);
|
||||
virtual const char* GetClassName(void) {return "entity";}
|
||||
virtual PRInt32 GetTokenType(void) {return eToken_entity;}
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
PRInt32 TranslateToUnicode(void);
|
||||
virtual PRInt32 Consume(PRUnichar aChar,CScanner* aScanner);
|
||||
static PRInt32 ConsumeEntity(PRUnichar aChar,nsString& aString,CScanner* aScanner);
|
||||
@@ -180,31 +215,53 @@ class CEntityToken : public CHTMLToken {
|
||||
};
|
||||
|
||||
|
||||
/** -----------------------------------------------------
|
||||
* Whitespace tokens are used where whitespace can be
|
||||
* detected as distinct from text. This allows us to
|
||||
* easily skip leading/trailing whitespace when desired.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
*/ //---------------------------------------------------
|
||||
#ifdef TOKENIZE_WHITESPACE
|
||||
class CWhitespaceToken: public CHTMLToken {
|
||||
public:
|
||||
CWhitespaceToken(const nsString& aString);
|
||||
virtual PRInt32 Consume(PRUnichar aChar,CScanner* aScanner);
|
||||
virtual const char* GetClassName(void) {return "ws";}
|
||||
virtual PRInt32 GetTokenType(void) {return eToken_whitespace;}
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
};
|
||||
#endif
|
||||
|
||||
/** -----------------------------------------------------
|
||||
* Text tokens contain the normalized form of html text.
|
||||
* These tokens are guaranteed not to contain entities,
|
||||
* start or end tags, or newlines.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
*/ //---------------------------------------------------
|
||||
class CTextToken: public CHTMLToken {
|
||||
public:
|
||||
CTextToken(const nsString& aString);
|
||||
virtual PRInt32 Consume(PRUnichar aChar,CScanner* aScanner);
|
||||
virtual const char* GetClassName(void) {return "text";}
|
||||
virtual PRInt32 GetTokenType(void) {return eToken_text;}
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
};
|
||||
|
||||
|
||||
/** -----------------------------------------------------
|
||||
* Attribute tokens are used to contain attribute key/value
|
||||
* pairs whereever they may occur. Typically, they should
|
||||
* occur only in start tokens. However, we may expand that
|
||||
* ability when XML tokens become commonplace.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
*/ //---------------------------------------------------
|
||||
class CAttributeToken: public CHTMLToken {
|
||||
public:
|
||||
CAttributeToken(const nsString& aString);
|
||||
virtual PRInt32 Consume(PRUnichar aChar,CScanner* aScanner);
|
||||
virtual const char* GetClassName(void) {return "attr";}
|
||||
virtual PRInt32 GetTokenType(void) {return eToken_attribute;}
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual nsString& GetKey(void) {return mTextKey;}
|
||||
virtual void DebugDumpToken(ostream& out);
|
||||
virtual void DebugDumpSource(ostream& out);
|
||||
@@ -215,44 +272,71 @@ class CAttributeToken: public CHTMLToken {
|
||||
};
|
||||
|
||||
|
||||
/** -----------------------------------------------------
|
||||
* Newline tokens contain, you guessed it, newlines.
|
||||
* They consume newline (CR/LF) either alone or in pairs.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
*/ //---------------------------------------------------
|
||||
#ifdef TOKENIZE_CRLF
|
||||
class CNewlineToken: public CHTMLToken {
|
||||
public:
|
||||
CNewlineToken(const nsString& aString);
|
||||
virtual PRInt32 Consume(PRUnichar aChar,CScanner* aScanner);
|
||||
virtual const char* GetClassName(void) {return "crlf";}
|
||||
virtual PRInt32 GetTokenType(void) {return eToken_newline;}
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
/** -----------------------------------------------------
|
||||
* Script tokens contain sequences of javascript (or, gulp,
|
||||
* any other script you care to send). We don't tokenize
|
||||
* it here, nor validate it. We just wrap it up, and pass
|
||||
* it along to the html parser, who sends it (later on)
|
||||
* to the scripting engine.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
*/ //---------------------------------------------------
|
||||
class CScriptToken: public CHTMLToken {
|
||||
public:
|
||||
|
||||
CScriptToken(const nsString& aString);
|
||||
virtual const char* GetClassName(void) {return "script";}
|
||||
virtual PRInt32 GetTokenType(void) {return eToken_script;}
|
||||
virtual void DebugDumpSource(ostream& out) {CToken::DebugDumpSource(out);}
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
protected:
|
||||
};
|
||||
|
||||
|
||||
/** -----------------------------------------------------
|
||||
* Style tokens contain sequences of css style. We don't
|
||||
* tokenize it here, nor validate it. We just wrap it up,
|
||||
* and pass it along to the html parser, who sends it
|
||||
* (later on) to the style engine.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
*/ //---------------------------------------------------
|
||||
class CStyleToken: public CHTMLToken {
|
||||
public:
|
||||
CStyleToken(const nsString& aString);
|
||||
virtual const char* GetClassName(void) {return "style";}
|
||||
virtual PRInt32 GetTokenType(void) {return eToken_style;}
|
||||
virtual void DebugDumpSource(ostream& out) {CToken::DebugDumpSource(out);}
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
protected:
|
||||
};
|
||||
|
||||
|
||||
/** -----------------------------------------------------
|
||||
* This is a placeholder token, which is being deprecated.
|
||||
* Don't bother paying attention to this.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
*/ //---------------------------------------------------
|
||||
class CSkippedContentToken: public CAttributeToken {
|
||||
public:
|
||||
CSkippedContentToken(const nsString& aString);
|
||||
virtual PRInt32 Consume(PRUnichar aChar,CScanner* aScanner);
|
||||
virtual const char* GetClassName(void) {return "skipped";}
|
||||
virtual PRInt32 GetTokenType(void) {return eToken_skippedcontent;}
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
protected:
|
||||
};
|
||||
|
||||
|
||||
@@ -41,6 +41,12 @@
|
||||
|
||||
class nsIContentSink;
|
||||
|
||||
/**-------------------------------------------------------
|
||||
* This class defines the iparser interface. This XPCOM
|
||||
* inteface is all that parser clients ever need to see.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
*------------------------------------------------------*/
|
||||
class nsIParser : public nsISupports {
|
||||
|
||||
public:
|
||||
|
||||
@@ -40,6 +40,14 @@
|
||||
#include "nsString.h"
|
||||
#include "nsDebug.h"
|
||||
|
||||
/**-------------------------------------------------------
|
||||
* Parser nodes are the unit of exchange between the
|
||||
* parser and the content sink. Nodes offer access to
|
||||
* the current token, its attributes, and its skipped-
|
||||
* content if applicable.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
*------------------------------------------------------*/
|
||||
class nsIParserNode {
|
||||
|
||||
public:
|
||||
|
||||
@@ -19,57 +19,55 @@
|
||||
#include "nsToken.h"
|
||||
#include "nsScanner.h"
|
||||
|
||||
/*-------------------------------------------------------
|
||||
* LAST MODS: gess
|
||||
* PURPOSE: default constructor
|
||||
* PARMS:
|
||||
* RETURNS:
|
||||
/**-------------------------------------------------------
|
||||
* Default constructor
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param nsString--name of token
|
||||
*------------------------------------------------------*/
|
||||
CToken::CToken(const nsString& aName) : mTextValue(aName) {
|
||||
mOrdinalValue=0;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------
|
||||
* LAST MODS: gess
|
||||
* PURPOSE: destructor
|
||||
* PARMS:
|
||||
* RETURNS:
|
||||
/**-------------------------------------------------------
|
||||
* Decstructor
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
*------------------------------------------------------*/
|
||||
CToken::~CToken() {
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------
|
||||
* LAST MODS: gess
|
||||
* PURPOSE: virtual method used to tell this token to
|
||||
Consume valid characters.
|
||||
* PARMS: aChar: last char read
|
||||
aScanner: see scanner.h
|
||||
* RETURNS: error code
|
||||
/**-------------------------------------------------------
|
||||
* Virtual method used to tell this toke to consume his
|
||||
* valid chars.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aChar -- first char in sequence
|
||||
* @param aScanner -- object to retrieve data from
|
||||
* @return int error code
|
||||
*------------------------------------------------------*/
|
||||
PRInt32 CToken::Consume(PRUnichar aChar,CScanner* aScanner) {
|
||||
PRInt32 result=kNoError;
|
||||
return result;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------
|
||||
* LAST MODS: gess
|
||||
* PURPOSE: Allows caller to set value of internal
|
||||
string buffer
|
||||
* PARMS: aValue: new value for internal string
|
||||
* RETURNS:
|
||||
/**-------------------------------------------------------
|
||||
* Method used to set the string value of this token
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aValue -- char* containing new value
|
||||
*------------------------------------------------------*/
|
||||
void CToken::SetStringValue(const char* aValue) {
|
||||
mTextValue=aValue;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------
|
||||
* LAST MODS: gess
|
||||
* PURPOSE: used for debugging purposes, this method
|
||||
causes the token dump its contents to the
|
||||
given stream.
|
||||
* PARMS: aOutputStream: stream to write data to
|
||||
* RETURNS: nada
|
||||
/**-------------------------------------------------------
|
||||
* This debug method causes the token to dump its content
|
||||
* to the given stream (formated for debugging).
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param ostream -- output stream to accept output data
|
||||
*------------------------------------------------------*/
|
||||
void CToken::DebugDumpToken(ostream& anOutputStream) {
|
||||
anOutputStream << "[" << GetClassName() << "] ";
|
||||
@@ -79,23 +77,77 @@ void CToken::DebugDumpToken(ostream& anOutputStream) {
|
||||
anOutputStream << ": " << mOrdinalValue << endl;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------
|
||||
* LAST MODS: gess
|
||||
* PURPOSE: used for debugging purposes, this method
|
||||
causes the token dump its contents to the
|
||||
given stream.
|
||||
* PARMS: aOutputStream: stream to write data to
|
||||
* RETURNS: nada
|
||||
/**-------------------------------------------------------
|
||||
* This debug method causes the token to dump its content
|
||||
* to the given stream, formated as text.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param ostream -- output stream to accept output data
|
||||
*------------------------------------------------------*/
|
||||
void CToken::DebugDumpSource(ostream& anOutputStream) {
|
||||
anOutputStream << mTextValue;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------
|
||||
* LAST MODS: gess 28Feb98
|
||||
* PURPOSE: self test
|
||||
* PARMS:
|
||||
* RETURNS:
|
||||
/**-------------------------------------------------------
|
||||
* This method retrieves the value of this internal string.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @return nsString reference to internal string value
|
||||
*------------------------------------------------------*/
|
||||
nsString& CToken::GetStringValue(void) {
|
||||
return mTextValue;
|
||||
}
|
||||
|
||||
nsString& CToken::GetText(void) {
|
||||
return mTextValue;
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
* Sets the internal ordinal value for this token.
|
||||
* This method is deprecated, and will soon be going away.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param value -- new ordinal value for this token
|
||||
*------------------------------------------------------*/
|
||||
void CToken::SetOrdinal(PRInt32 value) {
|
||||
mOrdinalValue=value;
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
* Retrieves copy of internal ordinal value.
|
||||
* This method is deprecated, and will soon be going away.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @return int containing ordinal value
|
||||
*------------------------------------------------------*/
|
||||
PRInt32 CToken::GetOrdinal(void) {
|
||||
return mOrdinalValue;
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
* Retrieve type of token. This class returns -1, but
|
||||
* subclasses return something more meaningful.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @return int value containing token type.
|
||||
*------------------------------------------------------*/
|
||||
PRInt32 CToken::GetTokenType(void) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
* retrieve this tokens classname.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @return char* containing name of class
|
||||
*------------------------------------------------------*/
|
||||
const char* CToken::GetClassName(void) {
|
||||
return "token";
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
*------------------------------------------------------*/
|
||||
void CToken::SelfTest(void) {
|
||||
#ifdef _DEBUG
|
||||
|
||||
@@ -41,21 +41,30 @@
|
||||
|
||||
class CScanner;
|
||||
|
||||
/**-------------------------------------------------------
|
||||
* Token objects represent sequences of characters as they
|
||||
* are consumed from the input stream (URL). While they're
|
||||
* pretty general in nature, we use subclasses (found in
|
||||
* nsHTMLTokens.h) to define <start>, </end>, <text>,
|
||||
* <comment>, <&entity>, <newline>, and <whitespace> tokens.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
*------------------------------------------------------*/
|
||||
class CToken {
|
||||
public:
|
||||
CToken(const nsString& aName);
|
||||
~CToken();
|
||||
|
||||
virtual nsString& GetStringValue(void) {return mTextValue;}
|
||||
virtual nsString& GetText(void) {return mTextValue;}
|
||||
virtual nsString& GetStringValue(void);
|
||||
virtual nsString& GetText(void);
|
||||
virtual void SetStringValue(const char* name);
|
||||
virtual void SetOrdinal(PRInt32 value) {mOrdinalValue=value;}
|
||||
virtual PRInt32 GetOrdinal(void) {return mOrdinalValue;}
|
||||
virtual void SetOrdinal(PRInt32 value);
|
||||
virtual PRInt32 GetOrdinal(void);
|
||||
virtual PRInt32 Consume(PRUnichar aChar,CScanner* aScanner);
|
||||
virtual void DebugDumpToken(ostream& out);
|
||||
virtual void DebugDumpSource(ostream& out);
|
||||
virtual PRInt32 GetTokenType(void) {return -1;}
|
||||
virtual const char* GetClassName(void) {return "token";}
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual const char* GetClassName(void);
|
||||
static void SelfTest();
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user