public IRCPrefix Parse(string text) { var span = new StringSpan(text); var map = span.TakeToEndBySeparator(out string front, IRCPrefix.UserSeparator, IRCPrefix.HostSeparator); this.Nick = front; this.User = map.TryGetValue(IRCPrefix.UserSeparator, out string user) ? user : null; this.Host = map.TryGetValue(IRCPrefix.HostSeparator, out string host) ? host : null; return(this); }
public IRCTagKey Parse(string text) { var span = new StringSpan(text); var next = span.NextChar(ClientPrefix); var read = span.TakeToSeparator(VendorSuffix, false, true); this.Client = next == ClientPrefix; if (read.EndsWith(VendorSuffix.ToString()) == true) { this.Vendor = read; this.Name = span.TakeToEnd(); } else { this.Vendor = null; this.Name = read; } return(this); }
public IRCParams Parse(string text) { var span = new StringSpan(text); var values = this.Values; values.Clear(); if (span.Position < span.Length) { while (true) { if (span.NextChar(IRCParams.ParamsPrefix) == IRCParams.ParamsPrefix) { var peek = span.PeekChar(); if (peek == IRCParams.TrailingPrefix) { values.Add(span.TakeToEnd()); } else { var value = span.TakeToSeparator(IRCParams.ParamsPrefix, false); values.Add(value); } } else { break; } if (span.Position >= span.Length) { break; } } } return(this); }
public IRCMessage Parse(string text) { var span = new StringSpan(text); var peek = span.PeekChar(); if (peek == IRCMessage.TagsPrefix) { span.NextChar(); var tagsText = span.TakeToSeparator(IRCMessage.TagsSuffix, false, true); this.Tags = new IRCTags().Parse(tagsText); } else { this.Tags = null; } peek = span.PeekChar(); if (peek == IRCMessage.PrefixsPrefix) { span.NextChar(); var prefixText = span.TakeToSeparator(IRCMessage.PrefixsSuffix, false, true); this.Prefix = new IRCPrefix().Parse(prefixText); } else { this.Prefix = null; } var commandText = span.TakeToSeparator(IRCParams.ParamsPrefix, false); this.Command = commandText; var paramsText = span.TakeToEnd(); this.Params = new IRCParams().Parse(paramsText); return(this); }