/// <summary> /// Gets all or a subset of the current capture buffer /// </summary> /// <param name="startIndex">The start index</param> /// <param name="length">The number of characters to retrieve, or zero to retrieve the remainder of the buffer</param> /// <returns>A string containing the specified subset of the capture buffer</returns> public string GetCapture(int startIndex = 0, int length = 0) { _CheckDisposed(); if (0 == length) { length = CaptureBuffer.Length - startIndex; } return(CaptureBuffer.ToString(startIndex, length)); }
/// <summary> /// Gets the capture buffer at the specified start index /// </summary> /// <param name="startIndex">The index to begin copying</param> /// <param name="count">The number of characters to copy</param> /// <returns>A string representing the specified subset of the capture buffer</returns> public string GetCapture(int startIndex, int count = 0) { _CheckDisposed(); if (0 == count) { count = CaptureBuffer.Length - startIndex; } return(CaptureBuffer.ToString(startIndex, count)); }
/// <summary> /// Attempts to read a floating point literal into the capture buffer while parsing it /// </summary> /// <param name="result">The value the literal represents</param> /// <returns>True if the value was a valid literal, otherwise false</returns> public bool TryParseReal(out double result) { result = default(double); int l = CaptureBuffer.Length; if (!TryReadReal()) { return(false); } return(double.TryParse(CaptureBuffer.ToString(l, CaptureBuffer.Length - l), out result)); }
// must be object because we don't know the int type. To be lexically valid we must use BigInteger when necessary /// <summary> /// Attempts to read a C# integer into the capture buffer while parsing it /// </summary> /// <param name="result">The value the literal represents</param> /// <returns>True if the value was a valid literal, otherwise false</returns> public bool TryParseInteger(out object result) { result = null; EnsureStarted(); if (-1 == Current) { return(false); } bool neg = false; if ('-' == Current) { Capture(); Advance(); neg = true; } int l = CaptureBuffer.Length; if (TryReadDigits()) { string num = CaptureBuffer.ToString(l, CaptureBuffer.Length - l); if (neg) { num = '-' + num; } int r; if (int.TryParse(num, out r)) { result = r; return(true); } long ll; if (long.TryParse(num, out ll)) { result = ll; return(true); } System.Numerics.BigInteger b; if (System.Numerics.BigInteger.TryParse(num, out b)) { result = b; return(true); } } return(false); }
/// <summary> /// Gets the capture buffer at the specified start index /// </summary> /// <param name="startIndex">The index to begin copying</param> /// <returns>A string representing the specified subset of the capture buffer</returns> public string GetCapture(int startIndex = 0) { _CheckDisposed(); return(CaptureBuffer.ToString(startIndex, CaptureBuffer.Length - startIndex)); }