Cutelyst  2.13.0
viewjson.h
1 /*
2  * Copyright (C) 2015-2017 Daniel Nicoletti <dantti12@gmail.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 #ifndef VIEWJSON_H
19 #define VIEWJSON_H
20 
21 #include <Cutelyst/cutelyst_global.h>
22 #include <Cutelyst/view.h>
23 
24 namespace Cutelyst {
25 
26 class ViewJsonPrivate;
27 class CUTELYST_VIEW_JSON_EXPORT ViewJson final : public View
28 {
29  Q_OBJECT
30  Q_DECLARE_PRIVATE(ViewJson)
31 public:
35  explicit ViewJson(QObject *parent, const QString &name = QString());
36 
38  enum JsonFormat {
40  Compact
41  };
42  Q_ENUM(JsonFormat)
43 
44 
48  JsonFormat outputFormat() const;
49 
53  void setOutputFormat(JsonFormat format);
54 
56  enum ExposeMode {
57  All,
58  String,
59  StringList,
60  RegularExpression
61  };
62  Q_ENUM(ExposeMode)
63 
64 
68  ExposeMode exposeStashMode() const;
69 
74  void setExposeStash(const QString &key);
75 
80  void setExposeStash(const QStringList &keys);
81 
86  void setExposeStash(const QRegularExpression &re);
87 
92  void setXJsonHeader(bool enable);
93 
97  bool xJsonHeader() const;
98 
99  QByteArray render(Context *c) const final;
100 };
101 
102 }
103 
104 #endif // VIEWJSON_H
Cutelyst::ViewJson::ExposeMode
ExposeMode
Definition: viewjson.h:56
Cutelyst::Context
The Cutelyst Context.
Definition: context.h:50
Cutelyst::ViewJson::Indented
@ Indented
Definition: viewjson.h:39
Cutelyst::ViewJson
JSON view for your data.
Definition: viewjson.h:27
Cutelyst::ViewJson::JsonFormat
JsonFormat
Definition: viewjson.h:38
Cutelyst::View
Cutelyst View abstract view component
Definition: view.h:34
Cutelyst
The Cutelyst namespace holds all public Cutelyst API.
Definition: Mainpage.dox:7