aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/string_utils
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2023-12-04 15:32:14 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2023-12-05 01:22:50 +0300
commitc21ed9eedf73010bc81342518177dfdfb0d56bd7 (patch)
tree72f8fde4463080cfe5a38eb0babc051cfe32c51e /library/cpp/string_utils
parentec1311bf2e8cc231723b8b5e484ca576663a1309 (diff)
downloadydb-c21ed9eedf73010bc81342518177dfdfb0d56bd7.tar.gz
Intermediate changes
Diffstat (limited to 'library/cpp/string_utils')
-rw-r--r--library/cpp/string_utils/subst_buf/substbuf.cpp1
-rw-r--r--library/cpp/string_utils/subst_buf/substbuf.h63
-rw-r--r--library/cpp/string_utils/subst_buf/ya.make7
3 files changed, 0 insertions, 71 deletions
diff --git a/library/cpp/string_utils/subst_buf/substbuf.cpp b/library/cpp/string_utils/subst_buf/substbuf.cpp
deleted file mode 100644
index f23cb24b19d..00000000000
--- a/library/cpp/string_utils/subst_buf/substbuf.cpp
+++ /dev/null
@@ -1 +0,0 @@
-#include "substbuf.h"
diff --git a/library/cpp/string_utils/subst_buf/substbuf.h b/library/cpp/string_utils/subst_buf/substbuf.h
deleted file mode 100644
index 357ee68ae3b..00000000000
--- a/library/cpp/string_utils/subst_buf/substbuf.h
+++ /dev/null
@@ -1,63 +0,0 @@
-#pragma once
-
-#include <util/generic/vector.h>
-#include <util/generic/strbuf.h>
-#include <util/string/subst.h>
-
-/// Заменяет в строке одни подстроки на другие.
-template <class TBuf, class TPool>
-size_t SubstGlobal(TBuf& s, const TBuf& from, const TBuf& to, TPool& pool) {
- if (from.empty())
- return 0;
-
- TVector<size_t> offs;
- for (size_t off = 0; (off = s.find(from, off)) != TBuf::npos; off += from.length())
- offs.push_back(off);
- if (offs.empty())
- return 0;
-
- size_t dstSize = s.size() + ssize_t(offs.size()) * ssize_t(to.size() - from.size());
- const size_t charTypeSz = sizeof(typename TBuf::char_type);
- typename TBuf::char_type* dst = (typename TBuf::char_type*)pool.Allocate((dstSize + 1) * charTypeSz);
- dst[dstSize] = 0;
-
- typename TBuf::char_type* p = dst;
- size_t lastSrc = 0;
- for (auto off : offs) {
- memcpy(p, s.data() + lastSrc, (off - lastSrc) * charTypeSz);
- p += off - lastSrc;
- lastSrc = off + from.size();
- memcpy(p, to.data(), to.size() * charTypeSz);
- p += to.size();
- }
- memcpy(p, s.data() + lastSrc, (s.size() - lastSrc) * charTypeSz);
- p += s.size() - lastSrc;
- Y_ASSERT(p - dst == (ssize_t)dstSize);
-
- s = TBuf(dst, dstSize);
- return offs.size();
-}
-
-template <class TPool>
-size_t SubstGlobal(TStringBuf& s, const TStringBuf& from, const TStringBuf& to, TPool& pool) {
- return SubstGlobal<TStringBuf, TPool>(s, from, to, pool);
-}
-
-/// Заменяет в строке одни подстроки на другие.
-template <class TBuf, class TPool>
-inline size_t SubstGlobal(TBuf& s, typename TBuf::char_type from, typename TBuf::char_type to, TPool& pool) {
- size_t result = 0;
- size_t off = s.find(from);
- if (off == TBuf::npos)
- return 0;
-
- s = TBuf(pool.Append(s), s.size());
-
- for (typename TBuf::char_type* it = const_cast<typename TBuf::char_type*>(s.begin()) + off; it != s.end(); ++it) {
- if (*it == from) {
- *it = to;
- ++result;
- }
- }
- return result;
-}
diff --git a/library/cpp/string_utils/subst_buf/ya.make b/library/cpp/string_utils/subst_buf/ya.make
deleted file mode 100644
index 8b8793f5b32..00000000000
--- a/library/cpp/string_utils/subst_buf/ya.make
+++ /dev/null
@@ -1,7 +0,0 @@
-LIBRARY()
-
-SRCS(
- substbuf.cpp
-)
-
-END()