public override int Match(Matcher m, ReaderBuffer buffer, int start, int skip) { int c; if (skip != 0) { return(-1); } c = buffer.Peek(start); if (c < 0) { m.SetReadEndOfString(); return(-1); } if (m.IsCaseInsensitive()) { c = (int)Char.ToLower((char)c); } return(InSet((char)c) ? 1 : -1); }
public override int Match(Matcher m, ReaderBuffer buffer, int start, int skip) { if (skip != 0) { return(-1); } for (int i = 0; i < _value.Length; i++) { var c = buffer.Peek(start + i); if (c < 0) { m.SetReadEndOfString(); return(-1); } if (m.IsCaseInsensitive()) { c = (int)Char.ToLower((char)c); } if (c != (int)_value[i]) { return(-1); } } return(_value.Length); }
/// <summary> /// Returns the length of a matching string starting at the /// specified position. The number of matches to skip can also /// be specified, but numbers higher than zero (0) cause a /// failed match for any element that doesn't attempt to /// combine other elements. /// </summary> /// <param name="m">The matcher being used</param> /// <param name="buffer">The input character buffer to match</param> /// <param name="start">The starting position</param> /// <param name="skip">The number of matches to skip</param> /// <returns> /// The length of the longest matching string, or -1 if no match is found /// </returns> /// <exception cref="IOException">If an I/O error occurred</exception> public override int Match( Matcher m, ReaderBuffer buffer, int start, int skip) { int c; if (skip != 0) { return -1; } for (int i = 0; i < this.value.Length; i++) { c = buffer.Peek(start + i); if (c < 0) { m.SetReadEndOfString(); return -1; } if (m.IsCaseInsensitive) { c = (int)char.ToLower((char)c); } if (c != (int)this.value[i]) { return -1; } } return this.value.Length; }