20 namespace strings_internal {
23 std::initializer_list<std::pair<absl::string_view, absl::string_view>>;
30 std::vector<strings_internal::ViableSubstitution>* subs_ptr,
31 std::string* result_ptr) {
32 auto& subs = *subs_ptr;
33 int substitutions = 0;
35 while (!subs.empty()) {
36 auto& sub = subs.back();
37 if (sub.offset >= pos) {
38 if (pos <= s.
size()) {
39 StrAppend(result_ptr, s.
substr(pos, sub.offset - pos), sub.replacement);
41 pos = sub.offset + sub.old.size();
44 sub.offset = s.
find(sub.old, pos);
45 if (sub.offset == s.
npos) {
50 size_t index = subs.size();
51 while (--index && subs[index - 1].OccursBefore(subs[index])) {
56 result_ptr->append(s.
data() + pos, s.
size() - pos);
72 return StrReplaceAll<strings_internal::FixedMapping>(s, replacements);
76 std::string* target) {
77 return StrReplaceAll<strings_internal::FixedMapping>(replacements, target);
string_view substr(size_type pos, size_type n=npos) const
void StrAppend(std::string *dest, const AlphaNum &a)
size_type find(string_view s, size_type pos=0) const noexcept
static constexpr size_type npos
constexpr size_type size() const noexcept
void swap(absl::InlinedVector< T, N, A > &a, absl::InlinedVector< T, N, A > &b) noexcept(noexcept(a.swap(b)))
std::initializer_list< std::pair< absl::string_view, absl::string_view >> FixedMapping
constexpr const_pointer data() const noexcept
int ApplySubstitutions(absl::string_view s, std::vector< strings_internal::ViableSubstitution > *subs_ptr, std::string *result_ptr)
std::string StrReplaceAll(absl::string_view s, strings_internal::FixedMapping replacements)