Smithy Qt 0.1.0-pre
Internal development documentation
Loading...
Searching...
No Matches
model.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 Model class.
7 */
8
9#ifndef QTSMITHY_MODEL_H
10#define QTSMITHY_MODEL_H
11
12#include "shape.h"
13#include "shapeid.h"
14
15#include <QCoreApplication>
16#include <QHash>
17#include <QJsonObject>
18
20
22
23class ModelPrivate;
24
26{
27Q_DECLARE_TR_FUNCTIONS(Model);
28
29public:
30 enum class Error {
31 NoError = 0,
32 NoData = 1,
33 InvalidMetadata = 2,
34 InvalidShapes = 3,
35 InvalidShapeId = 4,
36 InvalidShape = 5,
37 ConflictingMetadata = 6,
38 };
39
40 Model();
41 Model(Model &&other);
42 Model(const Model &other);
43 Model& operator=(const Model &model);
44 Model& operator=(const Model &&model);
45 ~Model();
46
47 void clear();
48 bool insert(const QJsonObject &ast);
49 bool finish();
50
51 Error error() const;
52 bool isValid() const;
53
54 QJsonObject metadata() const;
55 Shape shape(const ShapeId &shapeId) const;
56 QHash<ShapeId, Shape> shapes(const Shape::Type &type = Shape::Type::Undefined) const;
57
58protected:
59 /// \cond internal
60 ModelPrivate * d_ptr; ///< Internal d-pointer.
61 /// \endcond
62
63private:
64 Q_DECLARE_PRIVATE(Model)
66};
67
69
70#endif // QTSMITHY_MODEL_H
The ModelPrivate class provides private implementation for Model.
Definition model_p.h:22
The Model class provides a Qt representation of a Smithy semantic model.
Definition model.h:26
QHash< ShapeId, Shape > shapes(const Shape::Type &type=Shape::Type::Undefined) const
Definition model.cpp:230
Shape shape(const ShapeId &shapeId) const
Definition model.cpp:223
bool insert(const QJsonObject &ast)
Add the logical content of the JSON AST model file given by ast into this semantic model.
Definition model.cpp:102
bool finish()
Definition model.cpp:186
Model()
Constructs a new, empty Smithy model.
Definition model.cpp:27
ModelPrivate * d_ptr
Definition model.h:60
The ShapeId class provides a Qt representation of a Smithy Shape ID.
Definition shapeid.h:29
The Shape class provides a Qt representation of a Smithy semantic shape.
Definition shape.h:25
Type
Definition shape.h:37
@ Undefined
The shape is undefined, usually the result of an error condition.
Definition shape.h:38
#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).
Declares the Shape class.
Declares the ShapeId class.