Function replaceFirstWithEscape

Summary

#include <src/easylogging++.h>

(1) static void replaceFirstWithEscape(base::type::string_t &str, const base::type::string_t &replaceWhat, const base::type::string_t &replaceWith)

(2) static void replaceFirstWithEscape(base::type::string_t &str, const base::type::string_t &replaceWhat, const std::string &replaceWith)

Function overload

Synopsis

#include <src/easylogging++.h>

static void replaceFirstWithEscape(base::type::string_t &str, const base::type::string_t &replaceWhat, const base::type::string_t &replaceWith)

Description

No description yet.

Source

Lines 928-940 in src/easylogging++.cc. Line 1111 in src/easylogging++.h.

void Str::replaceFirstWithEscape(base::type::string_t& str, const base::type::string_t& replaceWhat,
                                 const base::type::string_t& replaceWith) {
  std::size_t foundAt = base::type::string_t::npos;
  while ((foundAt = str.find(replaceWhat, foundAt + 1)) != base::type::string_t::npos) {
    if (foundAt > 0 && str[foundAt - 1] == base::consts::kFormatSpecifierChar) {
      str.erase(foundAt - 1, 1);
      ++foundAt;
    } else {
      str.replace(foundAt, replaceWhat.length(), replaceWith);
      return;
    }
  }
}

Synopsis

#include <src/easylogging++.h>

static void replaceFirstWithEscape(base::type::string_t &str, const base::type::string_t &replaceWhat, const std::string &replaceWith)

Description

No description yet.

Source

Lines 942-945 in src/easylogging++.cc. Line 1114 in src/easylogging++.h.

void Str::replaceFirstWithEscape(base::type::string_t& str, const base::type::string_t& replaceWhat,
                                 const std::string& replaceWith) {
  replaceFirstWithEscape(str, replaceWhat, base::type::string_t(replaceWith.begin(), replaceWith.end()));
}





Add Discussion

Log in to comment