2011-10-16 07:11:36 +00:00
|
|
|
|
#pragma once
|
|
|
|
|
|
2012-09-05 19:51:09 +00:00
|
|
|
|
#include <Poco/Mutex.h>
|
2014-01-27 13:49:06 +00:00
|
|
|
|
#include <boost/concept_check.hpp>
|
|
|
|
|
#include <boost/smart_ptr/shared_ptr.hpp>
|
2012-09-05 19:51:09 +00:00
|
|
|
|
|
2011-10-16 07:11:36 +00:00
|
|
|
|
#include <statdaemons/OptimizedRegularExpression.h>
|
|
|
|
|
|
|
|
|
|
#include <DB/DataTypes/DataTypesNumberFixed.h>
|
|
|
|
|
#include <DB/DataTypes/DataTypeString.h>
|
|
|
|
|
#include <DB/Columns/ColumnString.h>
|
|
|
|
|
#include <DB/Columns/ColumnConst.h>
|
2013-08-29 03:30:47 +00:00
|
|
|
|
#include <DB/Common/Volnitsky.h>
|
2011-10-16 07:11:36 +00:00
|
|
|
|
#include <DB/Functions/IFunction.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/** Функции поиска и замены в строках:
|
|
|
|
|
*
|
|
|
|
|
* position(haystack, needle) - обычный поиск подстроки в строке, возвращает позицию (в байтах) найденной подстроки, начиная с 1, или 0, если подстрока не найдена.
|
|
|
|
|
* positionUTF8(haystack, needle) - то же самое, но позиция вычисляется в кодовых точках, при условии, что строка в кодировке UTF-8.
|
2011-10-17 08:28:39 +00:00
|
|
|
|
*
|
|
|
|
|
* like(haystack, pattern) - поиск по регулярному выражению LIKE; возвращает 0 или 1. Регистронезависимое, но только для латиницы.
|
|
|
|
|
* notLike(haystack, pattern)
|
|
|
|
|
*
|
2011-10-16 07:11:36 +00:00
|
|
|
|
* match(haystack, pattern) - поиск по регулярному выражению re2; возвращает 0 или 1.
|
2012-07-21 03:45:48 +00:00
|
|
|
|
*
|
2013-03-18 10:49:31 +00:00
|
|
|
|
* Применяет регексп re2 и достаёт:
|
|
|
|
|
* - первый subpattern, если в regexp-е есть subpattern;
|
|
|
|
|
* - нулевой subpattern (сматчившуюся часть, иначе);
|
|
|
|
|
* - если не сматчилось - пустую строку.
|
|
|
|
|
* extract(haystack, pattern)
|
2011-10-17 08:28:39 +00:00
|
|
|
|
*
|
2011-10-16 07:11:36 +00:00
|
|
|
|
* replaceOne(haystack, pattern, replacement) - замена шаблона по заданным правилам, только первое вхождение.
|
|
|
|
|
* replaceAll(haystack, pattern, replacement) - замена шаблона по заданным правилам, все вхождения.
|
|
|
|
|
*
|
2012-12-26 14:51:41 +00:00
|
|
|
|
* Внимание! На данный момент, аргументы needle, pattern, n, replacement обязаны быть константами.
|
2011-10-16 07:11:36 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct PositionImpl
|
|
|
|
|
{
|
2011-10-17 08:28:39 +00:00
|
|
|
|
typedef UInt64 ResultType;
|
|
|
|
|
|
|
|
|
|
/// Предполагается, что res нужного размера и инициализирован нулями.
|
2013-09-15 05:51:43 +00:00
|
|
|
|
static void vector(const ColumnString::Chars_t & data, const ColumnString::Offsets_t & offsets,
|
2011-10-16 07:11:36 +00:00
|
|
|
|
const std::string & needle,
|
2013-12-08 02:29:40 +00:00
|
|
|
|
PODArray<UInt64> & res)
|
2011-10-16 07:11:36 +00:00
|
|
|
|
{
|
|
|
|
|
const UInt8 * begin = &data[0];
|
|
|
|
|
const UInt8 * pos = begin;
|
|
|
|
|
const UInt8 * end = pos + data.size();
|
|
|
|
|
|
|
|
|
|
/// Текущий индекс в массиве строк.
|
|
|
|
|
size_t i = 0;
|
|
|
|
|
|
2013-08-29 03:30:47 +00:00
|
|
|
|
Volnitsky searcher(needle.data(), needle.size(), end - pos);
|
|
|
|
|
|
2011-10-16 07:11:36 +00:00
|
|
|
|
/// Искать будем следующее вхождение сразу во всех строках.
|
2013-08-29 03:30:47 +00:00
|
|
|
|
while (pos < end && end != (pos = searcher.search(pos, end - pos)))
|
2011-10-16 07:11:36 +00:00
|
|
|
|
{
|
|
|
|
|
/// Определим, к какому индексу оно относится.
|
|
|
|
|
while (begin + offsets[i] < pos)
|
2013-12-08 02:29:40 +00:00
|
|
|
|
{
|
|
|
|
|
res[i] = 0;
|
2011-10-16 07:11:36 +00:00
|
|
|
|
++i;
|
2013-12-08 02:29:40 +00:00
|
|
|
|
}
|
2011-10-16 07:11:36 +00:00
|
|
|
|
|
|
|
|
|
/// Проверяем, что вхождение не переходит через границы строк.
|
|
|
|
|
if (pos + needle.size() < begin + offsets[i])
|
|
|
|
|
res[i] = (i != 0) ? pos - begin - offsets[i - 1] + 1 : (pos - begin + 1);
|
2013-12-08 02:29:40 +00:00
|
|
|
|
else
|
|
|
|
|
res[i] = 0;
|
2011-10-16 07:11:36 +00:00
|
|
|
|
|
2011-10-17 02:43:02 +00:00
|
|
|
|
pos = begin + offsets[i];
|
2011-10-16 07:11:36 +00:00
|
|
|
|
++i;
|
|
|
|
|
}
|
2013-12-08 02:29:40 +00:00
|
|
|
|
|
|
|
|
|
memset(&res[i], 0, (res.size() - i) * sizeof(res[0]));
|
2011-10-17 08:28:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void constant(const std::string & data, const std::string & needle, UInt64 & res)
|
|
|
|
|
{
|
|
|
|
|
res = data.find(needle);
|
|
|
|
|
if (res == std::string::npos)
|
|
|
|
|
res = 0;
|
|
|
|
|
else
|
|
|
|
|
++res;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct PositionUTF8Impl
|
|
|
|
|
{
|
|
|
|
|
typedef UInt64 ResultType;
|
|
|
|
|
|
2013-09-15 05:51:43 +00:00
|
|
|
|
static void vector(const ColumnString::Chars_t & data, const ColumnString::Offsets_t & offsets,
|
2011-10-17 08:28:39 +00:00
|
|
|
|
const std::string & needle,
|
2013-12-08 02:29:40 +00:00
|
|
|
|
PODArray<UInt64> & res)
|
2011-10-17 08:28:39 +00:00
|
|
|
|
{
|
|
|
|
|
const UInt8 * begin = &data[0];
|
|
|
|
|
const UInt8 * pos = begin;
|
|
|
|
|
const UInt8 * end = pos + data.size();
|
2011-10-16 07:11:36 +00:00
|
|
|
|
|
2011-10-17 08:28:39 +00:00
|
|
|
|
/// Текущий индекс в массиве строк.
|
|
|
|
|
size_t i = 0;
|
|
|
|
|
|
2013-08-29 03:30:47 +00:00
|
|
|
|
Volnitsky searcher(needle.data(), needle.size(), end - pos);
|
|
|
|
|
|
2011-10-17 08:28:39 +00:00
|
|
|
|
/// Искать будем следующее вхождение сразу во всех строках.
|
2013-08-29 03:30:47 +00:00
|
|
|
|
while (pos < end && end != (pos = searcher.search(pos, end - pos)))
|
2011-10-17 08:28:39 +00:00
|
|
|
|
{
|
|
|
|
|
/// Определим, к какому индексу оно относится.
|
|
|
|
|
while (begin + offsets[i] < pos)
|
2013-12-08 02:29:40 +00:00
|
|
|
|
{
|
|
|
|
|
res[i] = 0;
|
2011-10-17 08:28:39 +00:00
|
|
|
|
++i;
|
2013-12-08 02:29:40 +00:00
|
|
|
|
}
|
2011-10-17 08:28:39 +00:00
|
|
|
|
|
|
|
|
|
/// Проверяем, что вхождение не переходит через границы строк.
|
|
|
|
|
if (pos + needle.size() < begin + offsets[i])
|
|
|
|
|
{
|
|
|
|
|
/// А теперь надо найти, сколько кодовых точек находится перед pos.
|
|
|
|
|
res[i] = 1;
|
|
|
|
|
for (const UInt8 * c = begin + (i != 0 ? offsets[i - 1] : 0); c < pos; ++c)
|
|
|
|
|
if (*c <= 0x7F || *c >= 0xC0)
|
|
|
|
|
++res[i];
|
|
|
|
|
}
|
2013-12-08 02:29:40 +00:00
|
|
|
|
else
|
|
|
|
|
res[i] = 0;
|
2011-10-17 08:28:39 +00:00
|
|
|
|
|
|
|
|
|
pos = begin + offsets[i];
|
|
|
|
|
++i;
|
|
|
|
|
}
|
2013-12-08 02:29:40 +00:00
|
|
|
|
|
|
|
|
|
memset(&res[i], 0, (res.size() - i) * sizeof(res[0]));
|
2011-10-16 07:11:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void constant(const std::string & data, const std::string & needle, UInt64 & res)
|
|
|
|
|
{
|
|
|
|
|
res = data.find(needle);
|
|
|
|
|
if (res == std::string::npos)
|
|
|
|
|
res = 0;
|
|
|
|
|
else
|
|
|
|
|
++res;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2011-10-24 12:10:59 +00:00
|
|
|
|
/// Переводит выражение LIKE в regexp re2. Например, abc%def -> ^abc.*def$
|
2011-10-17 08:28:39 +00:00
|
|
|
|
inline String likePatternToRegexp(const String & pattern)
|
|
|
|
|
{
|
|
|
|
|
String res = "^";
|
|
|
|
|
res.reserve(pattern.size() * 2);
|
|
|
|
|
const char * pos = pattern.data();
|
|
|
|
|
const char * end = pos + pattern.size();
|
|
|
|
|
|
|
|
|
|
while (pos < end)
|
|
|
|
|
{
|
|
|
|
|
switch (*pos)
|
|
|
|
|
{
|
|
|
|
|
case '^': case '$': case '.': case '[': case '|': case '(': case ')': case '?': case '*': case '+': case '{':
|
|
|
|
|
res += '\\';
|
|
|
|
|
res += *pos;
|
|
|
|
|
break;
|
|
|
|
|
case '%':
|
|
|
|
|
res += ".*";
|
|
|
|
|
break;
|
|
|
|
|
case '_':
|
|
|
|
|
res += ".";
|
|
|
|
|
break;
|
|
|
|
|
case '\\':
|
|
|
|
|
++pos;
|
|
|
|
|
if (pos == end)
|
|
|
|
|
res += "\\\\";
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (*pos == '%' || *pos == '_')
|
|
|
|
|
res += *pos;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
res += '\\';
|
|
|
|
|
res += *pos;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
res += *pos;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
++pos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
res += '$';
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-10-24 12:10:59 +00:00
|
|
|
|
/// Сводится ли выражение LIKE к поиску подстроки в строке?
|
|
|
|
|
inline bool likePatternIsStrstr(const String & pattern, String & res)
|
|
|
|
|
{
|
|
|
|
|
res = "";
|
|
|
|
|
|
|
|
|
|
if (pattern.size() < 2 || *pattern.begin() != '%' || *pattern.rbegin() != '%')
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
res.reserve(pattern.size() * 2);
|
|
|
|
|
|
|
|
|
|
const char * pos = pattern.data();
|
|
|
|
|
const char * end = pos + pattern.size();
|
|
|
|
|
|
|
|
|
|
++pos;
|
|
|
|
|
--end;
|
|
|
|
|
|
|
|
|
|
while (pos < end)
|
|
|
|
|
{
|
|
|
|
|
switch (*pos)
|
|
|
|
|
{
|
|
|
|
|
case '%': case '_':
|
|
|
|
|
return false;
|
|
|
|
|
case '\\':
|
|
|
|
|
++pos;
|
|
|
|
|
if (pos == end)
|
|
|
|
|
return false;
|
|
|
|
|
else
|
|
|
|
|
res += *pos;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
res += *pos;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
++pos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-10-17 08:28:39 +00:00
|
|
|
|
struct Regexps
|
|
|
|
|
{
|
|
|
|
|
typedef std::map<String, OptimizedRegularExpression> KnownRegexps;
|
|
|
|
|
|
|
|
|
|
static const OptimizedRegularExpression & get(const std::string & pattern)
|
|
|
|
|
{
|
|
|
|
|
/// В GCC thread safe statics.
|
|
|
|
|
static KnownRegexps known_regexps;
|
|
|
|
|
static Poco::FastMutex mutex;
|
|
|
|
|
Poco::ScopedLock<Poco::FastMutex> lock(mutex);
|
|
|
|
|
|
|
|
|
|
KnownRegexps::const_iterator it = known_regexps.find(pattern);
|
|
|
|
|
if (known_regexps.end() == it)
|
|
|
|
|
it = known_regexps.insert(std::make_pair(pattern, OptimizedRegularExpression(pattern))).first;
|
|
|
|
|
|
|
|
|
|
return it->second;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const OptimizedRegularExpression & getLike(const std::string & pattern)
|
|
|
|
|
{
|
|
|
|
|
/// В GCC thread safe statics.
|
|
|
|
|
static KnownRegexps known_regexps;
|
|
|
|
|
static Poco::FastMutex mutex;
|
|
|
|
|
Poco::ScopedLock<Poco::FastMutex> lock(mutex);
|
|
|
|
|
|
|
|
|
|
KnownRegexps::const_iterator it = known_regexps.find(pattern);
|
|
|
|
|
if (known_regexps.end() == it)
|
2013-11-11 17:56:41 +00:00
|
|
|
|
it = known_regexps.insert(std::make_pair(pattern, OptimizedRegularExpression(likePatternToRegexp(pattern)))).first;
|
2011-10-17 08:28:39 +00:00
|
|
|
|
|
|
|
|
|
return it->second;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** like - использовать выражения LIKE, если true; использовать выражения re2, если false.
|
|
|
|
|
* Замечание: хотелось бы запускать регексп сразу над всем массивом, аналогично функции position,
|
|
|
|
|
* но для этого пришлось бы сделать поддержку символов \0 в движке регулярных выражений,
|
|
|
|
|
* и их интерпретацию как начал и концов строк.
|
|
|
|
|
*/
|
|
|
|
|
template <bool like, bool revert = false>
|
|
|
|
|
struct MatchImpl
|
|
|
|
|
{
|
|
|
|
|
typedef UInt8 ResultType;
|
|
|
|
|
|
2013-09-15 05:51:43 +00:00
|
|
|
|
static void vector(const ColumnString::Chars_t & data, const ColumnString::Offsets_t & offsets,
|
2011-10-17 08:28:39 +00:00
|
|
|
|
const std::string & pattern,
|
2013-12-08 02:29:40 +00:00
|
|
|
|
PODArray<UInt8> & res)
|
2011-10-17 08:28:39 +00:00
|
|
|
|
{
|
2011-10-24 12:10:59 +00:00
|
|
|
|
String strstr_pattern;
|
|
|
|
|
/// Простой случай, когда выражение LIKE сводится к поиску подстроки в строке
|
|
|
|
|
if (like && likePatternIsStrstr(pattern, strstr_pattern))
|
|
|
|
|
{
|
|
|
|
|
const UInt8 * begin = &data[0];
|
|
|
|
|
const UInt8 * pos = begin;
|
|
|
|
|
const UInt8 * end = pos + data.size();
|
|
|
|
|
|
|
|
|
|
/// Текущий индекс в массиве строк.
|
|
|
|
|
size_t i = 0;
|
2011-10-17 08:28:39 +00:00
|
|
|
|
|
2013-08-29 03:30:47 +00:00
|
|
|
|
Volnitsky searcher(strstr_pattern.data(), strstr_pattern.size(), end - pos);
|
|
|
|
|
|
2011-10-24 12:10:59 +00:00
|
|
|
|
/// Искать будем следующее вхождение сразу во всех строках.
|
2013-08-29 03:30:47 +00:00
|
|
|
|
while (pos < end && end != (pos = searcher.search(pos, end - pos)))
|
2011-10-24 12:10:59 +00:00
|
|
|
|
{
|
|
|
|
|
/// Определим, к какому индексу оно относится.
|
|
|
|
|
while (begin + offsets[i] < pos)
|
2013-12-08 02:29:40 +00:00
|
|
|
|
{
|
|
|
|
|
res[i] = revert;
|
2011-10-24 12:10:59 +00:00
|
|
|
|
++i;
|
2013-12-08 02:29:40 +00:00
|
|
|
|
}
|
2011-10-24 12:10:59 +00:00
|
|
|
|
|
|
|
|
|
/// Проверяем, что вхождение не переходит через границы строк.
|
|
|
|
|
if (pos + strstr_pattern.size() < begin + offsets[i])
|
2012-08-03 18:49:39 +00:00
|
|
|
|
res[i] = !revert;
|
2013-12-08 02:29:40 +00:00
|
|
|
|
else
|
|
|
|
|
res[i] = revert;
|
2011-10-24 12:10:59 +00:00
|
|
|
|
|
|
|
|
|
pos = begin + offsets[i];
|
|
|
|
|
++i;
|
|
|
|
|
}
|
2013-12-08 02:29:40 +00:00
|
|
|
|
|
|
|
|
|
memset(&res[i], revert, (res.size() - i) * sizeof(res[0]));
|
2011-10-24 12:10:59 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
const OptimizedRegularExpression & regexp = like ? Regexps::getLike(pattern) : Regexps::get(pattern);
|
|
|
|
|
|
|
|
|
|
size_t size = offsets.size();
|
|
|
|
|
for (size_t i = 0; i < size; ++i)
|
2012-06-18 07:49:19 +00:00
|
|
|
|
res[i] = revert ^ regexp.match(reinterpret_cast<const char *>(&data[i != 0 ? offsets[i - 1] : 0]), (i != 0 ? offsets[i] - offsets[i - 1] : offsets[0]) - 1);
|
2011-10-24 12:10:59 +00:00
|
|
|
|
}
|
2011-10-17 08:28:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void constant(const std::string & data, const std::string & pattern, UInt8 & res)
|
|
|
|
|
{
|
|
|
|
|
const OptimizedRegularExpression & regexp = like ? Regexps::getLike(pattern) : Regexps::get(pattern);
|
|
|
|
|
res = revert ^ regexp.match(data);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2013-02-28 13:01:07 +00:00
|
|
|
|
struct ExtractImpl
|
|
|
|
|
{
|
2013-09-15 05:51:43 +00:00
|
|
|
|
static void vector(const ColumnString::Chars_t & data, const ColumnString::Offsets_t & offsets,
|
2013-02-28 13:01:07 +00:00
|
|
|
|
const std::string & pattern,
|
2013-09-15 05:51:43 +00:00
|
|
|
|
ColumnString::Chars_t & res_data, ColumnString::Offsets_t & res_offsets)
|
2013-02-28 13:01:07 +00:00
|
|
|
|
{
|
2013-10-03 19:23:08 +00:00
|
|
|
|
res_data.reserve(data.size() / 5);
|
2013-02-28 13:01:07 +00:00
|
|
|
|
res_offsets.resize(offsets.size());
|
|
|
|
|
|
|
|
|
|
const OptimizedRegularExpression & regexp = Regexps::get(pattern);
|
|
|
|
|
|
2013-05-22 18:56:19 +00:00
|
|
|
|
unsigned capture = regexp.getNumberOfSubpatterns() > 0 ? 1 : 0;
|
2013-02-28 13:01:07 +00:00
|
|
|
|
OptimizedRegularExpression::MatchVec matches;
|
|
|
|
|
matches.reserve(capture + 1);
|
|
|
|
|
size_t prev_offset = 0;
|
|
|
|
|
size_t res_offset = 0;
|
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < offsets.size(); ++i)
|
|
|
|
|
{
|
|
|
|
|
size_t cur_offset = offsets[i];
|
|
|
|
|
|
2013-03-04 10:10:19 +00:00
|
|
|
|
unsigned count = regexp.match(reinterpret_cast<const char *>(&data[prev_offset]), cur_offset - prev_offset - 1, matches, capture + 1);
|
|
|
|
|
if (count > capture && matches[capture].offset != std::string::npos)
|
2013-02-28 13:01:07 +00:00
|
|
|
|
{
|
2013-03-04 10:10:19 +00:00
|
|
|
|
const OptimizedRegularExpression::Match & match = matches[capture];
|
2013-02-28 13:01:07 +00:00
|
|
|
|
res_data.resize(res_offset + match.length + 1);
|
|
|
|
|
memcpy(&res_data[res_offset], &data[prev_offset + match.offset], match.length);
|
|
|
|
|
res_offset += match.length;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
res_data.resize(res_offset + 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
res_data[res_offset] = 0;
|
|
|
|
|
++res_offset;
|
|
|
|
|
res_offsets[i] = res_offset;
|
|
|
|
|
|
|
|
|
|
prev_offset = cur_offset;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2014-01-27 13:49:06 +00:00
|
|
|
|
/** Заменить все вхождения подстроки needle на строку replacement. needle и replacement - константы.
|
|
|
|
|
*/
|
|
|
|
|
template <bool replaceOne = false>
|
|
|
|
|
struct ReplaceImpl
|
|
|
|
|
{
|
|
|
|
|
static void vector(const ColumnString::Chars_t & data, const ColumnString::Offsets_t & offsets,
|
|
|
|
|
const std::string & needle, const std::string & replacement,
|
|
|
|
|
ColumnString::Chars_t & res_data, ColumnString::Offsets_t & res_offsets)
|
|
|
|
|
{
|
|
|
|
|
const UInt8 * begin = &data[0];
|
|
|
|
|
const UInt8 * pos = begin;
|
|
|
|
|
const UInt8 * end = pos + data.size();
|
|
|
|
|
|
|
|
|
|
ColumnString::Offset_t res_offset = 0;
|
|
|
|
|
res_data.reserve(data.size());
|
|
|
|
|
size_t size = offsets.size();
|
|
|
|
|
res_offsets.resize(size);
|
|
|
|
|
|
|
|
|
|
/// Текущий индекс в массиве строк.
|
|
|
|
|
size_t i = 0;
|
|
|
|
|
|
|
|
|
|
Volnitsky searcher(needle.data(), needle.size(), end - pos);
|
|
|
|
|
|
|
|
|
|
/// Искать будем следующее вхождение сразу во всех строках.
|
|
|
|
|
while (pos < end)
|
|
|
|
|
{
|
|
|
|
|
const UInt8 * match = searcher.search(pos, end - pos);
|
|
|
|
|
|
|
|
|
|
/// Копируем данные без изменения
|
|
|
|
|
res_data.resize(res_data.size() + (match - pos));
|
|
|
|
|
memcpy(&res_data[res_offset], pos, match - pos);
|
|
|
|
|
|
|
|
|
|
/// Определим, к какому индексу оно относится.
|
|
|
|
|
while (i < offsets.size() && begin + offsets[i] < match)
|
|
|
|
|
{
|
|
|
|
|
res_offsets[i] = res_offset + ((begin + offsets[i]) - pos);
|
|
|
|
|
++i;
|
|
|
|
|
}
|
|
|
|
|
res_offset += (match - pos);
|
|
|
|
|
|
|
|
|
|
/// Если дошли до конца, пора остановиться
|
|
|
|
|
if (i == offsets.size())
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
/// Правда ли, что с этой строкой больше не надо выполнять преобразования.
|
|
|
|
|
bool can_finish_current_string = false;
|
|
|
|
|
|
|
|
|
|
/// Проверяем, что вхождение не переходит через границы строк.
|
|
|
|
|
if (match + needle.size() < begin + offsets[i])
|
|
|
|
|
{
|
|
|
|
|
res_data.resize(res_data.size() + replacement.size());
|
|
|
|
|
memcpy(&res_data[res_offset], replacement.data(), replacement.size());
|
|
|
|
|
res_offset += replacement.size();
|
|
|
|
|
pos = match + needle.size();
|
|
|
|
|
if (replaceOne)
|
|
|
|
|
can_finish_current_string = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
can_finish_current_string = true;
|
|
|
|
|
|
|
|
|
|
if (can_finish_current_string)
|
|
|
|
|
{
|
|
|
|
|
res_data.resize(res_data.size() + (begin + offsets[i] - match));
|
|
|
|
|
memcpy(&res_data[res_offset], match, (begin + offsets[i] - match));
|
|
|
|
|
res_offsets[i] = res_offset + (begin + offsets[i] - match);
|
|
|
|
|
pos = begin + offsets[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void vector_fixed(const ColumnString::Chars_t & data, size_t n,
|
|
|
|
|
const std::string & needle, const std::string & replacement,
|
|
|
|
|
ColumnString::Chars_t & res_data, ColumnString::Offsets_t & res_offsets)
|
|
|
|
|
{
|
|
|
|
|
const UInt8 * begin = &data[0];
|
|
|
|
|
const UInt8 * pos = begin;
|
|
|
|
|
const UInt8 * end = pos + data.size();
|
|
|
|
|
|
|
|
|
|
ColumnString::Offset_t res_offset = 0;
|
|
|
|
|
size_t size = data.size() / n;
|
|
|
|
|
res_data.reserve(data.size());
|
|
|
|
|
res_offsets.resize(size);
|
|
|
|
|
|
|
|
|
|
/// Текущий индекс в массиве строк.
|
|
|
|
|
size_t i = 0;
|
|
|
|
|
|
|
|
|
|
Volnitsky searcher(needle.data(), needle.size(), end - pos);
|
|
|
|
|
|
|
|
|
|
/// Искать будем следующее вхождение сразу во всех строках.
|
|
|
|
|
while (pos < end)
|
|
|
|
|
{
|
|
|
|
|
const UInt8 * match = searcher.search(pos, end - pos);
|
|
|
|
|
|
|
|
|
|
/// Копируем данные без изменения
|
|
|
|
|
res_data.resize(res_data.size() + (match - pos));
|
|
|
|
|
memcpy(&res_data[res_offset], pos, match - pos);
|
|
|
|
|
|
|
|
|
|
/// Определим, к какому индексу оно относится.
|
|
|
|
|
while (i < size && begin + n * (i + 1) < match)
|
|
|
|
|
{
|
|
|
|
|
res_offsets[i] = res_offset + ((begin + n * (i + 1)) - pos);
|
|
|
|
|
++i;
|
|
|
|
|
}
|
|
|
|
|
res_offset += (match - pos);
|
|
|
|
|
|
|
|
|
|
/// Если дошли до конца, пора остановиться
|
|
|
|
|
if (i == size)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
/// Правда ли, что с этой строкой больше не надо выполнять преобразования.
|
|
|
|
|
bool can_finish_current_string = false;
|
|
|
|
|
|
|
|
|
|
/// Проверяем, что вхождение не переходит через границы строк.
|
|
|
|
|
if (match + needle.size() < begin + n * (i + 1))
|
|
|
|
|
{
|
|
|
|
|
res_data.resize(res_data.size() + replacement.size());
|
|
|
|
|
memcpy(&res_data[res_offset], replacement.data(), replacement.size());
|
|
|
|
|
res_offset += replacement.size();
|
|
|
|
|
pos = match + needle.size();
|
|
|
|
|
if (replaceOne)
|
|
|
|
|
can_finish_current_string = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
can_finish_current_string = true;
|
|
|
|
|
|
|
|
|
|
if (can_finish_current_string)
|
|
|
|
|
{
|
|
|
|
|
res_data.resize(res_data.size() + (begin + n * (i + 1) - match));
|
|
|
|
|
memcpy(&res_data[res_offset], match, (begin + n * (i + 1) - match));
|
|
|
|
|
res_offsets[i] = res_offset + (begin + n * (i + 1) - match);
|
|
|
|
|
pos = begin + n * (i + 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void constant(const std::string & data, const std::string & needle, const std::string & replacement,
|
|
|
|
|
std::string & res_data)
|
|
|
|
|
{
|
|
|
|
|
res_data = "";
|
|
|
|
|
int replace_cnt = 0;
|
|
|
|
|
for (size_t i = 0; i < data.size(); ++i)
|
|
|
|
|
{
|
|
|
|
|
bool match = true;
|
|
|
|
|
if (i + needle.size() > data.size() || (replaceOne && replace_cnt > 0))
|
|
|
|
|
match = false;
|
|
|
|
|
for (size_t j = 0; match && j < needle.size(); ++j)
|
|
|
|
|
if (data[i + j] != needle[j])
|
|
|
|
|
match = false;
|
|
|
|
|
if (match)
|
|
|
|
|
{
|
|
|
|
|
replace_cnt ++;
|
|
|
|
|
res_data += replacement;
|
|
|
|
|
i = i + needle.size() - 1;
|
|
|
|
|
} else
|
|
|
|
|
res_data += data[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <typename Impl, typename Name>
|
|
|
|
|
class FunctionStringReplace : public IFunction
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
/// Получить имя функции.
|
|
|
|
|
String getName() const
|
|
|
|
|
{
|
|
|
|
|
return Name::get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
|
|
|
|
|
DataTypePtr getReturnType(const DataTypes & arguments) const
|
|
|
|
|
{
|
|
|
|
|
if (arguments.size() != 3)
|
|
|
|
|
throw Exception("Number of arguments for function " + getName() + " doesn't match: passed "
|
|
|
|
|
+ toString(arguments.size()) + ", should be 3.",
|
|
|
|
|
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
|
|
|
|
|
|
|
|
|
|
if (!dynamic_cast<const DataTypeString *>(&*arguments[0]) && !dynamic_cast<const DataTypeFixedString *>(&*arguments[0]))
|
|
|
|
|
throw Exception("Illegal type " + arguments[0]->getName() + " of first argument of function " + getName(),
|
|
|
|
|
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
|
|
|
|
|
|
|
|
|
|
if (!dynamic_cast<const DataTypeString *>(&*arguments[0]) && !dynamic_cast<const DataTypeFixedString *>(&*arguments[0]))
|
|
|
|
|
throw Exception("Illegal type " + arguments[1]->getName() + " of second argument of function " + getName(),
|
|
|
|
|
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
|
|
|
|
|
|
|
|
|
|
if (!dynamic_cast<const DataTypeString *>(&*arguments[0]) && !dynamic_cast<const DataTypeFixedString *>(&*arguments[0]))
|
|
|
|
|
throw Exception("Illegal type " + arguments[2]->getName() + " of third argument of function " + getName(),
|
|
|
|
|
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
|
|
|
|
|
|
|
|
|
|
return new DataTypeString;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Выполнить функцию над блоком.
|
|
|
|
|
void execute(Block & block, const ColumnNumbers & arguments, size_t result)
|
|
|
|
|
{
|
|
|
|
|
const ColumnPtr column_src = block.getByPosition(arguments[0]).column;
|
|
|
|
|
const ColumnPtr column_needle = block.getByPosition(arguments[1]).column;
|
|
|
|
|
const ColumnPtr column_replacement = block.getByPosition(arguments[2]).column;
|
|
|
|
|
|
|
|
|
|
if (!column_needle->isConst() || !column_replacement->isConst())
|
|
|
|
|
throw Exception("2nd and 3rd arguments of function " + getName() + " must be constants.");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const IColumn * c1 = &*block.getByPosition(arguments[1]).column;
|
|
|
|
|
const IColumn * c2 = &*block.getByPosition(arguments[2]).column;
|
|
|
|
|
const ColumnConstString * c1_const = dynamic_cast<const ColumnConstString *>(c1);
|
|
|
|
|
const ColumnConstString * c2_const = dynamic_cast<const ColumnConstString *>(c2);
|
|
|
|
|
String needle = c1_const->getData();
|
|
|
|
|
String replacement = c2_const->getData();
|
|
|
|
|
|
|
|
|
|
if (needle.size() == 0)
|
|
|
|
|
throw Exception("Length of the second argument of function replace must be greater than 0.", ErrorCodes::ARGUMENT_OUT_OF_BOUND);
|
|
|
|
|
|
|
|
|
|
if (const ColumnString * col = dynamic_cast<const ColumnString *>(&*column_src))
|
|
|
|
|
{
|
|
|
|
|
ColumnString * col_res = new ColumnString;
|
|
|
|
|
block.getByPosition(result).column = col_res;
|
|
|
|
|
Impl::vector(col->getChars(), col->getOffsets(),
|
|
|
|
|
needle, replacement,
|
|
|
|
|
col_res->getChars(), col_res->getOffsets());
|
|
|
|
|
}
|
|
|
|
|
else if (const ColumnFixedString * col = dynamic_cast<const ColumnFixedString *>(&*column_src))
|
|
|
|
|
{
|
|
|
|
|
ColumnString * col_res = new ColumnString;
|
|
|
|
|
block.getByPosition(result).column = col_res;
|
|
|
|
|
Impl::vector_fixed(col->getChars(), col->getN(),
|
|
|
|
|
needle, replacement,
|
|
|
|
|
col_res->getChars(), col_res->getOffsets());
|
|
|
|
|
}
|
|
|
|
|
else if (const ColumnConstString * col = dynamic_cast<const ColumnConstString *>(&*column_src))
|
|
|
|
|
{
|
|
|
|
|
String res;
|
|
|
|
|
Impl::constant(col->getData(), needle, replacement, res);
|
|
|
|
|
ColumnConstString * col_res = new ColumnConstString(col->size(), res);
|
|
|
|
|
block.getByPosition(result).column = col_res;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
throw Exception("Illegal column " + block.getByPosition(arguments[0]).column->getName()
|
|
|
|
|
+ " of first argument of function " + getName(),
|
|
|
|
|
ErrorCodes::ILLEGAL_COLUMN);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2011-10-17 08:28:39 +00:00
|
|
|
|
template <typename Impl, typename Name>
|
|
|
|
|
class FunctionsStringSearch : public IFunction
|
2011-10-16 07:11:36 +00:00
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
/// Получить имя функции.
|
|
|
|
|
String getName() const
|
|
|
|
|
{
|
2011-10-17 08:28:39 +00:00
|
|
|
|
return Name::get();
|
2011-10-16 07:11:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
|
|
|
|
|
DataTypePtr getReturnType(const DataTypes & arguments) const
|
|
|
|
|
{
|
|
|
|
|
if (arguments.size() != 2)
|
|
|
|
|
throw Exception("Number of arguments for function " + getName() + " doesn't match: passed "
|
2013-06-21 20:34:19 +00:00
|
|
|
|
+ toString(arguments.size()) + ", should be 2.",
|
2011-10-16 07:11:36 +00:00
|
|
|
|
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
|
|
|
|
|
|
|
|
|
|
if (!dynamic_cast<const DataTypeString *>(&*arguments[0]))
|
|
|
|
|
throw Exception("Illegal type " + arguments[0]->getName() + " of argument of function " + getName(),
|
|
|
|
|
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
|
|
|
|
|
|
|
|
|
|
if (!dynamic_cast<const DataTypeString *>(&*arguments[1]))
|
|
|
|
|
throw Exception("Illegal type " + arguments[1]->getName() + " of argument of function " + getName(),
|
|
|
|
|
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
|
|
|
|
|
|
2011-10-17 08:28:39 +00:00
|
|
|
|
return new typename DataTypeFromFieldType<typename Impl::ResultType>::Type;
|
2011-10-16 07:11:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Выполнить функцию над блоком.
|
|
|
|
|
void execute(Block & block, const ColumnNumbers & arguments, size_t result)
|
|
|
|
|
{
|
2011-10-17 08:28:39 +00:00
|
|
|
|
typedef typename Impl::ResultType ResultType;
|
2011-10-16 07:11:36 +00:00
|
|
|
|
|
|
|
|
|
const ColumnPtr column = block.getByPosition(arguments[0]).column;
|
|
|
|
|
const ColumnPtr column_needle = block.getByPosition(arguments[1]).column;
|
|
|
|
|
|
|
|
|
|
const ColumnConstString * col_needle = dynamic_cast<const ColumnConstString *>(&*column_needle);
|
|
|
|
|
if (!col_needle)
|
|
|
|
|
throw Exception("Second argument of function " + getName() + " must be constant string.", ErrorCodes::ILLEGAL_COLUMN);
|
|
|
|
|
|
|
|
|
|
if (const ColumnString * col = dynamic_cast<const ColumnString *>(&*column))
|
|
|
|
|
{
|
|
|
|
|
ColumnVector<ResultType> * col_res = new ColumnVector<ResultType>;
|
|
|
|
|
block.getByPosition(result).column = col_res;
|
|
|
|
|
|
2011-10-17 08:28:39 +00:00
|
|
|
|
typename ColumnVector<ResultType>::Container_t & vec_res = col_res->getData();
|
2011-10-16 07:11:36 +00:00
|
|
|
|
vec_res.resize(col->size());
|
2013-05-05 15:25:25 +00:00
|
|
|
|
Impl::vector(col->getChars(), col->getOffsets(), col_needle->getData(), vec_res);
|
2011-10-16 07:11:36 +00:00
|
|
|
|
}
|
|
|
|
|
else if (const ColumnConstString * col = dynamic_cast<const ColumnConstString *>(&*column))
|
|
|
|
|
{
|
|
|
|
|
ResultType res = 0;
|
2011-10-17 08:28:39 +00:00
|
|
|
|
Impl::constant(col->getData(), col_needle->getData(), res);
|
2011-10-16 07:11:36 +00:00
|
|
|
|
|
|
|
|
|
ColumnConst<ResultType> * col_res = new ColumnConst<ResultType>(col->size(), res);
|
|
|
|
|
block.getByPosition(result).column = col_res;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
throw Exception("Illegal column " + block.getByPosition(arguments[0]).column->getName()
|
|
|
|
|
+ " of argument of function " + getName(),
|
|
|
|
|
ErrorCodes::ILLEGAL_COLUMN);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2011-10-17 08:28:39 +00:00
|
|
|
|
|
2013-02-28 13:01:07 +00:00
|
|
|
|
template <typename Impl, typename Name>
|
|
|
|
|
class FunctionsStringSearchToString : public IFunction
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
/// Получить имя функции.
|
|
|
|
|
String getName() const
|
|
|
|
|
{
|
|
|
|
|
return Name::get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Получить тип результата по типам аргументов. Если функция неприменима для данных аргументов - кинуть исключение.
|
|
|
|
|
DataTypePtr getReturnType(const DataTypes & arguments) const
|
|
|
|
|
{
|
|
|
|
|
if (arguments.size() != 2)
|
|
|
|
|
throw Exception("Number of arguments for function " + getName() + " doesn't match: passed "
|
2013-06-21 20:34:19 +00:00
|
|
|
|
+ toString(arguments.size()) + ", should be 2.",
|
2013-02-28 13:01:07 +00:00
|
|
|
|
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
|
2013-03-04 10:38:44 +00:00
|
|
|
|
|
|
|
|
|
if (!dynamic_cast<const DataTypeString *>(&*arguments[0]))
|
|
|
|
|
throw Exception("Illegal type " + arguments[0]->getName() + " of argument of function " + getName(),
|
|
|
|
|
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
|
|
|
|
|
|
|
|
|
|
if (!dynamic_cast<const DataTypeString *>(&*arguments[1]))
|
|
|
|
|
throw Exception("Illegal type " + arguments[1]->getName() + " of argument of function " + getName(),
|
|
|
|
|
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
|
|
|
|
|
|
|
|
|
|
return new DataTypeString;
|
2013-02-28 13:01:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Выполнить функцию над блоком.
|
|
|
|
|
void execute(Block & block, const ColumnNumbers & arguments, size_t result)
|
|
|
|
|
{
|
|
|
|
|
const ColumnPtr column = block.getByPosition(arguments[0]).column;
|
|
|
|
|
const ColumnPtr column_needle = block.getByPosition(arguments[1]).column;
|
|
|
|
|
|
|
|
|
|
const ColumnConstString * col_needle = dynamic_cast<const ColumnConstString *>(&*column_needle);
|
|
|
|
|
if (!col_needle)
|
|
|
|
|
throw Exception("Second argument of function " + getName() + " must be constant string.", ErrorCodes::ILLEGAL_COLUMN);
|
|
|
|
|
|
|
|
|
|
if (const ColumnString * col = dynamic_cast<const ColumnString *>(&*column))
|
|
|
|
|
{
|
|
|
|
|
ColumnString * col_res = new ColumnString;
|
|
|
|
|
block.getByPosition(result).column = col_res;
|
|
|
|
|
|
2013-05-05 15:25:25 +00:00
|
|
|
|
ColumnString::Chars_t & vec_res = col_res->getChars();
|
2013-02-28 13:01:07 +00:00
|
|
|
|
ColumnString::Offsets_t & offsets_res = col_res->getOffsets();
|
2013-05-05 15:25:25 +00:00
|
|
|
|
Impl::vector(col->getChars(), col->getOffsets(), col_needle->getData(), vec_res, offsets_res);
|
2013-02-28 13:01:07 +00:00
|
|
|
|
}
|
|
|
|
|
else if (const ColumnConstString * col = dynamic_cast<const ColumnConstString *>(&*column))
|
|
|
|
|
{
|
2013-03-05 12:12:47 +00:00
|
|
|
|
const std::string & data = col->getData();
|
2013-09-15 05:51:43 +00:00
|
|
|
|
ColumnString::Chars_t vdata(
|
|
|
|
|
reinterpret_cast<const ColumnString::Chars_t::value_type *>(data.c_str()),
|
|
|
|
|
reinterpret_cast<const ColumnString::Chars_t::value_type *>(data.c_str() + data.size() + 1));
|
2013-05-05 15:25:25 +00:00
|
|
|
|
ColumnString::Offsets_t offsets(1, vdata.size());
|
2013-09-15 05:51:43 +00:00
|
|
|
|
ColumnString::Chars_t res_vdata;
|
2013-05-05 15:25:25 +00:00
|
|
|
|
ColumnString::Offsets_t res_offsets;
|
2013-03-05 12:12:47 +00:00
|
|
|
|
Impl::vector(vdata, offsets, col_needle->getData(), res_vdata, res_offsets);
|
|
|
|
|
|
2013-10-03 19:23:08 +00:00
|
|
|
|
std::string res;
|
|
|
|
|
|
|
|
|
|
if (!res_offsets.empty())
|
|
|
|
|
res.assign(&res_vdata[0], &res_vdata[res_vdata.size() - 1]);
|
2013-02-28 13:01:07 +00:00
|
|
|
|
|
|
|
|
|
ColumnConstString * col_res = new ColumnConstString(col->size(), res);
|
|
|
|
|
block.getByPosition(result).column = col_res;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
throw Exception("Illegal column " + block.getByPosition(arguments[0]).column->getName()
|
|
|
|
|
+ " of argument of function " + getName(),
|
|
|
|
|
ErrorCodes::ILLEGAL_COLUMN);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2011-10-17 08:28:39 +00:00
|
|
|
|
struct NamePosition { static const char * get() { return "position"; } };
|
|
|
|
|
struct NamePositionUTF8 { static const char * get() { return "positionUTF8"; } };
|
|
|
|
|
struct NameMatch { static const char * get() { return "match"; } };
|
|
|
|
|
struct NameLike { static const char * get() { return "like"; } };
|
|
|
|
|
struct NameNotLike { static const char * get() { return "notLike"; } };
|
2013-02-28 13:01:07 +00:00
|
|
|
|
struct NameExtract { static const char * get() { return "extract"; } };
|
2014-01-27 13:49:06 +00:00
|
|
|
|
struct NameReplaceOne { static const char * get() { return "replaceOne"; } };
|
|
|
|
|
struct NameReplaceAll { static const char * get() { return "replaceAll"; } };
|
2011-10-17 08:28:39 +00:00
|
|
|
|
|
|
|
|
|
typedef FunctionsStringSearch<PositionImpl, NamePosition> FunctionPosition;
|
|
|
|
|
typedef FunctionsStringSearch<PositionUTF8Impl, NamePositionUTF8> FunctionPositionUTF8;
|
|
|
|
|
typedef FunctionsStringSearch<MatchImpl<false>, NameMatch> FunctionMatch;
|
2013-09-15 05:51:43 +00:00
|
|
|
|
typedef FunctionsStringSearch<MatchImpl<true>, NameLike> FunctionLike;
|
2011-10-17 08:28:39 +00:00
|
|
|
|
typedef FunctionsStringSearch<MatchImpl<true, true>, NameNotLike> FunctionNotLike;
|
2013-09-15 05:51:43 +00:00
|
|
|
|
typedef FunctionsStringSearchToString<ExtractImpl, NameExtract> FunctionExtract;
|
2014-01-27 13:49:06 +00:00
|
|
|
|
typedef FunctionStringReplace<ReplaceImpl<true>, NameReplaceOne> FunctionReplaceOne;
|
|
|
|
|
typedef FunctionStringReplace<ReplaceImpl<false>, NameReplaceAll> FunctionReplaceAll;
|
2011-10-17 08:28:39 +00:00
|
|
|
|
|
2011-10-16 07:11:36 +00:00
|
|
|
|
}
|