QxOrm 1.4.9
C++ Object Relational Mapping library
Loading...
Searching...
No Matches
QxRestApi.h
Go to the documentation of this file.
1/****************************************************************************
2**
3** https://www.qxorm.com/
4** Copyright (C) 2013 Lionel Marty (contact@qxorm.com)
5**
6** This file is part of the QxOrm library
7**
8** This software is provided 'as-is', without any express or implied
9** warranty. In no event will the authors be held liable for any
10** damages arising from the use of this software
11**
12** Commercial Usage
13** Licensees holding valid commercial QxOrm licenses may use this file in
14** accordance with the commercial license agreement provided with the
15** Software or, alternatively, in accordance with the terms contained in
16** a written agreement between you and Lionel Marty
17**
18** GNU General Public License Usage
19** Alternatively, this file may be used under the terms of the GNU
20** General Public License version 3.0 as published by the Free Software
21** Foundation and appearing in the file 'license.gpl3.txt' included in the
22** packaging of this file. Please review the following information to
23** ensure the GNU General Public License version 3.0 requirements will be
24** met : http://www.gnu.org/copyleft/gpl.html
25**
26** If you are unsure which license is appropriate for your use, or
27** if you have questions regarding the use of this file, please contact :
28** contact@qxorm.com
29**
30****************************************************************************/
31
32#ifndef _QX_REST_API_H_
33#define _QX_REST_API_H_
34
35#ifdef _MSC_VER
36#pragma once
37#endif
38
46#ifdef _QX_NO_PRECOMPILED_HEADER
47#ifndef Q_MOC_RUN
48#include <QxPrecompiled.h> // Need to include precompiled header for the generated moc file
49#endif // Q_MOC_RUN
50#endif // _QX_NO_PRECOMPILED_HEADER
51
52#include <QtSql/qsqlerror.h>
53
54#ifndef _QX_NO_JSON
55#include <QtCore/qjsonvalue.h>
56#include <QtCore/qjsonobject.h>
57#include <QtCore/qjsonarray.h>
58#include <QtCore/qjsondocument.h>
59#endif // _QX_NO_JSON
60
61namespace qx {
62
67class QX_DLL_EXPORT QxRestApi : public QObject
68{
69
70 Q_OBJECT
71
72private:
73
74 struct QxRestApiImpl;
75 std::unique_ptr<QxRestApiImpl> m_pImpl;
76
77public:
78
79 QxRestApi(QObject * parent = NULL);
80 virtual ~QxRestApi();
81
82 Q_INVOKABLE QString processRequest(const QString & request);
83 Q_INVOKABLE void clearAll();
84
85 Q_INVOKABLE QString getErrorDesc() const;
86 Q_INVOKABLE int getErrorCode() const;
87 QSqlError getError() const;
88
89#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
90#if (QT_VERSION >= 0x050300) // Double check here to support Qt4 (which doesn't manage macro expansion in the moc process)
91 Q_INVOKABLE QString getNativeErrorCode() const;
92#endif // (QT_VERSION >= 0x050300)
93#endif // (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
94
95 Q_INVOKABLE void setEntity(const QString & entity);
96 Q_INVOKABLE void setAction(const QString & action);
97 Q_INVOKABLE void setFunction(const QString & fct);
98 Q_INVOKABLE void setColumns(const QStringList & columns);
99 Q_INVOKABLE void setRelations(const QStringList & relations);
100 Q_INVOKABLE void setOutputFormat(const QStringList & outputFormat);
101 Q_INVOKABLE void setDatabase(const QString & database);
102 Q_INVOKABLE void setQuery(const QString & query);
103 Q_INVOKABLE void setData(const QString & data);
104 Q_INVOKABLE void setUseExecBatch(bool useExecBatch);
105
106#ifndef _QX_NO_JSON
107 QJsonValue processRequest(const QJsonValue & request);
108 void setData(const QJsonValue & data);
109#endif // _QX_NO_JSON
110
111};
112
113} // namespace qx
114
115#endif // _QX_REST_API_H_
#define QX_DLL_EXPORT
Definition QxMacro.h:182
qx::QxRestApi : provide a REST API to send requests in JSON format from external application,...
Definition QxRestApi.h:68
Q_INVOKABLE void setQuery(const QString &query)
QJsonValue processRequest(const QJsonValue &request)
Q_INVOKABLE void setOutputFormat(const QStringList &outputFormat)
void setData(const QJsonValue &data)
virtual ~QxRestApi()
Q_INVOKABLE QString processRequest(const QString &request)
Q_INVOKABLE void setAction(const QString &action)
Q_INVOKABLE void setDatabase(const QString &database)
Q_INVOKABLE void setRelations(const QStringList &relations)
QSqlError getError() const
Q_INVOKABLE void setUseExecBatch(bool useExecBatch)
Q_INVOKABLE int getErrorCode() const
Q_INVOKABLE void setFunction(const QString &fct)
Q_INVOKABLE void clearAll()
std::unique_ptr< QxRestApiImpl > m_pImpl
Private implementation idiom.
Definition QxRestApi.h:75
Q_INVOKABLE QString getErrorDesc() const
QxRestApi(QObject *parent=NULL)
Q_INVOKABLE void setData(const QString &data)
Q_INVOKABLE void setColumns(const QStringList &columns)
Q_INVOKABLE void setEntity(const QString &entity)
Root namespace for all QxOrm library features.