2 using System.Collections.Generic;
\r
5 using System.Text.RegularExpressions;
\r
7 namespace Handbrake.Parsing
\r
10 /// An object representing a Chapter aosciated with a Title, in a DVD
\r
12 public class Chapter
\r
14 private int m_chapterNumber;
\r
16 /// The number of this Chapter, in regards to it's parent Title
\r
18 public int ChapterNumber
\r
22 return this.m_chapterNumber;
\r
26 private TimeSpan m_duration;
\r
28 /// The length in time this Chapter spans
\r
30 public TimeSpan Duration
\r
34 return this.m_duration;
\r
39 /// Override of the ToString method to make this object easier to use in the UI
\r
41 /// <returns>A string formatted as: {chapter #}</returns>
\r
42 public override string ToString()
\r
44 return this.m_chapterNumber.ToString();
\r
47 public static Chapter Parse(StringReader output)
\r
49 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})");
\r
52 Chapter thisChapter = new Chapter();
\r
53 thisChapter.m_chapterNumber = int.Parse(m.Groups[1].Value.Trim().ToString());
\r
54 thisChapter.m_duration = TimeSpan.Parse(m.Groups[5].Value);
\r
63 public static Chapter[] ParseList(StringReader output)
\r
65 List<Chapter> chapters = new List<Chapter>();
\r
67 // this is to read the " + chapters:" line from the buffer
\r
68 // so we can start reading the chapters themselvs
\r
73 // Start of the chapter list for this Title
\r
74 Chapter thisChapter = Chapter.Parse(output);
\r
76 if (thisChapter != null)
\r
78 chapters.Add(thisChapter);
\r
85 return chapters.ToArray();
\r