Ejemplo n.º 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));
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 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();
            }
        }