1 | #include <Functions/FunctionFactory.h> |
2 | #include <Functions/FunctionsStringArray.h> |
3 | |
4 | namespace DB |
5 | { |
6 | |
7 | class |
8 | { |
9 | private: |
10 | Pos ; |
11 | Pos ; |
12 | bool ; |
13 | |
14 | public: |
15 | static constexpr auto = "extractURLParameters" ; |
16 | static String () { return name; } |
17 | |
18 | static size_t () { return 1; } |
19 | |
20 | static void (const DataTypes & arguments) |
21 | { |
22 | if (!isString(arguments[0])) |
23 | throw Exception("Illegal type " + arguments[0]->getName() + " of first argument of function " + getName() + ". Must be String." , |
24 | ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); |
25 | } |
26 | |
27 | void (Block & /*block*/, const ColumnNumbers & /*arguments*/) {} |
28 | |
29 | /// Returns the position of the argument that is the column of rows |
30 | size_t () |
31 | { |
32 | return 0; |
33 | } |
34 | |
35 | /// Called for each next string. |
36 | void (Pos pos_, Pos end_) |
37 | { |
38 | pos = pos_; |
39 | end = end_; |
40 | first = true; |
41 | } |
42 | |
43 | /// Get the next token, if any, or return false. |
44 | bool (Pos & token_begin, Pos & token_end) |
45 | { |
46 | if (pos == nullptr) |
47 | return false; |
48 | |
49 | if (first) |
50 | { |
51 | first = false; |
52 | pos = find_first_symbols<'?', '#'>(pos, end); |
53 | if (pos + 1 >= end) |
54 | return false; |
55 | ++pos; |
56 | } |
57 | |
58 | while (true) |
59 | { |
60 | token_begin = pos; |
61 | pos = find_first_symbols<'=', '&', '#', '?'>(pos, end); |
62 | if (pos == end) |
63 | return false; |
64 | |
65 | if (*pos == '?') |
66 | { |
67 | ++pos; |
68 | continue; |
69 | } |
70 | |
71 | break; |
72 | } |
73 | |
74 | if (*pos == '&' || *pos == '#') |
75 | { |
76 | token_end = pos++; |
77 | } |
78 | else |
79 | { |
80 | ++pos; |
81 | pos = find_first_symbols<'&', '#'>(pos, end); |
82 | if (pos == end) |
83 | token_end = end; |
84 | else |
85 | token_end = pos++; |
86 | } |
87 | |
88 | return true; |
89 | } |
90 | }; |
91 | |
92 | struct { static constexpr auto = "extractURLParameters" ; }; |
93 | using = FunctionTokens<ExtractURLParametersImpl>; |
94 | |
95 | void (FunctionFactory & factory) |
96 | { |
97 | factory.registerFunction<FunctionExtractURLParameters>(); |
98 | } |
99 | |
100 | } |
101 | |