Debian Codegraph @

libqnapi/src/subconvert/formats/subrip.h

raw symbols SCIP
1 /*****************************************************************************
2 ** QNapi
3 ** Copyright (C) 2008-2017 Piotr KrzemiƄski <[email protected]>
4 **
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 of the License, or
8 ** (at your option) any later version.
9 **
10 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12 **
13 *****************************************************************************/
14
15 #ifndef SUBRIPSUBTITLEFORMAT_H
16 #define SUBRIPSUBTITLEFORMAT_H
17
18 #include "subconvert/subtitleformat.h"
19
20 class SubRipSubtitleFormat : public SubtitleFormat {
21 public:
22 virtual ~SubRipSubtitleFormat() {}
23
24 bool isTimeBased() const { return true; }
25 QString formatName() const { return "SRT"; }
26 QString defaultExtension() const { return "srt"; }
27
28 bool detect(const QStringList &lines) const;
29 SubFile decode(const QStringList &lines) const;
30 QStringList encode(const SubFile &subFile) const;
31
32 private:
33 struct SrtTimestamps {
34 int h1;
35 int m1;
36 int s1;
37 int ms1;
38 int h2;
39 int m2;
40 int s2;
41 int ms2;
42 };
43
44 void addEntry(QVector<SubEntry> &entries, QString &tokensBuff,
45 SrtTimestamps &timestamps) const;
46 QStringList encodeEntry(const SubEntry &entry, int i) const;
47 QString encodeToken(const SubToken &entry) const;
48 };
49
50 #endif // SUBRIPSUBTITLEFORMAT_H