mirror of
https://github.com/markdavidlong/AppleSAWS.git
synced 2026-04-19 14:16:45 +00:00
Modernized interface to GenericFile and aligned all inherited classes
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
#include <QList>
|
||||
#include <QPair>
|
||||
|
||||
ApplesoftFile::ApplesoftFile(QByteArray data) : GenericFile(data)
|
||||
ApplesoftFile::ApplesoftFile(const QByteArray& data) : GenericFile(data)
|
||||
{
|
||||
m_data_end = data.length();
|
||||
|
||||
@@ -22,7 +22,7 @@ ApplesoftFile::ApplesoftFile(QByteArray data) : GenericFile(data)
|
||||
setAddress(0x801);
|
||||
}
|
||||
|
||||
void ApplesoftFile::setData(QByteArray data)
|
||||
void ApplesoftFile::setData(const QByteArray& data)
|
||||
{
|
||||
if (!m_retokenizer)
|
||||
{
|
||||
|
||||
@@ -15,18 +15,18 @@ class ApplesoftRetokenizer;
|
||||
class ApplesoftFile : public GenericFile
|
||||
{
|
||||
public:
|
||||
explicit ApplesoftFile(QByteArray data = {});
|
||||
explicit ApplesoftFile(const QByteArray& data = QByteArray());
|
||||
~ApplesoftFile() override = default;
|
||||
|
||||
void setData(QByteArray data);
|
||||
void setData(const QByteArray& data) override;
|
||||
QByteArray extraData() const;
|
||||
QStringList extraDataHexValues() const;
|
||||
|
||||
const QList<ApplesoftLine>& getLines() const { return m_lines; }
|
||||
|
||||
quint16 length() const { return m_length; }
|
||||
quint16 length() const override { return m_length; }
|
||||
|
||||
QByteArray rawData() const;
|
||||
QByteArray rawData() const override;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <QDebug>
|
||||
#include <QByteArray>
|
||||
|
||||
BinaryFile::BinaryFile(QByteArray data) : GenericFile(data)
|
||||
BinaryFile::BinaryFile(const QByteArray& data) : GenericFile(data)
|
||||
{
|
||||
m_length = 0;
|
||||
|
||||
@@ -13,7 +13,7 @@ BinaryFile::BinaryFile(QByteArray data) : GenericFile(data)
|
||||
}
|
||||
}
|
||||
|
||||
void BinaryFile::setData(QByteArray data)
|
||||
void BinaryFile::setData(const QByteArray& data)
|
||||
{
|
||||
if (data.length() >= 4) {
|
||||
QByteArray metadata = data.left(4);
|
||||
|
||||
@@ -8,8 +8,8 @@ class QByteArray;
|
||||
class BinaryFile : public GenericFile
|
||||
{
|
||||
public:
|
||||
BinaryFile(QByteArray data = QByteArray());
|
||||
void setData(QByteArray data) override;
|
||||
BinaryFile(const QByteArray& data = QByteArray());
|
||||
void setData(const QByteArray& data) override;
|
||||
|
||||
virtual quint16 length() const override { return m_length; }
|
||||
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
#include "GenericFile.h"
|
||||
|
||||
GenericFile::GenericFile(QByteArray data)
|
||||
GenericFile::GenericFile(const QByteArray& data)
|
||||
{
|
||||
m_diskfile = 0;
|
||||
if (!data.isEmpty()) {
|
||||
setData(data);
|
||||
}
|
||||
m_address = 0x00;
|
||||
m_length = 0x00;
|
||||
}
|
||||
|
||||
void GenericFile::setData(QByteArray data)
|
||||
void GenericFile::setData(const QByteArray& data)
|
||||
{
|
||||
m_data = data;
|
||||
m_length = data.size();
|
||||
|
||||
@@ -9,31 +9,31 @@
|
||||
class GenericFile
|
||||
{
|
||||
public:
|
||||
GenericFile(QByteArray data = QByteArray());
|
||||
GenericFile(const QByteArray& data = QByteArray());
|
||||
virtual ~GenericFile() { }
|
||||
|
||||
virtual void setData(QByteArray data);
|
||||
virtual QByteArray data() { return m_data; }
|
||||
virtual void setData(const QByteArray& data);
|
||||
virtual QByteArray data() const { return m_data; }
|
||||
|
||||
void setFilename(QString filename) { m_filename = filename; }
|
||||
QString filename() const { return m_filename; }
|
||||
inline void setFilename(const QString& filename) { m_filename = filename; }
|
||||
inline QString filename() const { return m_filename; }
|
||||
|
||||
virtual void setAddress(quint16 location) { m_address = location; }
|
||||
virtual quint16 address() { return m_address; }
|
||||
virtual quint16 address() const { return m_address; }
|
||||
|
||||
virtual QByteArray rawData() { return m_data; }
|
||||
virtual QByteArray rawData() const { return m_data; }
|
||||
|
||||
virtual void setLength(quint16 length) { m_length = length; }
|
||||
virtual quint16 length() const { return m_length; }
|
||||
|
||||
DiskFile *diskFile() const { return m_diskfile; }
|
||||
void setDiskFile(DiskFile *diskfile) { m_diskfile = diskfile; }
|
||||
inline DiskFile *diskFile() const { return m_diskfile; }
|
||||
inline void setDiskFile(DiskFile *diskfile) { m_diskfile = diskfile; }
|
||||
|
||||
protected:
|
||||
QByteArray m_data;
|
||||
QString m_filename;
|
||||
QByteArray m_data{};
|
||||
QString m_filename{};
|
||||
quint16 m_address{0};
|
||||
qint16 m_length{0};
|
||||
DiskFile * m_diskfile{nullptr};
|
||||
quint16 m_length{0};
|
||||
DiskFile *m_diskfile{nullptr};
|
||||
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "IntBasicFile.h"
|
||||
#include <QDebug>
|
||||
|
||||
IntBasicFile::IntBasicFile(QByteArray data)
|
||||
IntBasicFile::IntBasicFile(const QByteArray& data)
|
||||
{
|
||||
setData(data);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
class IntBasicFile : public GenericFile
|
||||
{
|
||||
public:
|
||||
IntBasicFile(QByteArray data = QByteArray());
|
||||
IntBasicFile(const QByteArray& data = QByteArray());
|
||||
|
||||
QByteArray detokenize();
|
||||
private:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <QDebug>
|
||||
#include "RelocatableFile.h"
|
||||
|
||||
RelocatableFile::RelocatableFile(QByteArray data) : GenericFile(data)
|
||||
RelocatableFile::RelocatableFile(const QByteArray& data) : GenericFile(data)
|
||||
{
|
||||
// qDebug() << "Relocatable file ctor";
|
||||
if (!data.isEmpty()) {
|
||||
@@ -9,7 +9,7 @@ RelocatableFile::RelocatableFile(QByteArray data) : GenericFile(data)
|
||||
}
|
||||
}
|
||||
|
||||
void RelocatableFile::setData(QByteArray data)
|
||||
void RelocatableFile::setData(const QByteArray& data)
|
||||
{
|
||||
// qDebug() << "setData()";
|
||||
if (data.length() >= 6) {
|
||||
|
||||
@@ -78,10 +78,10 @@ class RelocatableFile : public GenericFile
|
||||
{
|
||||
public:
|
||||
|
||||
RelocatableFile(QByteArray data = QByteArray());
|
||||
void setData(QByteArray data);
|
||||
RelocatableFile(const QByteArray& data = QByteArray());
|
||||
void setData(const QByteArray& data) override;
|
||||
|
||||
virtual quint16 length() const { return m_data.length(); }
|
||||
virtual quint16 length() const override { return m_data.length(); }
|
||||
|
||||
void dump();
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#include <QDebug>
|
||||
#include "TextFile.h"
|
||||
|
||||
TextFile::TextFile(QByteArray data) : GenericFile(data)
|
||||
TextFile::TextFile(const QByteArray& data) : GenericFile(data)
|
||||
{
|
||||
if (!data.isEmpty()) {
|
||||
setData(data);
|
||||
}
|
||||
}
|
||||
|
||||
void TextFile::setData(QByteArray data)
|
||||
void TextFile::setData(const QByteArray& data)
|
||||
{
|
||||
m_data = data;
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
class TextFile : public GenericFile
|
||||
{
|
||||
public:
|
||||
TextFile(QByteArray data = QByteArray());
|
||||
void setData(QByteArray data);
|
||||
TextFile(const QByteArray& data = QByteArray());
|
||||
void setData(const QByteArray& data) override;
|
||||
|
||||
void dump();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user