LCOV - code coverage report
Current view: top level - include/qtsmithy - shape.h Coverage Total Hit
Project: Smithy Qt Lines: 0.0 % 4 0
Version: 0.1.0-pre Functions: - 0 0

            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 Shape class.
       7              :  */
       8              : 
       9              : #ifndef QTSMITHY_SHAPE_H
      10              : #define QTSMITHY_SHAPE_H
      11              : 
      12              : #include "shapeid.h"
      13              : 
      14              : #include <QCoreApplication>
      15              : #include <QJsonObject>
      16              : #include <QJsonValue>
      17              : 
      18              : QTSMITHY_DECLARE_TEST(Shape)
      19              : 
      20              : QTSMITHY_BEGIN_NAMESPACE
      21              : 
      22              : class ShapePrivate;
      23              : 
      24              : class QTSMITHY_EXPORT Shape
      25              : {
      26            0 : Q_DECLARE_TR_FUNCTIONS(Shape);
      27              : 
      28              : public:
      29              :     enum class Error {
      30              :         NoError                 = 0,
      31              :         UndefinedShapeType      = 1,
      32              :         MissingRequiredProperty = 2,
      33              :         InvalidPropertyValue    = 3,
      34              :     };
      35              : 
      36              :     // https://awslabs.github.io/smithy/2.0/spec/model.html#shape-types
      37              :     enum class Type {
      38              :         Undefined  = 0x000, ///< The shape is undefined, usually the result of an error condition.
      39              : 
      40              :         // Simple Types
      41              :         Blob       = 0x101, ///< Uninterpreted binary data.
      42              :         Boolean    = 0x102, ///< Boolean value type.
      43              :         String     = 0x103, ///< UTF-8 encoded string.
      44              :         Enum       = 0x104, ///< A string with a fixed set of values.
      45              :         Byte       = 0x105, ///< 8-bit signed integer ranging from -128 to 127 (inclusive).
      46              :         Short      = 0x106, ///< 16-bit signed integer ranging from -32,768 to 32,767 (inclusive).
      47              :         Integer    = 0x107, ///< 32-bit signed integer ranging from -2^31 to (2^31)-1 (inclusive).
      48              :         IntEnum    = 0x108, ///< An integer with a fixed set of values.
      49              :         Long       = 0x109, ///< 64-bit signed integer ranging from -2^63 to (2^63)-1 (inclusive).
      50              :         Float      = 0x10A, ///< Single precision IEEE-754 floating point number.
      51              :         Double     = 0x10B, ///< Double precision IEEE-754 floating point number.
      52              :         BigInteger = 0x10C, ///< Arbitrarily large signed integer.
      53              :         BigDecimal = 0x10D, ///< Arbitrary precision signed decimal number.
      54              :         Timestamp  = 0x10E, ///< An instant in time with no UTC offset or timezone.
      55              :         Document   = 0x10F, ///< Open content that functions as a kind of "any" type.
      56              : 
      57              :         // Aggregate Types
      58              :         List      = 0x201, ///< Ordered collection of homogeneous values.
      59              :         Set       = 0x201, ///< Deprecated; use a list with the uniqueItems trait instead.
      60              :         Map       = 0x202, ///< Map data structure that maps string keys to homogeneous values.
      61              :         Structure = 0x203, ///< Fixed set of named heterogeneous members.
      62              :         Union     = 0x204, ///< Tagged union data structure that can take on one of several
      63              :                            ///< different, but fixed, types
      64              : 
      65              :         // Service Types
      66              :         Service   = 0x301, ///< Entry point of an API that aggregates resources and operations together.
      67              :         Operation = 0x302, ///< Represents the input, output, and errors of an API operation.
      68              :         Resource  = 0x303, ///< Entity with an identity that has a set of operations
      69              : 
      70              :         // Special Types
      71              :         Apply     = 0x401, ///< Traits to be applied to shapes outside of their definition.
      72              :     };
      73              : 
      74              :     // Map of absolute shape ID of a trait shape to the value to assign to the trait.
      75              :     typedef QHash<ShapeId, QJsonValue> TraitsMap;
      76              : 
      77              :     // https://awslabs.github.io/smithy/2.0/spec/json-ast.html#ast-shape-reference
      78            0 :     struct ShapeReference {
      79              :         ShapeId target;
      80              :     };
      81              :     typedef QHash<QString, ShapeReference> StringShapeRefMap;
      82              :     typedef QSet<ShapeReference> ShapeReferences;
      83              : 
      84              :     // https://awslabs.github.io/smithy/2.0/spec/json-ast.html#ast-member
      85            0 :     struct Member : public ShapeReference {
      86              :         TraitsMap traits;
      87              :     };
      88              :     typedef QHash<QString, Member> StringMemberMap;
      89              : 
      90              :     Shape();
      91              :     Shape(const QJsonObject &ast, const ShapeId &id = ShapeId{});
      92              :     Shape(Shape &&other);
      93              :     Shape(const Shape &other);
      94              :     Shape& operator=(const Shape &shape);
      95              :     Shape& operator=(const Shape &&shape);
      96              :     ~Shape();
      97              : 
      98              :     Error error() const;
      99              :     bool isValid() const;
     100              : 
     101              :     ShapeId id() const;
     102              :     Type type() const;
     103              :     TraitsMap traits() const;
     104              : 
     105              :     // List (and set) shape https://awslabs.github.io/smithy/2.0/spec/json-ast.html#list-shapes
     106              :     Member member() const;
     107              : 
     108              :     // Map shape https://awslabs.github.io/smithy/2.0/spec/json-ast.html#map-shape
     109              :     Member key() const;
     110              :     Member value() const;
     111              : 
     112              :     // Structure, union, enum, and intEnum shapes
     113              :     // https://awslabs.github.io/smithy/2.0/spec/json-ast.html#structure-union-enum-and-intenum-shapes
     114              :     StringMemberMap members() const;
     115              : 
     116              :     // Service shape https://awslabs.github.io/smithy/2.0/spec/json-ast.html#service-shape
     117              :     QString version() const;
     118              :     ShapeReferences operations() const; // And resource shape.
     119              :     ShapeReferences resources() const;  // And resource shape.
     120              :     ShapeReferences errors() const;     // And operation shape.
     121              :     ShapeIdStringMap rename() const;
     122              : 
     123              :     // Resource shape https://awslabs.github.io/smithy/2.0/spec/json-ast.html#resource-shape
     124              :     StringShapeRefMap identifiers() const;
     125              :     StringShapeRefMap properties() const;
     126              :     ShapeReference create() const;
     127              :     ShapeReference put() const;
     128              :     ShapeReference read() const;
     129              :     ShapeReference update() const;
     130              :     ShapeReference Delete() const;
     131              :     ShapeReference list() const;
     132              :   //ShapeReferences operations() const; // And service shape.
     133              :     ShapeReferences collectionOperations() const;
     134              :   //ShapeReferences resources() const;  // And service shape.
     135              : 
     136              :     // Operation shape https://awslabs.github.io/smithy/2.0/spec/json-ast.html#operation-shape
     137              :     ShapeReference input() const;
     138              :     ShapeReference output() const;
     139              :   //ShapeReferences errors() const; // And service shape.
     140              : 
     141              :     // Mixins https://awslabs.github.io/smithy/2.0/spec/json-ast.html#mixins
     142              :     ShapeReferences mixins() const;
     143              : 
     144              :     QJsonObject rawAst() const;
     145              : 
     146              : protected:
     147              :     /// \cond internal
     148              :     ShapePrivate * d_ptr; ///< Internal d-pointer.
     149              :     /// \endcond
     150              : 
     151              : private:
     152            0 :     Q_DECLARE_PRIVATE(Shape)
     153              :     QTSMITHY_BEFRIEND_TEST(Shape)
     154              : };
     155              : 
     156              : #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
     157              : QTSMITHY_EXPORT uint qHash(const Shape::ShapeReference &key, uint seed = 0);
     158              : #else
     159              : QTSMITHY_EXPORT size_t qHash(const Shape::ShapeReference &key, size_t seed = 0);
     160              : #endif
     161              : 
     162              : QTSMITHY_EXPORT bool operator==(const Shape::ShapeReference &lhs, const Shape::ShapeReference& rhs);
     163              : 
     164              : QTSMITHY_END_NAMESPACE
     165              : 
     166              : #endif // QTSMITHY_SHAPE_H
        

Generated by: LCOV version 2.2-1