// Returns the next peeked character.
        // Return value of 0 means we have reached the end of the json string.
        // TBD: use "look ahead" implementation similar to ReadString() ????
        // Note that this is effective only for "formatted" JSON with lots of consecutive spaces...
        private char GobbleUpSpaceLookAhead()
        {
            char c = (char)0;

            try {
                c = PeekChar();
                // if(char.IsWhitespace(c)) {
                if (CharUtil.IsWhitespace(c))
                {
                    // SkipCharNoCheck();
                    c = SkipAndPeekChar();

                    // Spaces tend appear together.
                    // if(char.IsWhitespace(c)) {
                    if (CharUtil.IsWhitespace(c))
                    {
                        int             chunkLength;
                        CyclicCharArray charArray = PeekCharsInQueue(MAX_SPACE_LOOKAHEAD_SIZE);
                        // if(charArray == null || (chunkLength = charArray.GetLength()) == 0) {
                        //     return c;
                        // }
                        chunkLength = charArray.Length;

                        int chunkCounter         = 0;
                        int totalLookAheadLength = 0;
                        c = charArray.GetChar(0);
                        // while((chunkCounter < chunkLength - 1) && char.IsWhitespace(c) ) {
                        while ((chunkCounter < chunkLength - 1) && CharUtil.IsWhitespace(c))
                        {
                            ++chunkCounter;

                            if (chunkCounter >= chunkLength - 1)
                            {
                                totalLookAheadLength += chunkCounter;
                                chunkCounter          = 0;                          // restart a loop.

                                charArray = PeekCharsInQueue(totalLookAheadLength, MAX_SPACE_LOOKAHEAD_SIZE);
                                if (charArray == null || (chunkLength = charArray.Length) == 0)
                                {
                                    break;
                                }
                            }
                            c = charArray.GetChar(chunkCounter);
                        }
                        totalLookAheadLength += chunkCounter;
                        SkipChars(totalLookAheadLength);
                        c = PeekChar();
                    }
                }
            } catch (DotJsonMiniException e) {
                // ????
                System.Diagnostics.Debug.WriteLine("Failed to consume space.", e);
                c = (char)0;
            }
            return(c);
        }
        private char GobbleUpSpace()
        {
            char c = (char)0;

            try {
                c = PeekChar();
                //while(c != 0 && char.isSpaceChar(c)) {  // ???  -> this doesn't seem to work....
                // while(c != 0 && char.IsWhitespace(c)  ) {  // ???
                while (c != 0 && CharUtil.IsWhitespace(c))                     // ???
                // NextChar();   // gobble up space.
                // c = PeekChar();
                {
                    c = SkipAndPeekChar();
                }
            } catch (DotJsonMiniException e) {
                // ????
                System.Diagnostics.Debug.WriteLine("Failed to consume space.", e);
                c = (char)0;
            }
            return(c);
        }
Exemple #3
0
        // Returns the next peeked character.
        // Return value of 0 means we have reached the end of the json string.
        // TBD: use "look ahead" implementation similar to readString() ????
        private char GobbleUpSpace()
        {
            char c = (char)0;

            try {
                c = PeekChar();
                //while(c != 0 && Character.isSpaceChar(c)) {  // ???  -> this doesn't seem to work....
                // while(c != 0 && Character.isWhitespace(c)  ) {  // ???
                while (c != 0 && CharUtil.IsWhitespace(c))   // ???
                // nextChar();   // gobble up space.
                // c = PeekChar();
                {
                    c = SkipAndPeekChar();
                }
            } catch (JsonTokenizerException e) {
                // ????
                //if (log.isLoggable(Level.INFO)) {
                //    // log.log(Level.INFO, "Failed to consume space: " + ErrorContext.buildContextString(GetTailCharStream(), PeekCharStream()), e);
                //}
                c = (char)0;
            }
            return(c);
        }
Exemple #4
0
        // Note that this is effective only for "formatted" JSON with lots of consecutive spaces...
        private char GobbleUpSpaceLookAhead()
        {
            char c = (char)0;

            try {
                c = PeekChar();
                // if(Character.isWhitespace(c)) {
                if (CharUtil.IsWhitespace(c))
                {
                    // SkipCharNoCheck();
                    c = SkipAndPeekChar();
                    // Spaces tend appear together.
                    // if(Character.isWhitespace(c)) {
                    if (CharUtil.IsWhitespace(c))
                    {
                        int             chunkLength;
                        CyclicCharArray charArray = PeekCharsInQueue(MAX_SPACE_LOOKAHEAD_SIZE);
                        // if(charArray == null || (chunkLength = charArray.getLength()) == 0) {
                        //     return c;
                        // }
                        chunkLength = charArray.Length;

                        int chunkCounter         = 0;
                        int totalLookAheadLength = 0;
                        c = charArray.GetChar(0);
                        // while((chunkCounter < chunkLength - 1) && Character.isWhitespace(c) ) {
                        while ((chunkCounter < chunkLength - 1) && CharUtil.IsWhitespace(c))
                        {
                            ++chunkCounter;

                            if (chunkCounter >= chunkLength - 1)
                            {
                                totalLookAheadLength += chunkCounter;
                                if (tracingEnabled)
                                {
                                    this.tailBuffer.Push(charArray.GetArray(), chunkCounter);
                                }
                                chunkCounter = 0; // restart a loop.

                                charArray = PeekCharsInQueue(totalLookAheadLength, MAX_SPACE_LOOKAHEAD_SIZE);
                                if (charArray == null || (chunkLength = charArray.Length) == 0)
                                {
                                    break;
                                }
                            }
                            c = charArray.GetChar(chunkCounter);
                        }
                        totalLookAheadLength += chunkCounter;
                        if (tracingEnabled)
                        {
                            this.tailBuffer.Push(charArray.GetArray(), chunkCounter);
                        }
                        SkipChars(totalLookAheadLength);
                        c = PeekChar();
                    }
                }
            } catch (JsonTokenizerException e) {
                // ????
                //if (log.isLoggable(Level.INFO)) {
                //    // log.log(Level.INFO, "Failed to consume space: " + ErrorContext.buildContextString(GetTailCharStream(), PeekCharStream()), e);
                //}
                c = (char)0;
            }
            return(c);
        }