diff options
author | sr55 <[email protected]> | 2008-08-27 23:45:44 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2008-08-27 23:45:44 +0000 |
commit | c1f31822b78859305328750ca0adcd0b1699f690 (patch) | |
tree | 9751e09ecee8a9199e5f49ae0af351f71a8be794 /win/C#/Parsing | |
parent | 1833f566d3f9c7fbe0ef61b4f9304b6e0f7fddb5 (diff) |
WinGui:
- Code Refactoring and optimization to numerous files
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1655 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/Parsing')
-rw-r--r-- | win/C#/Parsing/DVD.cs | 21 | ||||
-rw-r--r-- | win/C#/Parsing/Parser.cs | 41 | ||||
-rw-r--r-- | win/C#/Parsing/Title.cs | 69 |
3 files changed, 52 insertions, 79 deletions
diff --git a/win/C#/Parsing/DVD.cs b/win/C#/Parsing/DVD.cs index 1637c9154..d0802e4c9 100644 --- a/win/C#/Parsing/DVD.cs +++ b/win/C#/Parsing/DVD.cs @@ -11,7 +11,7 @@ using System.IO; namespace Handbrake.Parsing
{
-
+
/// <summary>
/// An object representing a scanned DVD
/// </summary>
@@ -41,20 +41,15 @@ namespace Handbrake.Parsing public static DVD Parse(StreamReader output)
{
DVD thisDVD = new DVD();
- try
- {
- while (!output.EndOfStream)
- {
- if ((char)output.Peek() == '+')
- thisDVD.m_titles.AddRange(Title.ParseList(output.ReadToEnd()));
- else
- output.ReadLine();
- }
- }
- catch (Exception exc)
+
+ while (!output.EndOfStream)
{
- MessageBox.Show("DVD.CS - Parse" + exc.ToString());
+ if ((char)output.Peek() == '+')
+ thisDVD.m_titles.AddRange(Title.ParseList(output.ReadToEnd()));
+ else
+ output.ReadLine();
}
+
return thisDVD;
}
}
diff --git a/win/C#/Parsing/Parser.cs b/win/C#/Parsing/Parser.cs index 86e8a5017..bbafc9295 100644 --- a/win/C#/Parsing/Parser.cs +++ b/win/C#/Parsing/Parser.cs @@ -64,7 +64,8 @@ namespace Handbrake.Parsing /// Default constructor for this object
/// </summary>
/// <param name="baseStream">The stream to parse from</param>
- public Parser(Stream baseStream) : base(baseStream)
+ public Parser(Stream baseStream)
+ : base(baseStream)
{
this.m_buffer = string.Empty;
}
@@ -72,38 +73,26 @@ namespace Handbrake.Parsing public override string ReadLine()
{
string tmp = base.ReadLine();
- try
- {
-
- this.m_buffer += tmp;
- Match m = Regex.Match(tmp, "^Scanning title ([0-9]*) of ([0-9]*)");
- if (OnReadLine != null)
- OnReadLine(this, tmp);
-
- if (m.Success && OnScanProgress != null)
- OnScanProgress(this, int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value));
- }
- catch (Exception exc)
- {
- MessageBox.Show("Parser.cs - ReadLine " + exc.ToString());
- }
+
+ this.m_buffer += tmp;
+ Match m = Regex.Match(tmp, "^Scanning title ([0-9]*) of ([0-9]*)");
+ if (OnReadLine != null)
+ OnReadLine(this, tmp);
+
+ if (m.Success && OnScanProgress != null)
+ OnScanProgress(this, int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value));
+
return tmp;
}
public override string ReadToEnd()
{
string tmp = base.ReadToEnd();
- try
- {
- this.m_buffer += tmp;
- if (OnReadToEnd != null)
- OnReadToEnd(this, tmp);
- }
- catch (Exception exc)
- {
- MessageBox.Show("Parser.cs - ReadToEnd " + exc.ToString());
- }
+ this.m_buffer += tmp;
+ if (OnReadToEnd != null)
+ OnReadToEnd(this, tmp);
+
return tmp;
}
}
diff --git a/win/C#/Parsing/Title.cs b/win/C#/Parsing/Title.cs index 5d21d89cb..14eacf165 100644 --- a/win/C#/Parsing/Title.cs +++ b/win/C#/Parsing/Title.cs @@ -142,44 +142,38 @@ namespace Handbrake.Parsing public static Title Parse(StringReader output)
{
Title thisTitle = new Title();
- try
- {
- Match m = Regex.Match(output.ReadLine(), @"^\+ title ([0-9]*):");
- // Match track number for this title
- if (m.Success)
- thisTitle.m_titleNumber = int.Parse(m.Groups[1].Value.Trim().ToString());
- output.ReadLine();
+ Match m = Regex.Match(output.ReadLine(), @"^\+ title ([0-9]*):");
+ // Match track number for this title
+ if (m.Success)
+ thisTitle.m_titleNumber = int.Parse(m.Groups[1].Value.Trim().ToString());
- // Get duration for this title
+ output.ReadLine();
- m = Regex.Match(output.ReadLine(), @"^ \+ duration: ([0-9]{2}:[0-9]{2}:[0-9]{2})");
- if (m.Success)
- thisTitle.m_duration = TimeSpan.Parse(m.Groups[1].Value);
+ // Get duration for this title
- // Get resolution, aspect ratio and FPS for this title
- m = Regex.Match(output.ReadLine(), @"^ \+ size: ([0-9]*)x([0-9]*), aspect: ([0-9]*\.[0-9]*), ([0-9]*\.[0-9]*) fps");
- if (m.Success)
- {
- thisTitle.m_resolution = new Size(int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value));
- thisTitle.m_aspectRatio = float.Parse(m.Groups[3].Value, Functions.Encode.Culture);
- }
+ m = Regex.Match(output.ReadLine(), @"^ \+ duration: ([0-9]{2}:[0-9]{2}:[0-9]{2})");
+ if (m.Success)
+ thisTitle.m_duration = TimeSpan.Parse(m.Groups[1].Value);
- // Get autocrop region for this title
- m = Regex.Match(output.ReadLine(), @"^ \+ autocrop: ([0-9]*)/([0-9]*)/([0-9]*)/([0-9]*)");
- if (m.Success)
- thisTitle.m_autoCrop = new int[4] { int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value), int.Parse(m.Groups[3].Value), int.Parse(m.Groups[4].Value) };
+ // Get resolution, aspect ratio and FPS for this title
+ m = Regex.Match(output.ReadLine(), @"^ \+ size: ([0-9]*)x([0-9]*), aspect: ([0-9]*\.[0-9]*), ([0-9]*\.[0-9]*) fps");
+ if (m.Success)
+ {
+ thisTitle.m_resolution = new Size(int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value));
+ thisTitle.m_aspectRatio = float.Parse(m.Groups[3].Value, Functions.Encode.Culture);
+ }
- thisTitle.m_chapters.AddRange(Chapter.ParseList(output));
+ // Get autocrop region for this title
+ m = Regex.Match(output.ReadLine(), @"^ \+ autocrop: ([0-9]*)/([0-9]*)/([0-9]*)/([0-9]*)");
+ if (m.Success)
+ thisTitle.m_autoCrop = new int[4] { int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value), int.Parse(m.Groups[3].Value), int.Parse(m.Groups[4].Value) };
- thisTitle.m_audioTracks.AddRange(AudioTrack.ParseList(output));
+ thisTitle.m_chapters.AddRange(Chapter.ParseList(output));
- thisTitle.m_subtitles.AddRange(Subtitle.ParseList(output));
- }
- catch (Exception exc)
- {
- MessageBox.Show("Title.cs - Parse " + exc.ToString());
- }
+ thisTitle.m_audioTracks.AddRange(AudioTrack.ParseList(output));
+
+ thisTitle.m_subtitles.AddRange(Subtitle.ParseList(output));
return thisTitle;
}
@@ -187,18 +181,13 @@ namespace Handbrake.Parsing public static Title[] ParseList(string output)
{
List<Title> titles = new List<Title>();
- try
- {
- StringReader sr = new StringReader(output);
- while ((char)sr.Peek() == '+')
- {
- titles.Add(Title.Parse(sr));
- }
- }
- catch (Exception exc)
+
+ StringReader sr = new StringReader(output);
+ while ((char)sr.Peek() == '+')
{
- MessageBox.Show("Title.cs - ParseList " + exc.ToString());
+ titles.Add(Title.Parse(sr));
}
+
return titles.ToArray();
}
}
|