OSDN Git Service

forgot to check this in
authorbrianmario <brianmario@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Fri, 13 Jul 2007 21:11:32 +0000 (21:11 +0000)
committerbrianmario <brianmario@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Fri, 13 Jul 2007 21:11:32 +0000 (21:11 +0000)
git-svn-id: svn://localhost/HandBrake/trunk@678 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/C#/Parsing/Parser.cs [new file with mode: 0644]

diff --git a/win/C#/Parsing/Parser.cs b/win/C#/Parsing/Parser.cs
new file mode 100644 (file)
index 0000000..7cda417
--- /dev/null
@@ -0,0 +1,56 @@
+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