diff options
author | sr55 <[email protected]> | 2010-02-20 22:30:12 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2010-02-20 22:30:12 +0000 |
commit | 3678fc6353c1b1bbea23723891cbf950f66ab452 (patch) | |
tree | 401d6f9b859ecac9fdf13fe432dd564589ac7276 /win/C#/Parsing | |
parent | b59b7b8733533aed4b97da6679e455df63049e23 (diff) |
WinGui:
- Cleanup more StyleCop warnings.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3131 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/Parsing')
-rw-r--r-- | win/C#/Parsing/AudioTrack.cs | 43 | ||||
-rw-r--r-- | win/C#/Parsing/Chapter.cs | 14 | ||||
-rw-r--r-- | win/C#/Parsing/DVD.cs | 7 | ||||
-rw-r--r-- | win/C#/Parsing/Parser.cs | 38 | ||||
-rw-r--r-- | win/C#/Parsing/Subtitle.cs | 14 | ||||
-rw-r--r-- | win/C#/Parsing/Title.cs | 39 |
6 files changed, 82 insertions, 73 deletions
diff --git a/win/C#/Parsing/AudioTrack.cs b/win/C#/Parsing/AudioTrack.cs index 56a35194b..a28e01737 100644 --- a/win/C#/Parsing/AudioTrack.cs +++ b/win/C#/Parsing/AudioTrack.cs @@ -4,13 +4,13 @@ Homepage: <http://handbrake.fr>.
It may be used under the terms of the GNU General Public License. */
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Text.RegularExpressions;
-
namespace Handbrake.Parsing
{
+ using System;
+ using System.Collections.Generic;
+ using System.IO;
+ using System.Text.RegularExpressions;
+
/// <summary>
/// An object represending an AudioTrack associated with a Title, in a DVD
/// </summary>
@@ -74,7 +74,7 @@ namespace Handbrake.Parsing public string ISO639_2
{
- get { return m_iso639_2; }
+ get { return m_iso639_2; }
}
/// <summary>
@@ -85,13 +85,13 @@ namespace Handbrake.Parsing {
if (m_subFormat == null)
return string.Format("{0} {1} ({2})", m_trackNumber, m_language, m_format);
-
+
return string.Format("{0} {1} ({2}) ({3})", m_trackNumber, m_language, m_format, m_subFormat);
}
public static AudioTrack Parse(StringReader output)
{
- String audio_track = output.ReadLine();
+ string audio_track = output.ReadLine();
Match m = Regex.Match(audio_track, @"^ \+ ([0-9]*), ([A-Za-z0-9]*) \((.*)\) \((.*)\)");
Match track = Regex.Match(audio_track, @"^ \+ ([0-9]*), ([A-Za-z0-9]*) \((.*)\)"); // ID and Language
Match iso639_2 = Regex.Match(audio_track, @"iso639-2: ([a-zA-Z]*)\)");
@@ -99,24 +99,25 @@ namespace Handbrake.Parsing Match bitrate = Regex.Match(audio_track, @"([0-9]*)bps");
string subformat = m.Groups[4].Value.Trim().Contains("iso639") ? null : m.Groups[4].Value;
- string samplerateVal = samplerate.Success ? samplerate.Groups[0].Value.Replace("Hz", "").Trim() : "0";
- string bitrateVal = bitrate.Success ? bitrate.Groups[0].Value.Replace("bps", "").Trim() : "0";
+ string samplerateVal = samplerate.Success ? samplerate.Groups[0].Value.Replace("Hz", string.Empty).Trim() : "0";
+ string bitrateVal = bitrate.Success ? bitrate.Groups[0].Value.Replace("bps", string.Empty).Trim() : "0";
if (track.Success)
{
var thisTrack = new AudioTrack
- {
- m_trackNumber = int.Parse(track.Groups[1].Value.Trim()),
- m_language = track.Groups[2].Value,
- m_format = m.Groups[3].Value,
- m_subFormat = subformat,
- m_frequency = int.Parse(samplerateVal),
- m_bitrate = int.Parse(bitrateVal),
- m_iso639_2 = iso639_2.Value.Replace("iso639-2: ", "").Replace(")", "")
- };
- return thisTrack;
+ {
+ m_trackNumber = int.Parse(track.Groups[1].Value.Trim()),
+ m_language = track.Groups[2].Value,
+ m_format = m.Groups[3].Value,
+ m_subFormat = subformat,
+ m_frequency = int.Parse(samplerateVal),
+ m_bitrate = int.Parse(bitrateVal),
+ m_iso639_2 =
+ iso639_2.Value.Replace("iso639-2: ", string.Empty).Replace(")", string.Empty)
+ };
+ return thisTrack;
}
-
+
return null;
}
diff --git a/win/C#/Parsing/Chapter.cs b/win/C#/Parsing/Chapter.cs index 1bf38f4d8..31d57aa26 100644 --- a/win/C#/Parsing/Chapter.cs +++ b/win/C#/Parsing/Chapter.cs @@ -4,13 +4,13 @@ Homepage: <http://handbrake.fr>.
It may be used under the terms of the GNU General Public License. */
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Text.RegularExpressions;
-
namespace Handbrake.Parsing
{
+ using System;
+ using System.Collections.Generic;
+ using System.IO;
+ using System.Text.RegularExpressions;
+
/// <summary>
/// An object representing a Chapter aosciated with a Title, in a DVD
/// </summary>
@@ -47,13 +47,13 @@ namespace Handbrake.Parsing public static Chapter Parse(StringReader output)
{
- Match m = Regex.Match(output.ReadLine(),
+ Match m = Regex.Match(output.ReadLine(),
@"^ \+ ([0-9]*): cells ([0-9]*)->([0-9]*), ([0-9]*) blocks, duration ([0-9]{2}:[0-9]{2}:[0-9]{2})");
if (m.Success)
{
var thisChapter = new Chapter
{
- m_chapterNumber = int.Parse(m.Groups[1].Value.Trim()),
+ m_chapterNumber = int.Parse(m.Groups[1].Value.Trim()),
m_duration = TimeSpan.Parse(m.Groups[5].Value)
};
return thisChapter;
diff --git a/win/C#/Parsing/DVD.cs b/win/C#/Parsing/DVD.cs index 31fe2de12..348da3190 100644 --- a/win/C#/Parsing/DVD.cs +++ b/win/C#/Parsing/DVD.cs @@ -4,11 +4,11 @@ Homepage: <http://handbrake.fr>.
It may be used under the terms of the GNU General Public License. */
-using System.Collections.Generic;
-using System.IO;
-
namespace Handbrake.Parsing
{
+ using System.Collections.Generic;
+ using System.IO;
+
/// <summary>
/// An object representing a scanned DVD
/// </summary>
@@ -17,6 +17,7 @@ namespace Handbrake.Parsing private readonly List<Title> m_titles;
/// <summary>
+ /// Initializes a new instance of the <see cref="DVD"/> class.
/// Default constructor for this object
/// </summary>
public DVD()
diff --git a/win/C#/Parsing/Parser.cs b/win/C#/Parsing/Parser.cs index 2fc4e6329..e643d3bd9 100644 --- a/win/C#/Parsing/Parser.cs +++ b/win/C#/Parsing/Parser.cs @@ -4,14 +4,14 @@ Homepage: <http://handbrake.fr>.
It may be used under the terms of the GNU General Public License. */
-using System.IO;
-using System.Text;
-using System.Text.RegularExpressions;
-using System;
-using System.Globalization;
-
namespace Handbrake.Parsing
{
+ using System;
+ using System.Globalization;
+ using System.IO;
+ using System.Text;
+ using System.Text.RegularExpressions;
+
/// <summary>
/// A delegate to handle custom events regarding data being parsed from the buffer
/// </summary>
@@ -37,7 +37,9 @@ namespace Handbrake.Parsing /// <param name="CurrentFps">The current encoding fps</param>
/// <param name="AverageFps">The average encoding fps for this task</param>
/// <param name="TimeRemaining">The estimated time remaining for this task to complete</param>
- public delegate void EncodeProgressEventHandler(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining);
+ public delegate void EncodeProgressEventHandler(
+ object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps,
+ TimeSpan TimeRemaining);
/// <summary>
@@ -45,16 +47,14 @@ namespace Handbrake.Parsing /// </summary>
internal class Parser : StreamReader
{
- private StringBuilder _buffer = new StringBuilder("");
+ private StringBuilder _buffer = new StringBuilder(string.Empty);
+
/// <summary>
/// The output from the CLI process
/// </summary>
- public String Buffer
+ public string Buffer
{
- get
- {
- return _buffer.ToString();
- }
+ get { return _buffer.ToString(); }
}
/// <summary>
@@ -73,16 +73,21 @@ namespace Handbrake.Parsing public event ScanProgressEventHandler OnScanProgress;
#region Experimetnal Code
+
/// <summary>
/// Raised upon the catching of a "Scanning title # of #..." in the stream
/// </summary>
public event EncodeProgressEventHandler OnEncodeProgress;
+
#endregion
/// <summary>
+ /// Initializes a new instance of the <see cref="Parser"/> class.
/// Default constructor for this object
/// </summary>
- /// <param name="baseStream">The stream to parse from</param>
+ /// <param name="baseStream">
+ /// The stream to parse from
+ /// </param>
public Parser(Stream baseStream)
: base(baseStream)
{
@@ -128,7 +133,8 @@ namespace Handbrake.Parsing CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US");
string tmp = base.ReadLine();
- Match m = Regex.Match(tmp, @"^Encoding: task ([0-9]*) of ([0-9]*), ([0-9]*\.[0-9]*) %( \(([0-9]*\.[0-9]*) fps, avg ([0-9]*\.[0-9]*) fps, ETA ([0-9]{2})h([0-9]{2})m([0-9]{2})s\))?");
+ Match m = Regex.Match(tmp,
+ @"^Encoding: task ([0-9]*) of ([0-9]*), ([0-9]*\.[0-9]*) %( \(([0-9]*\.[0-9]*) fps, avg ([0-9]*\.[0-9]*) fps, ETA ([0-9]{2})h([0-9]{2})m([0-9]{2})s\))?");
if (m.Success && OnEncodeProgress != null)
{
int currentTask = int.Parse(m.Groups[1].Value);
@@ -145,4 +151,4 @@ namespace Handbrake.Parsing }
}
}
-}
+}
\ No newline at end of file diff --git a/win/C#/Parsing/Subtitle.cs b/win/C#/Parsing/Subtitle.cs index a765f1de4..178e4470d 100644 --- a/win/C#/Parsing/Subtitle.cs +++ b/win/C#/Parsing/Subtitle.cs @@ -4,12 +4,12 @@ Homepage: <http://handbrake.fr>.
It may be used under the terms of the GNU General Public License. */
-using System.Collections.Generic;
-using System.IO;
-using System.Text.RegularExpressions;
-
namespace Handbrake.Parsing
{
+ using System.Collections.Generic;
+ using System.IO;
+ using System.Text.RegularExpressions;
+
/// <summary>
/// An object that represents a subtitle associated with a Title, in a DVD
/// </summary>
@@ -72,9 +72,9 @@ namespace Handbrake.Parsing {
var thisSubtitle = new Subtitle
{
- m_trackNumber = int.Parse(m.Groups[1].Value.Trim()),
- m_language = m.Groups[2].Value,
- m_typecode = m.Groups[3].Value,
+ m_trackNumber = int.Parse(m.Groups[1].Value.Trim()),
+ m_language = m.Groups[2].Value,
+ m_typecode = m.Groups[3].Value,
m_type = m.Groups[4].Value
};
return thisSubtitle;
diff --git a/win/C#/Parsing/Title.cs b/win/C#/Parsing/Title.cs index e13858fd3..764c7cdbd 100644 --- a/win/C#/Parsing/Title.cs +++ b/win/C#/Parsing/Title.cs @@ -4,15 +4,15 @@ Homepage: <http://handbrake.fr>.
It may be used under the terms of the GNU General Public License. */
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Globalization;
-using System.IO;
-using System.Text.RegularExpressions;
-
namespace Handbrake.Parsing
{
+ using System;
+ using System.Collections.Generic;
+ using System.Drawing;
+ using System.Globalization;
+ using System.IO;
+ using System.Text.RegularExpressions;
+
/// <summary>
/// An object that represents a single Title of a DVD
/// </summary>
@@ -22,7 +22,7 @@ namespace Handbrake.Parsing private readonly List<AudioTrack> m_audioTracks;
private readonly List<Chapter> m_chapters;
private readonly List<Subtitle> m_subtitles;
- private List<String> m_angles = new List<string>();
+ private List<string> m_angles = new List<string>();
private float m_aspectRatio;
private float m_fps;
private int[] m_autoCrop;
@@ -31,8 +31,9 @@ namespace Handbrake.Parsing private Size m_resolution;
private int m_titleNumber;
private Size m_parVal;
-
+
/// <summary>
+ /// Initializes a new instance of the <see cref="Title"/> class.
/// The constructor for this object
/// </summary>
public Title()
@@ -79,7 +80,7 @@ namespace Handbrake.Parsing /// </summary>
public string SourceName
{
- get { return source; }
+ get { return source; }
}
/// <summary>
@@ -142,14 +143,14 @@ namespace Handbrake.Parsing {
get { return m_fps; }
}
-
+
/// <summary>
/// Override of the ToString method to provide an easy way to use this object in the UI
/// </summary>
/// <returns>A string representing this track in the format: {title #} (00:00:00)</returns>
public override string ToString()
{
- return string.Format("{0} ({1:00}:{2:00}:{3:00})", m_titleNumber, m_duration.Hours,
+ return string.Format("{0} ({1:00}:{2:00}:{3:00})", m_titleNumber, m_duration.Hours,
m_duration.Minutes, m_duration.Seconds);
}
@@ -171,15 +172,15 @@ namespace Handbrake.Parsing string path = output.ReadLine();
m = Regex.Match(path, @"^ \+ stream:");
if (m.Success)
- thisTitle.source = path.Replace("+ stream:", "").Trim();
-
+ thisTitle.source = path.Replace("+ stream:", string.Empty).Trim();
+
if (!Properties.Settings.Default.noDvdNav)
{
// Get the Angles for the title.
m = Regex.Match(output.ReadLine(), @" \+ angle\(s\) ([0-9])");
if (m.Success)
{
- String angleList = m.Value.Replace("+ angle(s) ", "").Trim();
+ string angleList = m.Value.Replace("+ angle(s) ", string.Empty).Trim();
int angleCount;
int.TryParse(angleList, out angleCount);
@@ -194,9 +195,9 @@ namespace Handbrake.Parsing thisTitle.m_duration = TimeSpan.Parse(m.Groups[1].Value);
// Get resolution, aspect ratio and FPS for this title
- m = Regex.Match(output.ReadLine(),
+ m = Regex.Match(output.ReadLine(),
@"^ \+ size: ([0-9]*)x([0-9]*), pixel aspect: ([0-9]*)/([0-9]*), display aspect: ([0-9]*\.[0-9]*), ([0-9]*\.[0-9]*) fps");
- //size: 720x576, pixel aspect: 16/15, display aspect: 1.33, 25.000 fps
+ // size: 720x576, pixel aspect: 16/15, display aspect: 1.33, 25.000 fps
if (m.Success)
{
@@ -209,9 +210,9 @@ namespace Handbrake.Parsing // 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[]
+ thisTitle.m_autoCrop = new[]
{
- int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value),
+ int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value),
int.Parse(m.Groups[3].Value), int.Parse(m.Groups[4].Value)
};
|