Пример #1
0
        private int ReadInt()
        {
            if (_str[curIndex] < '0' || _str[curIndex] > '9')
            {
                throw BssomSerializationArgumentException.InputDataFormatterError();
            }

            long num = 0;

            num += (_str[curIndex] - '0');
            curIndex++;

            while (_str.Length - curIndex - 1 >= 0)
            {
                char c = _str[curIndex];
                if (c < '0' || c > '9')
                {
                    break;
                }

                num *= 10;
                num += (c - '0');
                curIndex++;
            }

            return(checked ((int)num));
        }
Пример #2
0
        public StringInputDataSource(string str) : this()
        {
            if (str is null)
            {
                throw new ArgumentNullException(nameof(str));
            }

            if (str.Length < 1)
            {
                throw BssomSerializationArgumentException.InputDataFormatterError();
            }

            _str = str;
        }
Пример #3
0
        public bool MoveNext()
        {
            if (curIndex == _str.Length)
            {
                return(false);
            }

            switch (_str[curIndex])
            {
            case '[':
            {
                curIsMapKey = true;
                curIndex++;
                mapKeyIndex = curIndex;
                for (; curIndex < _str.Length; curIndex++)
                {
                    if (_str[curIndex] == ']')
                    {
                        mapKeyLength = curIndex - mapKeyIndex;
                        if (mapKeyLength == 0)
                        {
                            BssomSerializationArgumentException.BssomMapStringKeyIsEmpty();
                        }

                        curIndex++;
                        return(true);
                    }
                }
                throw BssomSerializationArgumentException.InputDataFormatterError();
            }

            case '$':
            {
                curIsMapKey = false;
                curIndex++;
                aryIndexNumber = ReadInt();

                return(true);
            }

            default:
                throw BssomSerializationArgumentException.InputDataFormatterError();
            }
        }