diff --git a/lib/core/doc/res/snippets/qx-index.cpp b/lib/core/doc/res/snippets/qx-index.cpp index 2ec283f0..3c771beb 100644 --- a/lib/core/doc/res/snippets/qx-index.cpp +++ b/lib/core/doc/res/snippets/qx-index.cpp @@ -1,10 +1,10 @@ //! [0] -Index::LAST + 10 // = Index::LAST -Index::LAST - 10 // = Index::LAST -Index(5) + Index::LAST // = Index::LAST -Index(1087) - Index::LAST // = 0 -Index::LAST * 130 // = Index::LAST -Index::LAST / 58 // = Index::LAST -Index::LAST / Index::LAST // = 1 -Index(98) / Index::LAST // = 0 +Index(Qx::Last) + 10 // = Index(Qx::Last) +Index(Qx::Last) - 10 // = Index(Qx::Last) +Index(5) + Index(Qx::Last) // = Index(Qx::Last) +Index(1087) - Index(Qx::Last) // = 0 +Index(Qx::Last) * 130 // = Index(Qx::Last) +Index(Qx::Last) / 58 // = Index(Qx::Last) +Index(Qx::Last) / Index(Qx::Last) // = 1 +Index(98) / Index(Qx::Last) // = 0 //! [0] \ No newline at end of file diff --git a/lib/core/include/qx/core/qx-global.h b/lib/core/include/qx/core/qx-global.h index 86b8d302..6c1f6491 100644 --- a/lib/core/include/qx/core/qx-global.h +++ b/lib/core/include/qx/core/qx-global.h @@ -14,6 +14,14 @@ enum Severity Critical = 3 }; +enum Extent +{ + First, + Start = First, + Last, + End = Last +}; + //-Namespace Functions----------------------------------------------------------------------------------------------------------- QString severityString(Severity sv, bool uc = true); diff --git a/lib/core/include/qx/core/qx-index.h b/lib/core/include/qx/core/qx-index.h index 4da655cf..14fb1ca5 100644 --- a/lib/core/include/qx/core/qx-index.h +++ b/lib/core/include/qx/core/qx-index.h @@ -10,6 +10,7 @@ #include // Intra-component Includes +#include "qx/core/qx-global.h" #include "qx/core/qx-algorithm.h" namespace Qx @@ -23,13 +24,6 @@ class Index private: enum class Type {Null, End, Value}; -public: - enum Extent - { - First, - Last - }; - //-Instance Members---------------------------------------------------------------------------------------------------- private: Type mType; diff --git a/lib/core/src/qx-global.cpp b/lib/core/src/qx-global.cpp index 9b96dee1..9f9866db 100644 --- a/lib/core/src/qx-global.cpp +++ b/lib/core/src/qx-global.cpp @@ -13,21 +13,33 @@ namespace Qx * @enum Severity * * This enum represents the the severity of an error/outcome. - */ - -/*! + * * @var Severity Warning * A warning. - */ - -/*! + * * @var Severity Err * An error. + * + * @var Severity Critical + * A critical/fatal error. */ /*! - * @var Severity Critical - * A critical/fatal error. + * @enum Extent + * + * Used to refer the extents of a range. + * + * @var Extent First + * The beginning of a range, or its first unit. + * + * @var Extent Start + * Equivalent to First. + * + * @var Extent Last + * The end of a range, or its last unit. + * + * @var Extent End + * Equivalent to Last. */ //-Namespace Functions----------------------------------------------------------------------------------------------------------- diff --git a/lib/core/src/qx-index.dox b/lib/core/src/qx-index.dox index 3d1a329a..8f128774 100644 --- a/lib/core/src/qx-index.dox +++ b/lib/core/src/qx-index.dox @@ -52,21 +52,6 @@ namespace Qx * @li 2) 'last' indices are greater than everything except other 'last' indices (highest possible value) */ -//-Class Types---------------------------------------------------------------------------------------------------- -//Public: -// TODO: Report this as a Doxygen bug, likely should need to be Index::Extent -/*! - * @enum Index::Extent - * - * Used to refer to indicies of special significance. - * - * @var Index::Extent Index::First - * The first index, equivalent to @c Index(0). - * - * @var Index::Extent Index::Last - * The last index. - */ - //-Constructor---------------------------------------------------------------------------------------------- //Public: /*! @@ -102,7 +87,7 @@ namespace Qx * * Returns @c true if the index represents the last index of an arbitrary dataset; otherwise returns @c false. * - * This is equivalent to *this == Index(Last). + * This is equivalent to *this == Index(Qx::Last). */ //-Operators------------------------------------------------------------------------------------------------------- diff --git a/lib/io/include/qx/io/qx-common-io.h b/lib/io/include/qx/io/qx-common-io.h index e8888c09..3ba84302 100644 --- a/lib/io/include/qx/io/qx-common-io.h +++ b/lib/io/include/qx/io/qx-common-io.h @@ -62,10 +62,10 @@ QX_IO_EXPORT IoOpReport textFileAbsolutePosition(TextPos& textPos, QFile& textFi QX_IO_EXPORT IoOpReport findStringInFile(QList& returnBuffer, QFile& textFile, const TextQuery& query, ReadOptions readOptions = NoReadOptions); QX_IO_EXPORT IoOpReport fileContainsString(bool& returnBuffer, QFile& textFile, const QString& query, Qt::CaseSensitivity caseSensitivity = Qt::CaseSensitive, bool allowSplit = false); QX_IO_EXPORT IoOpReport readTextFromFile(QString& returnBuffer, QFile& textFile, TextPos startPos, int count, ReadOptions readOptions = NoReadOptions); -QX_IO_EXPORT IoOpReport readTextFromFile(QString& returnBuffer, QFile& textFile, TextPos startPos = TextPos(TextPos::Start), TextPos endPos = TextPos(TextPos::End), ReadOptions readOptions = NoReadOptions); -QX_IO_EXPORT IoOpReport readTextFromFile(QStringList& returnBuffer, QFile& textFile, Index32 startLine = 0, Index32 endLine = Index32(Index32::Last), ReadOptions readOptions = NoReadOptions); -QX_IO_EXPORT IoOpReport writeStringToFile(QFile& textFile, const QString& text, WriteMode writeMode = Truncate, TextPos startPos = TextPos(TextPos::Start), WriteOptions writeOptions = NoWriteOptions); -QX_IO_EXPORT IoOpReport writeStringToFile(QSaveFile& textFile, const QString& text, WriteMode writeMode = Truncate, TextPos startPos = TextPos(TextPos::Start), WriteOptions writeOptions = NoWriteOptions); +QX_IO_EXPORT IoOpReport readTextFromFile(QString& returnBuffer, QFile& textFile, TextPos startPos = TextPos(Start), TextPos endPos = TextPos(End), ReadOptions readOptions = NoReadOptions); +QX_IO_EXPORT IoOpReport readTextFromFile(QStringList& returnBuffer, QFile& textFile, Index32 startLine = 0, Index32 endLine = Index32(Last), ReadOptions readOptions = NoReadOptions); +QX_IO_EXPORT IoOpReport writeStringToFile(QFile& textFile, const QString& text, WriteMode writeMode = Truncate, TextPos startPos = TextPos(Start), WriteOptions writeOptions = NoWriteOptions); +QX_IO_EXPORT IoOpReport writeStringToFile(QSaveFile& textFile, const QString& text, WriteMode writeMode = Truncate, TextPos startPos = TextPos(Start), WriteOptions writeOptions = NoWriteOptions); QX_IO_EXPORT IoOpReport deleteTextFromFile(QFile& textFile, TextPos startPos, TextPos endPos); // Directory: @@ -81,7 +81,7 @@ QX_IO_EXPORT IoOpReport calculateFileChecksum(QString& returnBuffer, QFile& file QX_IO_EXPORT IoOpReport fileMatchesChecksum(bool& returnBuffer, QFile& file, QString checksum, QCryptographicHash::Algorithm hashAlgorithm); // Binary Based -QX_IO_EXPORT IoOpReport readBytesFromFile(QByteArray& returnBuffer, QFile& file, Index64 startPos = 0, Index64 endPos = Index64(Index64::Last)); +QX_IO_EXPORT IoOpReport readBytesFromFile(QByteArray& returnBuffer, QFile& file, Index64 startPos = 0, Index64 endPos = Index64(Last)); QX_IO_EXPORT IoOpReport writeBytesToFile(QFile& file, const QByteArray& bytes, WriteMode writeMode = Truncate, Index64 startPos = 0, WriteOptions writeOptions = NoWriteOptions); QX_IO_EXPORT IoOpReport writeBytesToFile(QSaveFile& file, const QByteArray& bytes, WriteMode writeMode = Truncate, Index64 startPos = 0, WriteOptions writeOptions = NoWriteOptions); } diff --git a/lib/io/include/qx/io/qx-textpos.h b/lib/io/include/qx/io/qx-textpos.h index 8b81142d..7811ed83 100644 --- a/lib/io/include/qx/io/qx-textpos.h +++ b/lib/io/include/qx/io/qx-textpos.h @@ -16,14 +16,6 @@ namespace Qx class QX_IO_EXPORT TextPos { -//-Class Types------------------------------------------------------------------------------------------------------ -public: - enum Extent - { - Start, - End - }; - //-Instance Variables------------------------------------------------------------------------------------------------ private: Index32 mLine; diff --git a/lib/io/src/qx-common-io.cpp b/lib/io/src/qx-common-io.cpp index d99ad33f..cef8a685 100644 --- a/lib/io/src/qx-common-io.cpp +++ b/lib/io/src/qx-common-io.cpp @@ -459,7 +459,7 @@ IoOpReport findStringInFile(QList& returnBuffer, QFile& textFile, const // Query tracking TextPos trueStartPos = query.startPosition(); - TextPos currentPos = TextPos(TextPos::Start); + TextPos currentPos = TextPos(Start); TextPos possibleMatch = TextPos(); int hitsSkipped = 0; QString::const_iterator queryIt = query.string().constBegin(); @@ -469,7 +469,7 @@ IoOpReport findStringInFile(QList& returnBuffer, QFile& textFile, const QTextStream fileTextStream(&textFile); // Translate start position to absolute position - if(trueStartPos != TextPos(TextPos::Start)) + if(trueStartPos != TextPos(Start)) { IoOpReport translate = textFileAbsolutePosition(trueStartPos, textFile, readOptions.testFlag(IgnoreTrailingBreak)); if(translate.isFailure()) @@ -489,7 +489,7 @@ IoOpReport findStringInFile(QList& returnBuffer, QFile& textFile, const QScopeGuard fileGuard([&textFile](){ textFile.close(); }); // Skip to start pos - if(trueStartPos != TextPos(TextPos::Start)) + if(trueStartPos != TextPos(Start)) { int line; // Skip to start line @@ -739,7 +739,7 @@ IoOpReport readTextFromFile(QString& returnBuffer, QFile& textFile, TextPos star TextStream fileTextStream(&textFile); // Cover each possible range type - if(startPos == TextPos(TextPos::Start) && endPos == TextPos(TextPos::End)) // Whole file is desired + if(startPos == TextPos(Start) && endPos == TextPos(End)) // Whole file is desired { returnBuffer = fileTextStream.readAll(); @@ -999,7 +999,7 @@ namespace // Fill beforeNew TextPos beforeEnd = TextPos(startPos.line(), startPos.character() - 1); - IoOpReport readBefore = readTextFromFile(beforeNew, auxFile, TextPos(TextPos::Start), beforeEnd); + IoOpReport readBefore = readTextFromFile(beforeNew, auxFile, TextPos(Start), beforeEnd); if(readBefore.isFailure()) return readBefore; @@ -1178,27 +1178,27 @@ IoOpReport deleteTextFromFile(QFile& textFile, TextPos startPos, TextPos endPos) IoOpReport transientReport; // Determine beforeDeletion - if(startPos == TextPos(TextPos::Start)) // (0,0) + if(startPos == TextPos(Start)) // (0,0) beforeDeletion = u""_s; else if(startPos.character().isLast()) { - transientReport = readTextFromFile(beforeDeletion, textFile, TextPos(TextPos::Start), startPos); + transientReport = readTextFromFile(beforeDeletion, textFile, TextPos(Start), startPos); beforeDeletion.chop(1); } else - transientReport = readTextFromFile(beforeDeletion, textFile, TextPos(TextPos::Start), TextPos(startPos.line(), startPos.character() - 1)); + transientReport = readTextFromFile(beforeDeletion, textFile, TextPos(Start), TextPos(startPos.line(), startPos.character() - 1)); // Check for transient errors if(!transientReport.isNull() && transientReport.result() != IO_SUCCESS) return IoOpReport(IO_OP_WRITE, transientReport.result(), textFile); // Determine afterDeletion - if(endPos == TextPos(TextPos::End)) + if(endPos == TextPos(End)) afterDeletion = u""_s; else if(endPos.character().isLast()) - transientReport = readTextFromFile(afterDeletion, textFile, TextPos(endPos.line() + 1, 0), TextPos(TextPos::End)); + transientReport = readTextFromFile(afterDeletion, textFile, TextPos(endPos.line() + 1, 0), TextPos(End)); else - transientReport = readTextFromFile(afterDeletion, textFile, TextPos(endPos.line(), endPos.character() + 1), TextPos(TextPos::End)); + transientReport = readTextFromFile(afterDeletion, textFile, TextPos(endPos.line(), endPos.character() + 1), TextPos(End)); // Check for transient errors if(transientReport.result() != IO_SUCCESS) diff --git a/lib/io/src/qx-common-io_p.cpp b/lib/io/src/qx-common-io_p.cpp index b240c34e..33c651e4 100644 --- a/lib/io/src/qx-common-io_p.cpp +++ b/lib/io/src/qx-common-io_p.cpp @@ -132,10 +132,10 @@ IoOpReport writePrep(const QFileInfo& fileInfo, WriteOptions writeOptions) void matchAppendConditionParams(WriteMode& writeMode, TextPos& startPos) { // Match append condition parameters - if(startPos == TextPos(TextPos::End)) + if(startPos == TextPos(End)) writeMode = Append; else if(writeMode == Append) - startPos = TextPos(TextPos::End); + startPos = TextPos(End); } /*! @endcond */ diff --git a/lib/io/src/qx-common-io_p.h b/lib/io/src/qx-common-io_p.h index 26ddb4b2..e1ab5c44 100644 --- a/lib/io/src/qx-common-io_p.h +++ b/lib/io/src/qx-common-io_p.h @@ -37,7 +37,7 @@ void matchAppendConditionParams(WriteMode& writeMode, Index& startPos) if(startPos.isLast()) writeMode = Append; else if(writeMode == Append) - startPos = Index(Index::Last); + startPos = Index(Last); } /*! @endcond */ } diff --git a/lib/io/src/qx-textpos.cpp b/lib/io/src/qx-textpos.cpp index 9f380c36..d4d142aa 100644 --- a/lib/io/src/qx-textpos.cpp +++ b/lib/io/src/qx-textpos.cpp @@ -15,25 +15,6 @@ namespace Qx * @brief The TextPos class is used to represent an offset within a text file in terms of lines and characters. */ -//-Class Types----------------------------------------------------------------------------------------------- -//Public: - -/*! - * @enum TextPos::Extent - * - * Used to refer to text positions of special significance. - * - * @var Index::Extent Index::First - * A text position representing the start of a file. - * - * Equivalent to @c TextPos(0,0). - * - * @var Index::Extent Index::Last - * A text position representing the end file. - * - * Equivalent to @c TextPos(Index32(Index32::Last), Index32(Index32::Last)). - */ - //-Constructor--------------------------------------------------------------------------------------------------- //Public: @@ -45,10 +26,11 @@ TextPos::TextPos() : mCharacter(Index32()) {} -//TODO: Consider creating Qx::Extent (with Start/End) in qx-global and just use -// that for Index and TextPos. /*! * Creates a text position at the given extent @a e. + * + * Start creates a text position equivalent to @c TextPos(0,0), while End creates + * a text position equivalent to @c TextPos(Index32(Qx::Last), Index32(Qx::Last)). */ TextPos::TextPos(Extent e) { @@ -60,8 +42,8 @@ TextPos::TextPos(Extent e) break; case End: - mLine = Index32(Index32::Last); - mCharacter = Index32(Index32::Last); + mLine = Index32(Last); + mCharacter = Index32(Last); break; default: diff --git a/lib/io/src/qx-textquery.cpp b/lib/io/src/qx-textquery.cpp index ae2e8dab..df37831e 100644 --- a/lib/io/src/qx-textquery.cpp +++ b/lib/io/src/qx-textquery.cpp @@ -27,7 +27,7 @@ namespace Qx TextQuery::TextQuery(const QString& string, Qt::CaseSensitivity cs) : mString(string), mCaseSensitivity(cs), - mStartPos(TextPos(TextPos::Start)), + mStartPos(TextPos(Start)), mHitsToSkip(0), mHitLimit(-1), mAllowSplit(false) @@ -48,7 +48,7 @@ Qt::CaseSensitivity TextQuery::caseSensitivity() const { return mCaseSensitivity /*! * Returns the position from which the search should begin. * - * The default is @c TextPos(TextPos::Start). + * The default is @c TextPos(Start). */ TextPos TextQuery::startPosition() const { return mStartPos; }