1#pragma once
2
3#include <common/StringRef.h>
4#include <Common/Exception.h>
5#include <Core/Types.h>
6
7namespace DB
8{
9namespace ErrorCodes
10{
11 extern const int NOT_IMPLEMENTED;
12}
13
14/// This class can be used as an argument for the template class FunctionJSON when we unable to parse JSONs.
15/// It can't do anything useful and just throws an exception.
16struct DummyJSONParser
17{
18 static constexpr bool need_preallocate = false;
19 void preallocate(size_t) {}
20
21 bool parse(const StringRef &) { throw Exception{"Functions JSON* are not supported without AVX2", ErrorCodes::NOT_IMPLEMENTED}; }
22
23 using Iterator = std::nullptr_t;
24 Iterator getRoot() const { return nullptr; }
25
26 static bool isInt64(const Iterator &) { return false; }
27 static bool isUInt64(const Iterator &) { return false; }
28 static bool isDouble(const Iterator &) { return false; }
29 static bool isString(const Iterator &) { return false; }
30 static bool isArray(const Iterator &) { return false; }
31 static bool isObject(const Iterator &) { return false; }
32 static bool isBool(const Iterator &) { return false; }
33 static bool isNull(const Iterator &) { return true; }
34
35 static Int64 getInt64(const Iterator &) { return 0; }
36 static UInt64 getUInt64(const Iterator &) { return 0; }
37 static double getDouble(const Iterator &) { return 0; }
38 static bool getBool(const Iterator &) { return false; }
39 static StringRef getString(const Iterator &) { return {}; }
40
41 static size_t sizeOfArray(const Iterator &) { return 0; }
42 static bool firstArrayElement(Iterator &) { return false; }
43 static bool arrayElementByIndex(Iterator &, size_t) { return false; }
44 static bool nextArrayElement(Iterator &) { return false; }
45
46 static size_t sizeOfObject(const Iterator &) { return 0; }
47 static bool firstObjectMember(Iterator &) { return false; }
48 static bool firstObjectMember(Iterator &, StringRef &) { return false; }
49 static bool objectMemberByIndex(Iterator &, size_t) { return false; }
50 static bool objectMemberByName(Iterator &, const StringRef &) { return false; }
51 static bool nextObjectMember(Iterator &) { return false; }
52 static bool nextObjectMember(Iterator &, StringRef &) { return false; }
53 static bool isObjectMember(const Iterator &) { return false; }
54 static StringRef getKey(const Iterator &) { return {}; }
55};
56
57}
58