swift
rolelist.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2015 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_NETWORK_ROLELIST_H
7 #define SWIFT_MISC_NETWORK_ROLELIST_H
8 
9 #include <QJsonArray>
10 #include <QMetaType>
11 #include <QString>
12 #include <QStringList>
13 
14 #include "misc/collection.h"
15 #include "misc/network/role.h"
16 #include "misc/sequence.h"
17 #include "misc/swiftmiscexport.h"
18 
19 SWIFT_DECLARE_SEQUENCE_MIXINS(swift::misc::network, CRole, CRoleList)
20 
21 namespace swift::misc::network
22 {
23  class CRole;
24 
26  class SWIFT_MISC_EXPORT CRoleList : public CSequence<CRole>, public swift::misc::mixin::MetaType<CRoleList>
27  {
28  public:
31 
33  CRoleList();
34 
36  bool hasRole(const QString &roleName) const;
37 
39  bool hasRole(const CRole &role) const;
40 
42  bool hasAnyRole(const QStringList &roles) const;
43 
45  CRoleList(const CSequence<CRole> &other);
46 
48  QString namesAsString(const QString &separator = ", ") const;
49 
51  static CRoleList fromDatabaseJson(const QJsonArray &array);
52  };
53 } // namespace swift::misc::network
54 
55 Q_DECLARE_METATYPE(swift::misc::network::CRoleList)
57 
58 #endif // SWIFT_MISC_NETWORK_ROLELIST_H
Generic ordered container with value semantics.
Definition: collection.h:107
Generic sequential container with value semantics.
Definition: sequence.h:86
CSequence()=default
Default constructor.
CRTP class template from which a derived class can inherit common methods dealing with the metatype o...
Definition: mixinmetatype.h:29
Value object encapsulating a list of servers.
Definition: rolelist.h:27
#define SWIFT_MISC_DECLARE_USING_MIXIN_METATYPE(DERIVED)
When a derived class and a base class both inherit from mixin::MetaType, the derived class uses this ...
#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...
Definition: sequence.h:62
#define SWIFT_MISC_EXPORT
Export a class or function from the library.