aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Functions/URL/queryStringAndFragment.h
blob: 27008388e4d68c914c780491de1cbb5d2344ad86 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#pragma once

#include <base/find_symbols.h>
#include <Functions/StringHelpers.h>


namespace DB
{

template <bool without_leading_char>
struct ExtractQueryStringAndFragment
{
    static size_t getReserveLengthForElement() { return 20; }

    static void execute(Pos data, size_t size, Pos & res_data, size_t & res_size)
    {
        res_data = data;
        res_size = 0;

        Pos end = data + size;
        Pos pos;

        if (end != (pos = find_first_symbols<'?'>(data, end)))
        {
            res_data = pos + (without_leading_char ? 1 : 0);
            res_size = end - res_data;
        }
        else if (end != (pos = find_first_symbols<'#'>(data, end)))
        {
            res_data = pos;
            res_size = end - res_data;
        }
    }
};

}