2019-10-08 18:42:22 +00:00
|
|
|
#include <Common/quoteString.h>
|
|
|
|
#include <IO/WriteHelpers.h>
|
|
|
|
#include <IO/WriteBufferFromString.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2021-10-03 15:36:08 +00:00
|
|
|
String quoteString(std::string_view x)
|
2019-10-08 18:42:22 +00:00
|
|
|
{
|
2021-10-03 15:36:08 +00:00
|
|
|
String res(x.size(), '\0');
|
2019-10-08 18:42:22 +00:00
|
|
|
WriteBufferFromString wb(res);
|
|
|
|
writeQuotedString(x, wb);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-07-15 11:15:46 +00:00
|
|
|
String doubleQuoteString(StringRef x)
|
2019-10-17 16:01:28 +00:00
|
|
|
{
|
|
|
|
String res(x.size, '\0');
|
|
|
|
WriteBufferFromString wb(res);
|
|
|
|
writeDoubleQuotedString(x, wb);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-07-15 11:15:46 +00:00
|
|
|
String backQuote(StringRef x)
|
2019-10-08 18:42:22 +00:00
|
|
|
{
|
|
|
|
String res(x.size, '\0');
|
|
|
|
{
|
|
|
|
WriteBufferFromString wb(res);
|
|
|
|
writeBackQuotedString(x, wb);
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-07-15 11:15:46 +00:00
|
|
|
String backQuoteIfNeed(StringRef x)
|
2019-10-08 18:42:22 +00:00
|
|
|
{
|
|
|
|
String res(x.size, '\0');
|
|
|
|
{
|
|
|
|
WriteBufferFromString wb(res);
|
|
|
|
writeProbablyBackQuotedString(x, wb);
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
2022-05-31 09:33:23 +00:00
|
|
|
|
2019-10-08 18:42:22 +00:00
|
|
|
}
|