diff options
author | brianmario <[email protected]> | 2007-07-19 03:46:40 +0000 |
---|---|---|
committer | brianmario <[email protected]> | 2007-07-19 03:46:40 +0000 |
commit | 5a85699f791f49ea7643ec2335d919d152410652 (patch) | |
tree | c86fd1ac50e4e70b1bebc02389111457aed3fd84 /win/C#/Parsing/Chapter.cs | |
parent | 34ec0f7cfb452f851cd2e59278b19ba724c50fa6 (diff) |
WinGui:
misc UI control placement changes
updates to some FormBorderStyle's
converted Parsing code to use regex instead of substrings and string splitting
added a couple of additional code comments
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@715 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/Parsing/Chapter.cs')
-rw-r--r-- | win/C#/Parsing/Chapter.cs | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/win/C#/Parsing/Chapter.cs b/win/C#/Parsing/Chapter.cs index c824fcd68..665841e97 100644 --- a/win/C#/Parsing/Chapter.cs +++ b/win/C#/Parsing/Chapter.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic;
using System.Text;
using System.IO;
+using System.Text.RegularExpressions;
namespace Handbrake.Parsing
{
@@ -43,15 +44,14 @@ namespace Handbrake.Parsing return this.m_chapterNumber.ToString();
}
- public static Chapter Parse(StreamReader output)
+ public static Chapter Parse(StringReader output)
{
- string curLine = output.ReadLine();
- if (!curLine.Contains(" + audio tracks:"))
+ 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)
{
Chapter thisChapter = new Chapter();
- string[] splitter = curLine.Split(new string[] { " + ", ": cells ", ", ", " blocks, duration ", "->" }, StringSplitOptions.RemoveEmptyEntries);
- thisChapter.m_chapterNumber = int.Parse(splitter[0]);
- thisChapter.m_duration = TimeSpan.Parse(splitter[4]);
+ thisChapter.m_chapterNumber = int.Parse(m.Groups[1].Value);
+ thisChapter.m_duration = TimeSpan.Parse(m.Groups[5].Value);
return thisChapter;
}
else
@@ -60,14 +60,19 @@ namespace Handbrake.Parsing }
}
- public static Chapter[] ParseList(StreamReader output)
+ public static Chapter[] ParseList(StringReader output)
{
List<Chapter> chapters = new List<Chapter>();
- string curLine = output.ReadLine();
- while (!curLine.Contains(" + audio tracks:"))
+
+ // this is to read the " + chapters:" line from the buffer
+ // so we can start reading the chapters themselvs
+ output.ReadLine();
+
+ while (true)
{
+ // Start of the chapter list for this Title
Chapter thisChapter = Chapter.Parse(output);
-
+
if (thisChapter != null)
{
chapters.Add(thisChapter);
|