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