Example #1
0
        private static IEnumerable <string> ReadInValues(this StringSpan stringSpan)
        {
            stringSpan.MoveToTheNextStartOfString();

            var arrayIsOpened = stringSpan.CurrentChar == '[';

            if (!arrayIsOpened)
            {
                throw new Exception("Invalid int operation at position: " + stringSpan.PositionStart);
            }

            stringSpan.MoveStartPosition(1);
            stringSpan.SyncEndWithStart();

            while (!stringSpan.Eof)
            {
                var value = stringSpan.ReadNextStringFromArray();
                yield return(value);

                stringSpan.SyncStartWithEnd();

                if (stringSpan.CurrentChar <= ' ')
                {
                    stringSpan.MoveToTheNextStartOfString();
                    stringSpan.SyncEndWithStart();
                }

                if (stringSpan.CurrentChar == ']')
                {
                    stringSpan.MoveStartPosition(1);
                    stringSpan.SyncEndWithStart();
                    break;
                }

                if (stringSpan.CurrentChar != ',')
                {
                    stringSpan.MoveStartPosition(EscapeSequence, c => c == ',' || c == ']');
                }

                stringSpan.MoveStartPosition(1);
                stringSpan.SyncEndWithStart();
            }
        }
Example #2
0
 private static void MoveToTheNextStartOfString(this StringSpan stringSpan)
 {
     stringSpan.MoveStartPosition(EscapeSequence, c => c > ' ');
 }