#include "ircmessagetype.hpp" #include #include IrcMessageType::MessageType IrcMessageType::getType() const { return _type; } IrcMessageType IrcMessageType::parse(QString str) { // QVariant var = QVariant::fromValue(str); // if (var.convert(QMetaType::fromType())) // return var.value(); // return IrcMessageType::MessageType::UNKNOWN; auto&& meta = QMetaEnum::fromType(); bool ok = false; auto value = static_cast(meta.keyToValue(str.toLocal8Bit().data(), &ok)); if (ok) return value; auto num = str.toInt(&ok); if (ok) return num; return Unknown(); } IrcMessageType::IrcMessageType(const IrcMessageType& other) : _type(other._type) { } IrcMessageType::IrcMessageType(int type) : _type(static_cast(type)) { } QString IrcMessageType::toString() const { auto&& metaEnum = QMetaEnum::fromType(); return metaEnum.valueToKey(static_cast(_type)); }