예제 #1
0
        public IRCTags Parse(string text)
        {
            var values = this.Values;

            values.Clear();

            var span = new StringSpan(text);

            while (span.Position < span.Length)
            {
                var    tag       = span.TakeToSeparator(TagSeparator, false, true);
                string keyString = null;
                string value     = null;

                if (tag.Contains(TagValueSeparator) == true)
                {
                    var splits = tag.Split(TagValueSeparator);
                    keyString = splits[0];
                    value     = splits[1];
                }
                else
                {
                    keyString = tag;
                }

                var key = new IRCTagKey().Parse(keyString);
                values[key] = value;
            }

            return(this);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }