C# Class Parser.ParserBase

An abstract class which is used as the base class for parsers. It contains basic methods which allow you to create a logical tree from a document.
Datei anzeigen Open project: totpero/SqlParser Class Usage Examples

Public Methods

Method Description
CheckTextAndPositionArguments ( string text, int position ) : void

Checks the text and position parameters.

CountStringsBefore ( string text, int position, string @string ) : int

Returns how many continuous specified strings are before of the specified position in the specified text

Parse ( string text ) : void

Parses the specified text.

ReadWordOrSeparator ( string text, int &position, bool treatWhiteSpaceAsSeparator ) : string

Reads a single word or separator at the specified position.

SkipWhiteSpace ( string text, int &position ) : void

Skips the white space symbols located at the specified position.

ToText ( ) : string

Returns the text string processed by the parser.

Protected Methods

Method Description
CheckXmlDocInitialized ( ) : void

Checks whether the m_ParsedDocument is initialized.

ClearXmlNode ( XmlNode node ) : void

Removes all the sub nodes from the specified node.

CreateTagXmlNode ( TagBase tag ) : XmlNode

Creates an xml node for the specified tag.

CreateTextXmlNode ( string text ) : XmlNode

Creates an xml node for the specified text.

GetTagFromType ( string type, string value, bool hasContents ) : TagBase

Retrurns the tag instance from its type and value.

GetTextNodeText ( XmlNode node ) : string

Returns the text stored in the text node.

GetXmlNodeValue ( XmlNode node ) : string

Retrieves the value of the specified tag xml node.

IsTag ( string text, int position ) : Type

Checks whether there is a tag in the text at the specified position, and returns its type.

IsTagXmlNode ( XmlNode node ) : bool

Determines whether the specified node is a tag node.

IsTextXmlNode ( XmlNode node ) : bool

Determines whether the specified node is a text node.

ParseBlock ( XmlNode parentNode, TagBase parentTag, string text, int position ) : int

Parses the specified block of a text.

TagXmlNodeToTag ( XmlNode node ) : TagBase

Converts the specified tag xml node into a tag.

XmlNodeToText ( StringBuilder output, XmlNode node ) : void

Converts the specified xml node to text.

XmlNodesToText ( StringBuilder output, XmlNodeList nodes ) : void

Converts the specified xml node collection to the text.

Private Methods

Method Description
TagXmlNodeToText ( StringBuilder output, XmlNode node ) : void

Converts the specified tag xml node to text.

Method Details

CheckTextAndPositionArguments() public static method

Checks the text and position parameters.
public static CheckTextAndPositionArguments ( string text, int position ) : void
text string
position int
return void

CheckXmlDocInitialized() protected method

Checks whether the m_ParsedDocument is initialized.
protected CheckXmlDocInitialized ( ) : void
return void

ClearXmlNode() protected static method

Removes all the sub nodes from the specified node.
protected static ClearXmlNode ( XmlNode node ) : void
node System.Xml.XmlNode
return void

CountStringsBefore() public static method

Returns how many continuous specified strings are before of the specified position in the specified text
public static CountStringsBefore ( string text, int position, string @string ) : int
text string
position int
@string string
return int

CreateTagXmlNode() protected method

Creates an xml node for the specified tag.
protected CreateTagXmlNode ( TagBase tag ) : XmlNode
tag TagBase
return System.Xml.XmlNode

CreateTextXmlNode() protected method

Creates an xml node for the specified text.
protected CreateTextXmlNode ( string text ) : XmlNode
text string
return System.Xml.XmlNode

GetTagFromType() protected method

Retrurns the tag instance from its type and value.
protected GetTagFromType ( string type, string value, bool hasContents ) : TagBase
type string
value string
hasContents bool
return TagBase

GetTextNodeText() protected method

Returns the text stored in the text node.
protected GetTextNodeText ( XmlNode node ) : string
node System.Xml.XmlNode
return string

GetXmlNodeValue() protected method

Retrieves the value of the specified tag xml node.
protected GetXmlNodeValue ( XmlNode node ) : string
node System.Xml.XmlNode
return string

IsTag() protected method

Checks whether there is a tag in the text at the specified position, and returns its type.
protected IsTag ( string text, int position ) : Type
text string
position int
return System.Type

IsTagXmlNode() protected method

Determines whether the specified node is a tag node.
protected IsTagXmlNode ( XmlNode node ) : bool
node System.Xml.XmlNode
return bool

IsTextXmlNode() protected method

Determines whether the specified node is a text node.
protected IsTextXmlNode ( XmlNode node ) : bool
node System.Xml.XmlNode
return bool

Parse() public method

Parses the specified text.
public Parse ( string text ) : void
text string
return void

ParseBlock() protected method

Parses the specified block of a text.
protected ParseBlock ( XmlNode parentNode, TagBase parentTag, string text, int position ) : int
parentNode System.Xml.XmlNode
parentTag TagBase
text string
position int
return int

ReadWordOrSeparator() public static method

Reads a single word or separator at the specified position.
public static ReadWordOrSeparator ( string text, int &position, bool treatWhiteSpaceAsSeparator ) : string
text string
position int
treatWhiteSpaceAsSeparator bool
return string

SkipWhiteSpace() public static method

Skips the white space symbols located at the specified position.
public static SkipWhiteSpace ( string text, int &position ) : void
text string
position int
return void

TagXmlNodeToTag() protected method

Converts the specified tag xml node into a tag.
protected TagXmlNodeToTag ( XmlNode node ) : TagBase
node System.Xml.XmlNode
return TagBase

ToText() public method

Returns the text string processed by the parser.
public ToText ( ) : string
return string

XmlNodeToText() protected method

Converts the specified xml node to text.
protected XmlNodeToText ( StringBuilder output, XmlNode node ) : void
output StringBuilder
node System.Xml.XmlNode
return void

XmlNodesToText() protected method

Converts the specified xml node collection to the text.
protected XmlNodesToText ( StringBuilder output, XmlNodeList nodes ) : void
output StringBuilder
nodes System.Xml.XmlNodeList
return void