Smithy Qt 0.1.0-pre
Internal development documentation
Loading...
Searching...
No Matches
shapeid.h
Go to the documentation of this file.
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
23
25
26class ShapeIdPrivate;
27
29{
30Q_DECLARE_TR_FUNCTIONS(ShapeId);
31
32public:
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
63private:
64 /// \cond internal
65 ShapeIdPrivate * d_ptr; ///< Internal d-pointer.
66 /// \endcond
67
68 Q_DECLARE_PRIVATE(ShapeId)
70};
71
72#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
73QTSMITHY_EXPORT uint qHash(const ShapeId &key, uint seed = 0);
74#else
75QTSMITHY_EXPORT size_t qHash(const ShapeId &key, size_t seed = 0);
76#endif
77
78typedef QHash<ShapeId, QString> ShapeIdStringMap;
79
81
82#endif // QTSMITHY_SHAPEID_H
The ShapeIdPrivate class provides private implementation for ShapeId.
Definition shapeid_p.h:20
The ShapeId class provides a Qt representation of a Smithy Shape ID.
Definition shapeid.h:29
QString nameSpace() const
Returns the Shape ID's namespace, if it has one, otherwise a null string.
Definition shapeid.cpp:123
bool isValid() const
Returns true if this object represents a valid, non-empty Smithy Shape ID.
Definition shapeid.cpp:281
void setMemberName(const QString &name)
Set the Shape ID's member name to name, which may be an empty or null string.
Definition shapeid.cpp:145
QString absoluteShapeId() const
Returns this object as an absolute Smithy Shape ID if this object has a namespace,...
Definition shapeid.cpp:185
QString toString() const
Returns this object as an absolute Smithy Shape ID if this object has a namespace,...
Definition shapeid.cpp:214
ShapeId()
Constructs an empty ShapeId object.
Definition shapeid.cpp:27
ShapeId & operator=(const ShapeId &shapeId)
Assigns the specified shapeId to this object.
Definition shapeid.cpp:72
bool isRootShapeId() const
Returns true if this Shape ID is a root Shape ID, false otherwise.
Definition shapeid.cpp:259
bool hasMemberName() const
Returns true if this Shape ID has a non-empty member name, otherwise false otherwise.
Definition shapeid.cpp:236
QString shapeName() const
Returns the Shape ID's shape name, if it has one, otherwise a null string.
Definition shapeid.cpp:136
void setNameSpace(const QString &name)
Set the Shape ID's namespace to name, which may be an empty or null string.
Definition shapeid.cpp:154
QString memberName() const
Returns the Shape ID's member name, if it has one, otherwise a null string.
Definition shapeid.cpp:114
QString relativeShapeId() const
Returns this object as a relative Smithy Shape ID, that one without a leading namespace.
Definition shapeid.cpp:198
bool hasNameSpace() const
Returns true if this Shape ID has a non-empty namespace, otherwise false otherwise.
Definition shapeid.cpp:225
ShapeIdPrivate * d_ptr
Definition shapeid.h:65
void setShapeName(const QString &name)
Set the Shape ID's shape name to name.
Definition shapeid.cpp:166
bool isAbsoluteRootShapeId() const
Returns true if this Shape ID is a root Shape ID, and has a namespace, false otherwise.
Definition shapeid.cpp:247
bool isRelativeShapeId() const
Returns true if this Shape ID is a relative Shape ID, false otherwise.
Definition shapeid.cpp:271
Global QtSmithy library macros.
#define QTSMITHY_EXPORT
QtSmithy library export/import macro.
#define QTSMITHY_BEGIN_NAMESPACE
Macro for starting the QtSmithy library's top-most namespace (if one is defined).
#define QTSMITHY_DECLARE_TEST(Class)
Macro for forward-delcaring a related unit test class, but only when QT_TESTLIB_LIB is defined.
#define QTSMITHY_BEFRIEND_TEST(Class)
Macro for befriending a related unit test class, but only when QT_TESTLIB_LIB is defined.
#define QTSMITHY_END_NAMESPACE
Macro for ending the QtSmithy library's top-most namespace (if one is defined).