File indexing completed on 2024-12-22 04:40:10

0001 /*
0002     SPDX-FileCopyrightText: 2007-2009 Sergio Pistone <sergio_pistone@yahoo.com.ar>
0003     SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic <max@smoothware.net>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef INPUTFORMAT_H
0009 #define INPUTFORMAT_H
0010 
0011 #include "format.h"
0012 #include "formatmanager.h"
0013 
0014 namespace SubtitleComposer {
0015 class InputFormat : public Format
0016 {
0017 public:
0018     bool readSubtitle(Subtitle &subtitle, bool primary, const QString &data) const
0019     {
0020         QExplicitlySharedDataPointer<Subtitle> newSubtitle(new Subtitle());
0021 
0022         if(!parseSubtitles(*newSubtitle, data))
0023             return false;
0024 
0025         if(primary)
0026             subtitle.setPrimaryData(*newSubtitle, true);
0027         else
0028             subtitle.setSecondaryData(*newSubtitle, true);
0029 
0030         return true;
0031     }
0032 
0033     virtual bool isBinary() const { return false; }
0034     virtual FormatManager::Status readBinary(Subtitle &, const QUrl &) { return FormatManager::ERROR; }
0035 
0036 protected:
0037     virtual bool parseSubtitles(Subtitle &subtitle, const QString &data) const = 0;
0038 
0039     InputFormat(const QString &name, const QStringList &extensions) : Format(name, extensions) {}
0040 };
0041 }
0042 
0043 #endif