Skip to content

Commit

Permalink
Added source copy from private repository on Bitbucket
Browse files Browse the repository at this point in the history
  • Loading branch information
oblivioncth committed Sep 22, 2019
1 parent 00990eb commit 668fb25
Show file tree
Hide file tree
Showing 41 changed files with 7,936 additions and 0 deletions.
67 changes: 67 additions & 0 deletions CoH_BSC_Editor.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#-------------------------------------------------
#
# Project created by QtCreator 2019-08-05T12:25:36
#
#-------------------------------------------------

QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = BSCWorks
TEMPLATE = app

# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

CONFIG += c++17
QMAKE_CXXFLAGS += /std:c++17

SOURCES += \
src/bsc.cpp \
src/main.cpp \
src/mainwindow.cpp \
src/smc.cpp \
src/smf.cpp \
src/wav.cpp

HEADERS += \
resources.rc \
src/bsc.h \
src/mainwindow.h \
src/smc.h \
src/smf.h \
src/version.h \
src/wav.h

FORMS += \
src/mainwindow.ui

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

RESOURCES += \
resources.qrc

RC_FILE = resources.rc

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/lib/ -lqxtended_static_0_0_1_0_Qt_5_12_3
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/lib/ -lqxtended_static_0_0_1_0_Qt_5_12_3d

INCLUDEPATH += $$PWD/include
DEPENDPATH += $$PWD/include

win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/lib/libqxtended_static_0_0_1_0_Qt_5_12_3.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/lib/libqxtended_static_0_0_1_0_Qt_5_12_3d.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/lib/qxtended_static_0_0_1_0_Qt_5_12_3.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/lib/qxtended_static_0_0_1_0_Qt_5_12_3d.lib
36 changes: 36 additions & 0 deletions include/Windows_c++17_compat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* ----------------- C++17 Compatible Windows.h Header ------------------ */
/* In C++ 17 the type std::byte was added to act as a formal method
* to store raw, uninterpreted data so that the practice of using
* "unsigned char" would no longer be required and the "char" type
* would finally be used exclusively for the storage of 8-bit
* characters. This was a beneficial addition, but unfortunately
* caused compatability issues with the windows SDK (at least as of
* Windows 10 SDK 10.0.17763.132); the ancient header "rpcndr.h" that
* is part of "Windows.h" contains:
*
* typedef unsigned char byte;
*
* which adds a definition of "byte" to the global namespace instead
* of a Windows SDK specific namespace as it should have been. This
* clashes with "byte" and makes the type ambiguous when utilizing
* "using namespace std;". This can be worked around by only including
* the poritions of the Windows SDK that are required for a project
* instead of including "Windows.h" directly or stricly avoiding the
* use of "using namespace std;".
*
* If neither of these options are practical, this file can be substituted
* for "Windows.h" instead. This header uses a macro to change "byte" to
* "WIN_BYTE" during the inclusion of "Windows.h" only so that the Windows
* SDK still compiles correctly but no longer clashes with std::byte.
*
* - oblivioncth
*/

#ifndef WINDOWS_C17_COMPAT_H
#define WINDOWS_C17_COMPAT_H

#define byte WIN_BYTE
#include "Windows.h"
#undef byte

#endif // WINDOWS_C17_COMPAT_H
141 changes: 141 additions & 0 deletions include/qx-io.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
#ifndef QXIO_H
#define QXIO_H

#include <QString>
#include <QList>
#include <QFile>
#include <QDir>
#include <QCryptographicHash>
#include <QTextStream>

namespace Qx
{
//-Classes--------------------------------------------------------------------------------------------------
class IO
{
//-Inner Class Forward Declarations---------------------------------------------------------------------------------------
public:
class IOOpReport;
class TextPos;
//-Class Types------------------------------------------------------------------------------------------------------
public:
enum IOOpType { IO_OP_READ, IO_OP_WRITE, IO_OP_ENUMERATE, IO_OP_INSPECT };
enum IOOpResultType { IO_SUCCESS, IO_ERR_UNKNOWN, IO_ERR_ACCESS_DENIED, IO_ERR_NOT_A_FILE, IO_ERR_NOT_A_DIR, IO_ERR_OUT_OF_RES,
IO_ERR_READ, IO_ERR_WRITE, IO_ERR_FATAL, IO_ERR_OPEN, IO_ERR_ABORT,
IO_ERR_TIMEOUT, IO_ERR_REMOVE, IO_ERR_RENAME, IO_ERR_REPOSITION,
IO_ERR_RESIZE, IO_ERR_COPY, IO_ERR_FILE_DNE, IO_ERR_DIR_DNE,
IO_ERR_FILE_EXISTS, IO_ERR_CANT_MAKE_DIR, IO_ERR_FILE_SIZE_MISMATCH, IO_ERR_CURSOR_OOB};
enum IOOpTargetType { IO_FILE, IO_DIR };

//-Class Variables-------------------------------------------------------------------------------------------------
public:
static inline QString ENDL = "\r\n"; //NOTE: Currently this is windows only

//- Class Functions-------------------------------------------------------------------------------------------------------------
private:
static IOOpResultType parsedOpen(QFile& file, QIODevice::OpenMode openMode);
static IOOpResultType translateQFileDeviceError(QFileDevice::FileError fileError);
static IOOpResultType translateQTextStreamStatus(QTextStream::Status fileStatus);
static IOOpResultType fileCheck(QFile& file);
static IOOpResultType directoryCheck(QDir& dir);

public:
// General:
static bool fileIsEmpty(QFile& file);
static bool fileIsEmpty(QFile& file, IOOpReport& reportBuffer);
// Text Based:
static IOOpReport findStringInFile(TextPos& returnBuffer, QFile& textFile, const QString& query, int hitsToSkip = 0);
static IOOpReport readTextFromFile(QString& returnBuffer, QFile& textFile, TextPos textPos, int characters = -1);
static IOOpReport readTextRangeFromFile(QString& returnBuffer, QFile& textFile, TextPos startPos, TextPos endPos = TextPos(-1,-1));
static IOOpReport readAllTextFromFile(QString& returnBuffer, QFile& textFile);
static IOOpReport readAllTextFromFileByLine(QStringList& returnBuffer, QFile &textFile, int startLine, int endLine = -1);
static IOOpReport writeStringAsFile(QFile &textFile, const QString& text, bool overwriteIfExist = false, bool createDirs = true);
// Directory Based:
static IOOpReport getDirFileList(QStringList& returnBuffer, QDir directory, bool includeSubdirectories = false, QStringList extFilter = QStringList());
static bool dirContainsFiles(QDir directory, bool includeSubdirectories = false);
static bool dirContainsFiles(QDir directory, IOOpReport& reportBuffer, bool includeSubdirectories = false);
// Integrity Based
static IOOpReport calculateFileChecksum(QByteArray& returnBuffer, QFile& file, QCryptographicHash::Algorithm hashAlgorithm);
// Raw Based
static IOOpReport readAllBytesFromFile(QByteArray& returnBuffer, QFile &file);
static IOOpReport readBytesFromFile(QByteArray& returnBuffer, QFile &file, long long start, long long end = -1);
static IOOpReport writeBytesAsFile(QFile &file, const QByteArray &byteArray, bool overwriteIfExist = false, bool createDirs = true);

//-Inner Classes--------------------------------------------------------------------------------------------
public:
class IOOpReport
{
//-Class Members----------------------------------------------------------------------------------------------------
public:
static const inline QStringList TARGET_TYPES = {"file", "directory"};
static const inline QString SUCCESS_TEMPLATE = "Succesfully %1 ""%3""";
static const inline QString ERROR_TEMPLATE = "Error while %1 ""%3""";
static const inline QStringList SUCCESS_VERBS = {"read", "wrote", "enumerated", "inspecting"};
static const inline QStringList ERROR_VERBS = {"reading", "writing", "enumerating", "inspecting"};
static const inline QStringList ERROR_INFO = {"An unknown error has occured.", "Access denied.", "Target is not a file.", "Target is not a directory.", "Out of resources.",
"General read error.", "General write error.", "A fatal error has occured.", "Could not open file.", "The opperation was aborted.",
"Request timed out.", "The file could not be removed.", "The file could not be renamed.", "The file could not be moved.",
"The file could not be resized.", "The file could not be copied.", "File does not exist.", "Directory does not exist.",
"The file already exists.", "The directory could not be created.", "File size mismatch.", "File data cursor has gone out of bounds."};

//-Instance Members-------------------------------------------------------------------------------------------------
private:
IOOpType mOperation;
IOOpResultType mResult;
IOOpTargetType mTargetType;
QString mTarget = QString();
QString mOutcome = QString();
QString mOutcomeInfo = QString();
//-Constructor-------------------------------------------------------------------------------------------------------
public:
IOOpReport();
IOOpReport(IOOpType op, IOOpResultType res, QFile& tar);
IOOpReport(IOOpType op, IOOpResultType res, QDir& tar);

//-Instance Functions----------------------------------------------------------------------------------------------
public:
IOOpType getOperation() const;
IOOpResultType getResult() const;
IOOpTargetType getTargetType() const;
QString getTarget() const;
QString getOutcome() const;
QString getOutcomeInfo() const;
bool wasSuccessful() const;
private:
void parseOutcome();
};

class TextPos {
//-Class Types------------------------------------------------------------------------------------------------------
public:
static const TextPos START;
static const TextPos END;
//-Instance Variables------------------------------------------------------------------------------------------------
private:
int mLineNum;
int mCharNum;
//-Constructor-------------------------------------------------------------------------------------------------------
public:
TextPos();
TextPos(int lineNum, int charNum);

//-Instance Functions------------------------------------------------------------------------------------------------
public:
int getLineNum();
int getCharNum();
void setLineNum(int lineNum);
void setCharNum(int charNum);
void setNull();
bool isNull();

bool operator== (const TextPos &otherTextPos);
bool operator!= (const TextPos &otherTextPos);
bool operator> (const TextPos &otherTextPos);
bool operator>= (const TextPos &otherTextPos);
bool operator< (const TextPos &otherTextPos);
bool operator<= (const TextPos &otherTextPos);
};
};
}

#endif // IO_H
Loading

0 comments on commit 668fb25

Please sign in to comment.