Line data Source code
1 : // SPDX-FileCopyrightText: 2013-2025 Paul Colby <git@colby.id.au>
2 : // SPDX-License-Identifier: LGPL-3.0-or-later
3 :
4 : /*!
5 : * \file
6 : * Declares the ShapeId class.
7 : */
8 :
9 : #ifndef QTSMITHY_SHAPEID_H
10 : #define QTSMITHY_SHAPEID_H
11 :
12 : #include "qtsmithy_global.h"
13 :
14 : #include <QtGlobal> // \todo Remove if/when dropping support for Qt 6.0.x.
15 : #if (QT_VERSION_CHECK(6, 0, 0) <= QT_VERSION) && (QT_VERSION < QT_VERSION_CHECK(6, 1, 0))
16 : #include <limits> // https://bugreports.qt.io/browse/QTBUG-89977
17 : #endif
18 :
19 : #include <QCoreApplication>
20 : #include <QHash>
21 :
22 : QTSMITHY_DECLARE_TEST(ShapeId)
23 :
24 : QTSMITHY_BEGIN_NAMESPACE
25 :
26 : class ShapeIdPrivate;
27 :
28 : class QTSMITHY_EXPORT ShapeId
29 : {
30 : Q_DECLARE_TR_FUNCTIONS(ShapeId);
31 :
32 : public:
33 : ShapeId();
34 : ShapeId(ShapeId &&other);
35 : ShapeId(const ShapeId &other);
36 : ShapeId(const QString &shapeId);
37 : ShapeId& operator=(const ShapeId &shapeId);
38 : ShapeId& operator=(const ShapeId &&shapeId);
39 : ShapeId& operator=(const QString &shapeId);
40 : ~ShapeId();
41 :
42 : QString memberName() const;
43 : QString nameSpace() const;
44 : QString shapeName() const;
45 :
46 : void setMemberName(const QString &name);
47 : void setNameSpace(const QString &name);
48 : void setShapeName(const QString &name);
49 :
50 : QString absoluteShapeId() const;
51 : QString relativeShapeId() const;
52 : QString toString() const;
53 :
54 : bool hasNameSpace() const;
55 : bool hasMemberName() const;
56 : bool isAbsoluteRootShapeId() const;
57 : bool isRootShapeId() const;
58 : bool isRelativeShapeId() const;
59 : bool isValid() const;
60 :
61 : bool operator==(const ShapeId &other) const;
62 :
63 : private:
64 : /// \cond internal
65 : ShapeIdPrivate * d_ptr; ///< Internal d-pointer.
66 : /// \endcond
67 :
68 52228 : Q_DECLARE_PRIVATE(ShapeId)
69 : QTSMITHY_BEFRIEND_TEST(ShapeId)
70 : };
71 :
72 : #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
73 : QTSMITHY_EXPORT uint qHash(const ShapeId &key, uint seed = 0);
74 : #else
75 : QTSMITHY_EXPORT size_t qHash(const ShapeId &key, size_t seed = 0);
76 : #endif
77 :
78 : typedef QHash<ShapeId, QString> ShapeIdStringMap;
79 :
80 : QTSMITHY_END_NAMESPACE
81 :
82 : #endif // QTSMITHY_SHAPEID_H
|