6 #ifndef SWIFT_MISC_LOGCATEGORYLIST_H
7 #define SWIFT_MISC_LOGCATEGORYLIST_H
9 #include <initializer_list>
11 #include <type_traits>
13 #include <QJsonObject>
17 #include <QStringList>
67 template <
typename T,
typename = std::enable_if_t<std::is_
class_v<T>>>
91 QStringList toQStringList()
const;
94 QString toQString(
bool i18n =
false)
const;
103 bool anyStartWith(
const QString &prefix)
const;
106 bool anyEndWith(
const QString &suffix)
const;
112 QString convertToQString(
bool i18n =
false)
const;
115 template <
typename T>
118 static_assert(
sizeof(T) > 0,
"T must be a complete type, not forward declared");
119 static const auto staticList = [] {
123 list.
push_back(fromQStringList(T::getLogCategories()));
126 if constexpr (std::is_base_of_v<QObject, T>)
128 list.appendCategoriesFromMetaObject(T::staticMetaObject);
132 auto list = staticList;
133 if constexpr (std::is_base_of_v<QObject, T>)
135 if (ptr) { list.appendCategoriesFromMetaObject(*ptr->metaObject(), T::staticMetaObject); }
137 else { Q_UNUSED(ptr); }
142 void appendCategoriesFromMetaObject(
const QMetaObject &,
const QMetaObject &super = QObject::staticMetaObject);
Generic ordered container with value semantics.
static const QString & uncategorized()
Uncategorized.
static const QString & validation()
Validation.
A log category is an arbitrary string tag which can be attached to log messages.
A sequence of log categories.
CLogCategoryList(const T *pointer)
Construct by extracting categories from a class T.
CLogCategoryList with(const CLogCategoryList &other) const
Return a copy with some other categories appended.
CLogCategoryList()=default
Empty constructor.
CLogCategoryList withValidation() const
Return a copy with validation category appended.
CLogCategoryList(const CLogCategory &category)
By single element.
CLogCategoryList(const CSequence< CLogCategory > &other)
Copy construct from superclass instance.
CLogCategoryList(std::nullptr_t)=delete
Prevent accidental use of the initializer list constructor.
CLogCategoryList with(const CLogCategory &other) const
Return a copy with another category appended.
Generic sequential container with value semantics.
CSequence()=default
Default constructor.
void push_back(const T &value)
Appends an element at the end of the sequence.
bool isEmpty() const
Synonym for empty.
Free functions in swift::misc.
void registerMetadata()
Register all relevant metadata in Misc.
#define SWIFT_DECLARE_SEQUENCE_MIXINS(Namespace, T, List)
Explicit template declaration of mixins for a CSequence subclass to be placed near the top of the hea...
Trait to detect whether a class T has a static member function named getLogCategories.
#define SWIFT_MISC_EXPORT
Export a class or function from the library.