ScummVM API documentation
httpjsonrequest.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef BACKENDS_NETWORKING_HTTP_HTTPJSONREQUEST_H
23#define BACKENDS_NETWORKING_HTTP_HTTPJSONREQUEST_H
24
25#include "backends/networking/http/httprequest.h"
26#include "common/memstream.h"
27#include "common/formats/json.h"
28
29namespace Networking {
30
31typedef Response<const Common::JSONValue *> JsonResponse;
34
35#define HTTP_JSON_REQUEST_BUFFER_SIZE 512 * 1024
36
38protected:
39 JsonCallback _jsonCallback;
41 byte *_buffer;
42
44 virtual void finishJson(const Common::JSONValue *json);
45
46public:
48 ~HttpJsonRequest() override;
49
50 void handle() override;
51 void restart() override;
52
53 static bool jsonIsObject(const Common::JSONValue *item, const char *warningPrefix);
54 static bool jsonContainsObject(const Common::JSONObject &item, const char *key, const char *warningPrefix, bool isOptional = false);
55 static bool jsonContainsString(const Common::JSONObject &item, const char *key, const char *warningPrefix, bool isOptional = false);
56 static bool jsonContainsIntegerNumber(const Common::JSONObject &item, const char *key, const char *warningPrefix, bool isOptional = false);
57 static bool jsonContainsArray(const Common::JSONObject &item, const char *key, const char *warningPrefix, bool isOptional = false);
58 static bool jsonContainsStringOrIntegerNumber(const Common::JSONObject &item, const char *key, const char *warningPrefix, bool isOptional = false);
59 static bool jsonContainsAttribute(const Common::JSONObject &item, const char *key, const char *warningPrefix, bool isOptional = false);
60};
61
62} // End of namespace Networking
63
64#endif
Definition: hashmap.h:85
Definition: json.h:90
Definition: memstream.h:194
Definition: str.h:59
Definition: httpjsonrequest.h:37
virtual void finishJson(const Common::JSONValue *json)
Definition: httprequest.h:42