Skip to content

Commit

Permalink
At global Extent enum
Browse files Browse the repository at this point in the history
Replaces/unifies Index<T>::Extent and TextPos::Extent.
  • Loading branch information
oblivioncth committed Aug 11, 2023
1 parent d746312 commit 4077c03
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 70 deletions.
16 changes: 8 additions & 8 deletions lib/core/doc/res/snippets/qx-index.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//! [0]
Index<int>::LAST + 10 // = Index<int>::LAST
Index<int>::LAST - 10 // = Index<int>::LAST
Index<int>(5) + Index<int>::LAST // = Index<int>::LAST
Index<int>(1087) - Index<int>::LAST // = 0
Index<int>::LAST * 130 // = Index<int>::LAST
Index<int>::LAST / 58 // = Index<int>::LAST
Index<int>::LAST / Index<int>::LAST // = 1
Index<int>(98) / Index<int>::LAST // = 0
Index<int>(Qx::Last) + 10 // = Index<int>(Qx::Last)
Index<int>(Qx::Last) - 10 // = Index<int>(Qx::Last)
Index<int>(5) + Index<int>(Qx::Last) // = Index<int>(Qx::Last)
Index<int>(1087) - Index<int>(Qx::Last) // = 0
Index<int>(Qx::Last) * 130 // = Index<int>(Qx::Last)
Index<int>(Qx::Last) / 58 // = Index<int>(Qx::Last)
Index<int>(Qx::Last) / Index<int>(Qx::Last) // = 1
Index<int>(98) / Index<int>(Qx::Last) // = 0
//! [0]
8 changes: 8 additions & 0 deletions lib/core/include/qx/core/qx-global.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
8 changes: 1 addition & 7 deletions lib/core/include/qx/core/qx-index.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <QtGlobal>

// Intra-component Includes
#include "qx/core/qx-global.h"
#include "qx/core/qx-algorithm.h"

namespace Qx
Expand All @@ -23,13 +24,6 @@ class Index
private:
enum class Type {Null, End, Value};

public:
enum Extent
{
First,
Last
};

//-Instance Members----------------------------------------------------------------------------------------------------
private:
Type mType;
Expand Down
28 changes: 20 additions & 8 deletions lib/core/src/qx-global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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-----------------------------------------------------------------------------------------------------------
Expand Down
17 changes: 1 addition & 16 deletions lib/core/src/qx-index.dox
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>::Extent
/*!
* @enum Index::Extent
*
* Used to refer to indicies of special significance.
*
* @var Index<T>::Extent Index<T>::First
* The first index, equivalent to @c Index<T>(0).
*
* @var Index<T>::Extent Index<T>::Last
* The last index.
*/

//-Constructor----------------------------------------------------------------------------------------------
//Public:
/*!
Expand Down Expand Up @@ -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 <tt>*this == Index<T>(Last)</tt>.
* This is equivalent to <tt>*this == Index<T>(Qx::Last)</tt>.
*/

//-Operators-------------------------------------------------------------------------------------------------------
Expand Down
8 changes: 0 additions & 8 deletions lib/io/include/qx/io/qx-textpos.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ namespace Qx

class QX_IO_EXPORT TextPos
{
//-Class Types------------------------------------------------------------------------------------------------------
public:
enum Extent
{
Start,
End
};

//-Instance Variables------------------------------------------------------------------------------------------------
private:
Index32 mLine;
Expand Down
28 changes: 5 additions & 23 deletions lib/io/src/qx-textpos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>::Extent Index<T>::First
* A text position representing the start of a file.
*
* Equivalent to @c TextPos(0,0).
*
* @var Index<T>::Extent Index<T>::Last
* A text position representing the end file.
*
* Equivalent to @c TextPos(Index32(Index32::Last), Index32(Index32::Last)).
*/

//-Constructor---------------------------------------------------------------------------------------------------
//Public:

Expand All @@ -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)
{
Expand All @@ -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:
Expand Down

0 comments on commit 4077c03

Please sign in to comment.