Cutelyst  2.3.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 : public View
28 {
29  Q_OBJECT
30  Q_DECLARE_PRIVATE(ViewJson)
31 public:
35  explicit ViewJson(QObject *parent, const QString &name = QString());
36  virtual ~ViewJson();
37 
39  enum JsonFormat {
41  Compact
42  };
43  Q_ENUM(JsonFormat)
44 
45 
49  JsonFormat outputFormat() const;
50 
54  void setOutputFormat(JsonFormat format);
55 
57  enum ExposeMode {
58  All,
59  String,
60  StringList,
61  RegularExpression
62  };
63  Q_ENUM(ExposeMode)
64 
65 
69  ExposeMode exposeStashMode() const;
70 
75  void setExposeStash(const QString &key);
76 
81  void setExposeStash(const QStringList &keys);
82 
87  void setExposeStash(const QRegularExpression &re);
88 
93  void setXJsonHeader(bool enable);
94 
98  bool xJsonHeader() const;
99 
100  QByteArray render(Context *c) const final;
101 
102 protected:
103  ViewJsonPrivate *d_ptr;
104 };
105 
106 }
107 
108 #endif // VIEWJSON_H
The Cutelyst Context.
Definition: context.h:50
The Cutelyst namespace holds all public Cutelyst API.
Definition: Mainpage.dox:7
JSON view for your data.
Definition: viewjson.h:27
Cutelyst View abstract view component
Definition: view.h:33