C# 클래스 CK.Core.StringMatcher

This class supports "Match and Forward" pattern. On a failed match, the SetError method sets the ErrorMessage. On a successful match, the StartIndex is updated by a call to Forward so that the Head is positioned after the match (and any existing error is cleared).
파일 보기 프로젝트 열기: SimpleGitVersion/SGV-Net 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
RegexDouble System.Text.RegularExpressions.Regex

공개 메소드들

메소드 설명
BackwardSetError ( int savedStartIndex, object expectedMessage = null, [ callerName = null ) : bool

Moves back the head at a previously index and sets an error. The message starts with the caller's method name.

Forward ( int charCount ) : bool

Increments the StartIndex (and decrements Length) with the specified character count and clears any existing error.

MatchChar ( char c ) : bool

Matches an exact single character. If match fails, SetError is called.

MatchWhiteSpaces ( int minCount = 1 ) : bool

Matches a sequence of white spaces.

SetError ( object expectedMessage = null, [ callerName = null ) : bool

Sets an error. The message starts with the caller's method name.

SetSuccess ( ) : bool

Clears any error and returns true.

StringMatcher ( string text, int startIndex ) : System

Initializes a new instance of the StringMatcher class.

StringMatcher ( string text, int startIndex, int length ) : System

Initializes a new instance of the StringMatcher class on a substring.

ToString ( ) : string

Overridden to return a detailed string with ErrorMessage (if any), the Head character, StartIndex position and whole Text.

TryMatchChar ( char c ) : bool

Attempts to match an exact single character.

TryMatchDoubleValue ( ) : bool

Matches a double without getting its value nor setting an error if match fails. This uses RegexDouble.

TryMatchJSONQuotedString ( bool allowNull = false ) : bool

Matches a quoted string without extracting its content.

TryMatchJSONQuotedString ( string &content, bool allowNull = false ) : bool

Matches a quoted string without setting an error if match fails.

TryMatchText ( string s, System.StringComparison comparisonType = StringComparison.OrdinalIgnoreCase ) : bool

Matches a string without setting an error if match fails.

UncheckedMove ( int delta ) : bool

Moves the head without any check and returns always true: typically called by successful TryMatch methods.

비공개 메소드들

메소드 설명
FormatMessage ( object expectedMessage, string callerName ) : string
ReadHexDigit ( char c ) : int

메소드 상세

BackwardSetError() 공개 메소드

Moves back the head at a previously index and sets an error. The message starts with the caller's method name.
public BackwardSetError ( int savedStartIndex, object expectedMessage = null, [ callerName = null ) : bool
savedStartIndex int Index to reset.
expectedMessage object /// Optional object. Its will be used to generate an "expected '...'" message. ///
callerName [ Name of the caller (automatically injected by the compiler).
리턴 bool

Forward() 공개 메소드

Increments the StartIndex (and decrements Length) with the specified character count and clears any existing error.
public Forward ( int charCount ) : bool
charCount int The successfully matched character count. /// Must be positive and should not move head past the end of the substring.
리턴 bool

MatchChar() 공개 메소드

Matches an exact single character. If match fails, SetError is called.
public MatchChar ( char c ) : bool
c char The character that must match.
리턴 bool

MatchWhiteSpaces() 공개 메소드

Matches a sequence of white spaces.
public MatchWhiteSpaces ( int minCount = 1 ) : bool
minCount int Minimal number of white spaces to match.
리턴 bool

SetError() 공개 메소드

Sets an error. The message starts with the caller's method name.
public SetError ( object expectedMessage = null, [ callerName = null ) : bool
expectedMessage object /// Optional object. Its will be used to generate an "expected '...'" message. ///
callerName [ Name of the caller (automatically injected by the compiler).
리턴 bool

SetSuccess() 공개 메소드

Clears any error and returns true.
public SetSuccess ( ) : bool
리턴 bool

StringMatcher() 공개 메소드

Initializes a new instance of the StringMatcher class.
public StringMatcher ( string text, int startIndex ) : System
text string The string to parse.
startIndex int Index where the match must start in .
리턴 System

StringMatcher() 공개 메소드

Initializes a new instance of the StringMatcher class on a substring.
public StringMatcher ( string text, int startIndex, int length ) : System
text string The string to parse.
startIndex int /// Index where the match must start in . ///
length int /// Number of characters to consider in the string. /// If + length is greater than the length of the string, an is thrown. ///
리턴 System

ToString() 공개 메소드

Overridden to return a detailed string with ErrorMessage (if any), the Head character, StartIndex position and whole Text.
public ToString ( ) : string
리턴 string

TryMatchChar() 공개 메소드

Attempts to match an exact single character.
public TryMatchChar ( char c ) : bool
c char The character that must match.
리턴 bool

TryMatchDoubleValue() 공개 메소드

Matches a double without getting its value nor setting an error if match fails. This uses RegexDouble.
public TryMatchDoubleValue ( ) : bool
리턴 bool

TryMatchJSONQuotedString() 공개 메소드

Matches a quoted string without extracting its content.
public TryMatchJSONQuotedString ( bool allowNull = false ) : bool
allowNull bool True to allow 'null'.
리턴 bool

TryMatchJSONQuotedString() 공개 메소드

Matches a quoted string without setting an error if match fails.
public TryMatchJSONQuotedString ( string &content, bool allowNull = false ) : bool
content string Extracted content.
allowNull bool True to allow 'null'.
리턴 bool

TryMatchText() 공개 메소드

Matches a string without setting an error if match fails.
public TryMatchText ( string s, System.StringComparison comparisonType = StringComparison.OrdinalIgnoreCase ) : bool
s string The string that must match. Can not be null nor empty.
comparisonType System.StringComparison Specifies the culture, case, and sort rules.
리턴 bool

UncheckedMove() 공개 메소드

Moves the head without any check and returns always true: typically called by successful TryMatch methods.
public UncheckedMove ( int delta ) : bool
delta int Number of characters.
리턴 bool

프로퍼티 상세

RegexDouble 공개적으로 정적으로 프로퍼티

The Regex that TryMatchDoubleValue() uses to avoid calling double.TryParse(string, out double) when resolving the value is useless.
public static Regex,System.Text.RegularExpressions RegexDouble
리턴 System.Text.RegularExpressions.Regex