Merge with MPC-HC 6d1472b2f18266d92e5bc068667de348c0cd3b3b.
[xy_vsfilter.git] / src / subtitles / libssf / SubtitleFile.h
blobb58798d53690b9a084718309e4a81711335a1c76
1 /*
2 * Copyright (C) 2003-2006 Gabest
3 * http://www.gabest.org
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
8 * any later version.
9 *
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GNU Make; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
22 #pragma once
24 #include "File.h"
25 #include "Subtitle.h"
27 namespace ssf
29 class SubtitleFile : public File
31 static LPCWSTR s_predef;
33 public:
34 struct SegmentItem
36 Definition* pDef;
37 float start, stop;
40 class Segment : public CAtlList<SegmentItem>
42 public:
43 float m_start, m_stop;
44 Segment() {}
45 Segment(float start, float stop, const SegmentItem* si = NULL);
46 Segment(const Segment& s);
47 void operator = (const Segment& s);
50 class SegmentList : public CAtlList<Segment>
52 CAtlArray<Segment*> m_index;
53 size_t Index(bool fForce = false);
55 public:
56 void RemoveAll();
57 void Insert(float start, float stop, Definition* pDef);
58 void Lookup(float at, CAtlList<SegmentItem>& sis);
59 bool Lookup(float at, size_t& k);
60 const Segment* GetSegment(size_t k);
63 SegmentList m_segments;
65 public:
66 SubtitleFile();
67 virtual ~SubtitleFile();
69 void Parse(InputStream& s);
70 void Append(InputStream& s, float start, float stop, bool fSetTime = false);
71 bool Lookup(float at, CAutoPtrList<Subtitle>& subs);