swift
logcategory.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2014 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef SWIFT_MISC_LOGCATEGORY_H
7 #define SWIFT_MISC_LOGCATEGORY_H
8 
9 #include <QList>
10 #include <QMetaType>
11 #include <QString>
12 
13 #include "misc/metaclass.h"
14 #include "misc/swiftmiscexport.h"
15 #include "misc/valueobject.h"
16 
18 
19 namespace swift::misc
20 {
27  class SWIFT_MISC_EXPORT CLogCategory : public CValueObject<CLogCategory>
28  {
29  public:
31  CLogCategory() = default;
32 
34  CLogCategory(const QString &categoryString) : m_string(categoryString) {}
35 
37  CLogCategory(const char *categoryString) : m_string(categoryString) {}
38 
40  bool startsWith(const QString &prefix) const { return m_string.startsWith(prefix); }
41 
43  bool endsWith(const QString &suffix) const { return m_string.endsWith(suffix); }
44 
46  bool contains(const QString &substring) const { return m_string.contains(substring); }
47 
49  QString convertToQString(bool i18n = false) const;
50 
51  private:
52  QString m_string;
53 
56  SWIFT_METAMEMBER(string));
57  };
58 } // namespace swift::misc
59 
60 Q_DECLARE_METATYPE(swift::misc::CLogCategory)
61 
62 #endif // SWIFT_MISC_LOGCATEGORY_H
A log category is an arbitrary string tag which can be attached to log messages.
Definition: logcategory.h:28
CLogCategory(const QString &categoryString)
Constructor.
Definition: logcategory.h:34
CLogCategory()=default
Constructor.
CLogCategory(const char *categoryString)
Constructor.
Definition: logcategory.h:37
bool startsWith(const QString &prefix) const
Returns true if the category string starts with the given prefix.
Definition: logcategory.h:40
bool endsWith(const QString &suffix) const
Returns true if the category string ends with the given suffix.
Definition: logcategory.h:43
bool contains(const QString &substring) const
Returns true if the category string contains the given substring.
Definition: logcategory.h:46
Mix of the most commonly used mixin classes.
Definition: valueobject.h:114
#define SWIFT_METAMEMBER(MEMBER,...)
Macro to define an element within a metaclass.
Definition: metaclass.h:73
#define SWIFT_METACLASS(CLASS,...)
Macro to define a nested metaclass that describes the attributes of its enclosing class.
Definition: metaclass.h:53
Free functions in swift::misc.
#define SWIFT_MISC_EXPORT
Export a class or function from the library.
#define SWIFT_DECLARE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template declaration of mixins for a CValueObject subclass to be placed near the top of the ...
Definition: valueobject.h:65