chore: Re-simplify IndexVersionType and MessageLevel with c++20
This sets our compiler requirements to gcc 11 and clang 13. If we forgo the use of `using enum` we can drop to gcc 10 and clang 10 but that means using `MessageLevel::Enum::Unknown` for direct enum access Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
@@ -2,26 +2,40 @@
|
||||
|
||||
#include <qlogging.h>
|
||||
#include <QString>
|
||||
#include <compare>
|
||||
|
||||
/**
|
||||
* @brief the MessageLevel Enum
|
||||
* defines what level a log message is
|
||||
*/
|
||||
enum class MessageLevel {
|
||||
Unknown, /**< No idea what this is or where it came from */
|
||||
StdOut, /**< Undetermined stderr messages */
|
||||
StdErr, /**< Undetermined stdout messages */
|
||||
Launcher, /**< Launcher Messages */
|
||||
Trace, /**< Trace Messages */
|
||||
Debug, /**< Debug Messages */
|
||||
Info, /**< Info Messages */
|
||||
Message, /**< Standard Messages */
|
||||
Warning, /**< Warnings */
|
||||
Error, /**< Errors */
|
||||
Fatal, /**< Fatal Errors */
|
||||
struct MessageLevel {
|
||||
enum class Enum {
|
||||
Unknown, /**< No idea what this is or where it came from */
|
||||
StdOut, /**< Undetermined stderr messages */
|
||||
StdErr, /**< Undetermined stdout messages */
|
||||
Launcher, /**< Launcher Messages */
|
||||
Trace, /**< Trace Messages */
|
||||
Debug, /**< Debug Messages */
|
||||
Info, /**< Info Messages */
|
||||
Message, /**< Standard Messages */
|
||||
Warning, /**< Warnings */
|
||||
Error, /**< Errors */
|
||||
Fatal, /**< Fatal Errors */
|
||||
};
|
||||
using enum Enum;
|
||||
constexpr MessageLevel(Enum e = Unknown) : m_type(e) {}
|
||||
static MessageLevel fromName(const QString& type);
|
||||
static MessageLevel fromQtMsgType(const QtMsgType& type);
|
||||
static MessageLevel fromLine(const QString& line);
|
||||
inline bool isValid() const { return m_type != Unknown; }
|
||||
std::strong_ordering operator<=>(const MessageLevel& other) const = default;
|
||||
std::strong_ordering operator<=>(const MessageLevel::Enum& other) const { return m_type <=> other; }
|
||||
explicit operator int() const { return static_cast<int>(m_type); }
|
||||
explicit operator MessageLevel::Enum() { return m_type; }
|
||||
|
||||
private:
|
||||
Enum m_type;
|
||||
};
|
||||
MessageLevel messageLevelFromName(const QString& levelName);
|
||||
MessageLevel messageLevelFromQtMsgType(QtMsgType type);
|
||||
|
||||
/* Get message level from a line. Line is modified if it was successful. */
|
||||
MessageLevel messageLevelFromLine(QString& line);
|
||||
|
||||
Reference in New Issue
Block a user