--- /dev/null
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.IO;\r
+\r
+namespace Handbrake.Parsing\r
+{\r
+ public delegate void DataReadEventHandler(object Sender, string Data);\r
+ /// <summary>\r
+ /// A simple wrapper around a StreamReader to keep track of the entire output from a cli process\r
+ /// </summary>\r
+ internal class Parser : StreamReader\r
+ {\r
+ /// <summary>\r
+ /// The output from the CLI process\r
+ /// </summary>\r
+ private string m_buffer;\r
+ public string Buffer\r
+ {\r
+ get\r
+ {\r
+ return this.m_buffer;\r
+ }\r
+ }\r
+\r
+ public static event DataReadEventHandler OnReadLine;\r
+ public static event DataReadEventHandler OnReadToEnd;\r
+\r
+ public Parser(Stream baseStream) : base(baseStream)\r
+ {\r
+ this.m_buffer = string.Empty;\r
+ }\r
+\r
+ public override string ReadLine()\r
+ {\r
+ string tmp = base.ReadLine();\r
+ this.m_buffer += tmp;\r
+ if (OnReadLine != null)\r
+ {\r
+ OnReadLine(this, tmp);\r
+ }\r
+ return tmp;\r
+ }\r
+\r
+ public override string ReadToEnd()\r
+ {\r
+ string tmp = base.ReadToEnd();\r
+ this.m_buffer += tmp;\r
+ if (OnReadToEnd != null)\r
+ {\r
+ OnReadToEnd(this, tmp);\r
+ }\r
+ return tmp;\r
+ }\r
+ }\r
+}\r