1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
/*
* ImportFilter.h - declaration of class ImportFilter, the base-class for all
* file import filters
*
* Copyright (c) 2006-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of LMMS - https://lmms.io
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#ifndef IMPORT_FILTER_H
#define IMPORT_FILTER_H
#include <QtCore/QFile>
#include "Plugin.h"
class TrackContainer;
class EXPORT ImportFilter : public Plugin
{
public:
ImportFilter( const QString & _file_name,
const Descriptor * _descriptor );
virtual ~ImportFilter();
// tries to import given file to given track-container by having all
// available import-filters to try to import the file
static void import( const QString & _file_to_import,
TrackContainer* tc );
protected:
virtual bool tryImport( TrackContainer* tc ) = 0;
const QFile & file() const
{
return m_file;
}
bool openFile();
inline void closeFile()
{
m_file.close();
}
inline int readByte()
{
unsigned char c;
if( m_file.getChar( (char*) &c ) )
{
return static_cast<int>( c );
}
return -1;
}
inline int readBlock( char * _data, int _len )
{
return m_file.read( _data, _len );
}
inline QByteArray readAllData()
{
m_file.seek(0);
return m_file.readAll();
}
inline void ungetChar( char _ch )
{
m_file.ungetChar( _ch );
}
virtual void saveSettings( QDomDocument &, QDomElement & )
{
}
virtual void loadSettings( const QDomElement & )
{
}
virtual QString nodeName() const
{
return "import_filter";
}
private:
QFile m_file;
} ;
#endif
|