NVelocity.Runtime.Parser.VelocityCharStream.ReadChar C# (CSharp) Method

ReadChar() public method

public ReadChar ( ) : bool
return bool
        public bool ReadChar()
        {
            if (inBuf > 0)
            {
                --inBuf;

                /*
                *  was : return (char)((char)0xff & buffer[(bufferPosition == bufferSize - 1) ? (bufferPosition = 0) : ++bufferPosition]);
                */
                currentCharacterAvailable = true;
                currentCharacter = buffer[(bufferPosition == bufferSize - 1) ? (bufferPosition = 0) : ++bufferPosition];
                return true;
            }

            if (++bufferPosition >= maxNextCharInd)
            {
                if (!FillBuff())
                {
                    currentCharacterAvailable = false;
                    currentCharacter = default(Char);
                    return false;
                }
            }

            /*
            *  was : char c = (char)((char)0xff & buffer[bufferPosition]);
            */
            currentCharacterAvailable = true;
            currentCharacter = buffer[bufferPosition];

            UpdateLineColumn();
            return true;
        }

Usage Example

Esempio n. 1
0
		public void Test_VelocityCharStream()
		{
			String s1 = "this is a test";
			VelocityCharStream vcs = new VelocityCharStream(new StringReader(s1), 1, 1);

			String s2 = String.Empty;
			try
			{
				Char c = vcs.ReadChar();
				while (true)
				{
					s2 += c;
					c = vcs.ReadChar();
				}
			}
			catch (IOException)
			{
				// this is expected to happen when the stream has been read
			}
			Assert.IsTrue(s1.Equals(s2), "read stream did not match source string");
		}
All Usage Examples Of NVelocity.Runtime.Parser.VelocityCharStream::ReadChar