public static string ParseCSharpStringFrom(StringSegment source, out StringSegment rest) { if (source[0] != '"') throw new ArgumentOutOfRangeException("source"); var parser = new CSharpStringParser(source); var value = parser.GetValue(); rest = source.Substring(parser._Index + 1); return value; }
public void SplitAtFirst(Func<string, int, bool> predicate, out StringSegment beforeExclusive, out StringSegment afterInclusive) { if (predicate == null) throw new ArgumentNullException("predicate"); var offset = IndexOf(predicate); if (offset == -1) { beforeExclusive = this; afterInclusive = new StringSegment(String, Start + Length, 0); } else { beforeExclusive = new StringSegment(String, Start, offset); afterInclusive = new StringSegment(String, Start + offset, Length - offset); } }
private CSharpStringParser(StringSegment input) { _StringBuilder = new StringBuilder(); _Source = input; }