// // System.Xml.XmlParserInput // // Author: // Atsushi Enomoto (ginga@kit.hi-ho.ne.jp) // // (C)2003 Atsushi Enomoto // using System; using System.IO; using System.Text; using System.Xml; using System.Globalization; namespace Mono.Xml.Native { public class XmlParserInput { #region ctor public XmlParserInput (TextReader reader, string baseURI) : this (reader, baseURI, 1, 1) { } public XmlParserInput (TextReader reader, string baseURI, int line, int column) { this.reader = reader; StreamReader sr = reader as StreamReader; if (sr != null) can_seek = sr.BaseStream.CanSeek; this.line = line; this.column = column; this.baseURI = baseURI; } #endregion #region Public Methods // Read the next character and compare it against the // specified character. public void Expect (int expected) { int ch = ReadChar (); if (ch != expected) { throw ReaderError ( String.Format ( "expected '{0}' ({1:X}) but found '{2}' ({3:X})", (char)expected, expected, (char)ch, ch)); } } public void Expect (string expected) { int len = expected.Length; for(int i=0; i< len; i++) Expect (expected[i]); } public void InsertParameterEntityBuffer (string value) { this.peBuffer.Insert (0, value); } public int PeekChar () { if (peBuffer.Length > 0) return peBuffer [0]; if (can_seek) return reader.Peek (); if (has_peek) return peek_char; peek_char = reader.Read (); has_peek = true; return peek_char; } public int ReadChar () { int ch; if (peBuffer.Length > 0) { ch = peBuffer [0]; peBuffer.Remove (0, 1); // I decided not to add character to currentTag with respect to PERef value return ch; } if (has_peek) { ch = peek_char; has_peek = false; } else { ch = reader.Read (); } if (ch == '\n') { line++; column = 1; } else { column++; } currentMarkup.Append ((char) ch); return ch; } #if FullTextParseSupport // The reader is positioned on the first character after // the leading '