summaryrefslogtreecommitdiffstats
path: root/win/C#/Parsing/Subtitle.cs
diff options
context:
space:
mode:
authorbrianmario <[email protected]>2007-07-09 22:26:54 +0000
committerbrianmario <[email protected]>2007-07-09 22:26:54 +0000
commit67570f0d1a66754708b519467443d81549841746 (patch)
tree954e91fc001ceda75d1573563bf4af2623c18b16 /win/C#/Parsing/Subtitle.cs
parentf443f516c2f56d2b64bd1b6c050ff75801b80112 (diff)
added new parsing code to parse cli output into objects
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@667 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/Parsing/Subtitle.cs')
-rw-r--r--win/C#/Parsing/Subtitle.cs63
1 files changed, 63 insertions, 0 deletions
diff --git a/win/C#/Parsing/Subtitle.cs b/win/C#/Parsing/Subtitle.cs
new file mode 100644
index 000000000..a9c169ddc
--- /dev/null
+++ b/win/C#/Parsing/Subtitle.cs
@@ -0,0 +1,63 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.IO;
+
+namespace Handbrake.Parsing
+{
+ public class Subtitle
+ {
+ private int m_trackNumber;
+ public int TrackNumber
+ {
+ get
+ {
+ return this.m_trackNumber;
+ }
+ }
+
+ private string m_language;
+ public string Language
+ {
+ get
+ {
+ return this.m_language;
+ }
+ }
+
+ public static Subtitle Parse(StreamReader output)
+ {
+ string curLine = output.ReadLine();
+ if (!curLine.Contains("HandBrake has exited."))
+ {
+ Subtitle thisSubtitle = new Subtitle();
+ string[] splitter = curLine.Split(new string[] { " + ", ", " }, StringSplitOptions.RemoveEmptyEntries);
+ thisSubtitle.m_trackNumber = int.Parse(splitter[0]);
+ thisSubtitle.m_language = splitter[1];
+ return thisSubtitle;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public static Subtitle[] ParseList(StreamReader output)
+ {
+ List<Subtitle> subtitles = new List<Subtitle>();
+ while ((char)output.Peek() != '+') // oh glorious hack, serve me well
+ {
+ Subtitle thisSubtitle = Subtitle.Parse(output);
+ if (thisSubtitle != null)
+ {
+ subtitles.Add(thisSubtitle);
+ }
+ else
+ {
+ break;
+ }
+ }
+ return subtitles.ToArray();
+ }
+ }
+}