aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Common/quoteString.h
blob: 3f17d6e7621aeda6745ab0f79b3238c749472255 (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
#pragma once

#include <base/types.h>
#include <base/StringRef.h>
#include <concepts>


namespace DB
{
[[nodiscard]] String quoteString(std::string_view x);

// Prefer string_view over StringRef for implicit conversions
[[nodiscard]] inline String quoteString(std::same_as<StringRef> auto x)
{
    return quoteString(std::string_view{x.data, x.size});
}

/// Double quote the string.
String doubleQuoteString(StringRef x);

/// Quote the identifier with backquotes.
String backQuote(StringRef x);

/// Quote the identifier with backquotes, if required.
String backQuoteIfNeed(StringRef x);

/// Quote the identifier with backquotes, for use in MySQL queries.
String backQuoteMySQL(StringRef x);

}