cutelyst  4.5.1
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
viewjson.h
1 /*
2  * SPDX-FileCopyrightText: (C) 2015-2022 Daniel Nicoletti <dantti12@gmail.com>
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 #ifndef VIEWJSON_H
6 #define VIEWJSON_H
7 
8 #include <Cutelyst/Plugins/View/json_export.h>
9 #include <Cutelyst/view.h>
10 
11 namespace Cutelyst {
12 
13 class ViewJsonPrivate;
25 class CUTELYST_VIEW_JSON_EXPORT ViewJson final : public View
26 {
27  Q_OBJECT
28  Q_DECLARE_PRIVATE(ViewJson)
29 public:
36  explicit ViewJson(QObject *parent, const QString &name = QString());
37 
39  enum JsonFormat {
41  Compact
42  };
43  Q_ENUM(JsonFormat)
44 
45 
49  [[nodiscard]] JsonFormat outputFormat() const;
50 
54  void setOutputFormat(JsonFormat format);
55 
57  enum ExposeMode {
58  All,
60  String,
62  StringList,
64  RegularExpression
66  };
67  Q_ENUM(ExposeMode)
68 
69 
73  [[nodiscard]] ExposeMode exposeStashMode() const;
74 
81  void setExposeStash(const QString &key);
82 
89  void setExposeStash(const QStringList &keys);
90 
97  void setExposeStash(const QRegularExpression &re);
98 
104  void setXJsonHeader(bool enable);
105 
109  [[nodiscard]] bool xJsonHeader() const;
110 
111  QByteArray render(Context *c) const final;
112 };
113 
114 } // namespace Cutelyst
115 
116 #endif // VIEWJSON_H
The Cutelyst Context.
Definition: context.h:42
A view that returns stash data in JSON format.
Definition: viewjson.h:26
Abstract View component for Cutelyst.
Definition: view.h:25
The Cutelyst namespace holds all public Cutelyst API.