mirror of
https://github.com/markdavidlong/AppleSAWS.git
synced 2026-04-20 05:16:40 +00:00
Cleaned up src/applesoftfile/*
This commit is contained in:
@@ -14,7 +14,7 @@ ApplesoftFormatter::ApplesoftFormatter(QObject *parent) :
|
||||
{
|
||||
}
|
||||
|
||||
void ApplesoftFormatter::setFile(ApplesoftFile *file)
|
||||
void ApplesoftFormatter::setFile(ApplesoftFile *file) noexcept
|
||||
{
|
||||
m_file = file;
|
||||
emit newFile(file);
|
||||
|
||||
@@ -29,19 +29,17 @@ public:
|
||||
Q_DECLARE_FLAGS(FormatOptions, FormatOption)
|
||||
|
||||
public:
|
||||
explicit ApplesoftFormatter(QObject *parent = 0);
|
||||
void setFlags(FormatOptions options) { m_format_options = options; }
|
||||
void setFile(ApplesoftFile *file);
|
||||
explicit ApplesoftFormatter(QObject *parent = nullptr);
|
||||
void setFlags(FormatOptions options) noexcept { m_format_options = options; }
|
||||
void setFile(ApplesoftFile *file) noexcept;
|
||||
|
||||
FormatOptions flags() { return m_format_options; }
|
||||
[[nodiscard]] FormatOptions flags() const noexcept { return m_format_options; }
|
||||
|
||||
void formatDocument(QTextDocument *doc);
|
||||
|
||||
signals:
|
||||
void newFile(ApplesoftFile *file);
|
||||
|
||||
public slots:
|
||||
|
||||
private:
|
||||
FormatOptions m_format_options{FormatOption::NoOptions};
|
||||
ApplesoftFile *m_file{nullptr};
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "ApplesoftToken.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QList>
|
||||
|
||||
class ApplesoftToken;
|
||||
|
||||
struct ApplesoftLine {
|
||||
qint16 address{0};
|
||||
quint16 next_address{0};
|
||||
quint16 linenum{0};
|
||||
QList<ApplesoftToken> tokens;
|
||||
QList<ApplesoftToken> tokens{};
|
||||
|
||||
// Applesoft BASIC maximum line number
|
||||
static constexpr quint16 MAX_LINE_NUMBER = 63999;
|
||||
|
||||
// Utility methods for modern C++
|
||||
[[nodiscard]] constexpr bool isValid() const noexcept { return linenum <= MAX_LINE_NUMBER; }
|
||||
[[nodiscard]] bool isEmpty() const noexcept { return tokens.isEmpty(); }
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ ApplesoftRetokenizer::ApplesoftRetokenizer()
|
||||
m_isParsed = false;
|
||||
}
|
||||
|
||||
void ApplesoftRetokenizer::setData(QByteArray data)
|
||||
void ApplesoftRetokenizer::setData(const QByteArray& data)
|
||||
{
|
||||
m_data = data;
|
||||
m_data_end = data.length();
|
||||
|
||||
@@ -13,14 +13,14 @@ class ApplesoftRetokenizer
|
||||
public:
|
||||
ApplesoftRetokenizer();
|
||||
|
||||
void setData(QByteArray data);
|
||||
void setData(const QByteArray& data);
|
||||
void parse(quint16 start_address = 0x0801);
|
||||
|
||||
quint16 getEndOfDataOffset() const { return m_data_end; }
|
||||
[[nodiscard]] quint16 getEndOfDataOffset() const noexcept { return m_data_end; }
|
||||
|
||||
QList<ApplesoftLine> getRetokenizedLines() { return m_retokenized_lines; }
|
||||
[[nodiscard]] const QList<ApplesoftLine>& getRetokenizedLines() const noexcept { return m_retokenized_lines; }
|
||||
|
||||
QList<QPair<quint16, quint16> > getFlowTargets() const { return m_flowTargets; }
|
||||
[[nodiscard]] const QList<QPair<quint16, quint16>>& getFlowTargets() const noexcept { return m_flowTargets; }
|
||||
|
||||
private:
|
||||
void retokenizeLinesForFormatting();
|
||||
|
||||
@@ -235,41 +235,41 @@ public:
|
||||
};
|
||||
|
||||
ApplesoftToken();
|
||||
ApplesoftToken(quint16 id);
|
||||
explicit ApplesoftToken(quint16 id);
|
||||
ApplesoftToken(quint16 id, QVariant payload);
|
||||
|
||||
void setTokenId(quint16 id);
|
||||
inline quint16 getTokenId() const { return m_token_id; }
|
||||
[[nodiscard]] inline quint16 getTokenId() const noexcept { return m_token_id; }
|
||||
|
||||
void setValue(QVariant value);
|
||||
inline QVariant getValue() const { return m_payload; }
|
||||
[[nodiscard]] inline QVariant getValue() const noexcept { return m_payload; }
|
||||
|
||||
inline QByteArray getByteStringValue() const { return m_payload.toByteArray(); }
|
||||
QString getStringValue() const;
|
||||
inline quint32 getUnsignedIntegerValue() const { return m_payload.toUInt(); }
|
||||
inline qint32 getIntegerValue() const { return m_payload.toInt(); }
|
||||
[[nodiscard]] inline QByteArray getByteStringValue() const noexcept { return m_payload.toByteArray(); }
|
||||
[[nodiscard]] QString getStringValue() const;
|
||||
[[nodiscard]] inline quint32 getUnsignedIntegerValue() const noexcept { return m_payload.toUInt(); }
|
||||
[[nodiscard]] inline qint32 getIntegerValue() const noexcept { return m_payload.toInt(); }
|
||||
|
||||
inline quint16 getWordValue() const { return quint16(m_payload.toUInt() & 0xFFFF); }
|
||||
inline quint8 getByteValue() const { return quint8(m_payload.toUInt() & 0xFF); }
|
||||
[[nodiscard]] inline quint16 getWordValue() const noexcept { return quint16(m_payload.toUInt() & 0xFFFF); }
|
||||
[[nodiscard]] inline quint8 getByteValue() const noexcept { return quint8(m_payload.toUInt() & 0xFF); }
|
||||
|
||||
inline TokenType getTokenType() const { return m_token_type; }
|
||||
inline CommandType getCommandType() const { return m_command_type; }
|
||||
[[nodiscard]] inline TokenType getTokenType() const noexcept { return m_token_type; }
|
||||
[[nodiscard]] inline CommandType getCommandType() const noexcept { return m_command_type; }
|
||||
|
||||
QString getRawPrintableString() const;
|
||||
[[nodiscard]] QString getRawPrintableString() const;
|
||||
|
||||
QTextCharFormat textFormat();
|
||||
[[nodiscard]] QTextCharFormat textFormat();
|
||||
|
||||
static QTextCharFormat defaultTextFormat();
|
||||
static QTextCharFormat defaultInverseTextFormat();
|
||||
static QTextCharFormat textFormat(quint16 tokentype) ;
|
||||
[[nodiscard]] static QTextCharFormat defaultTextFormat();
|
||||
[[nodiscard]] static QTextCharFormat defaultInverseTextFormat();
|
||||
[[nodiscard]] static QTextCharFormat textFormat(quint16 tokentype);
|
||||
|
||||
QString getStringForToken(quint8 token);
|
||||
[[nodiscard]] QString getStringForToken(quint8 token);
|
||||
|
||||
inline bool isOptFmtToken() const { return (m_token_id >= OptFmtRangeStart && m_token_id < OptFmtRangeEnd); }
|
||||
[[nodiscard]] inline bool isOptFmtToken() const noexcept { return (m_token_id >= OptFmtRangeStart && m_token_id < OptFmtRangeEnd); }
|
||||
|
||||
private:
|
||||
quint16 m_token_id{0};
|
||||
QString m_tokenname{""};
|
||||
QString m_tokenname{};
|
||||
QVariant m_payload{};
|
||||
TokenType m_token_type{TokenType::Unknown};
|
||||
CommandType m_command_type{CommandType::None};
|
||||
|
||||
Reference in New Issue
Block a user