39 : filename(filename), s1(s1), s2(s2) {}
60 filename = other.filename;
109 std::string outputFilepath = filename +
".replace";
120 while (pos < line.
length()) {
121 size_t foundPos = line.
find(s1, pos);
123 resultLine += line.
substr(pos);
126 resultLine += line.
substr(pos, foundPos - pos);
128 pos = foundPos + s1.
length();
Declares the FileReplacer class for replacing strings in a file.
basic_ostream< _CharT, _Traits > & endl(basic_ostream< _CharT, _Traits > &__os)
constexpr auto empty(const _Container &__cont) noexcept(noexcept(__cont.empty())) -> decltype(__cont.empty())
basic_istream< _CharT, _Traits > & getline(basic_istream< _CharT, _Traits > &&__is, basic_string< _CharT, _Traits, _Alloc > &__str)
basic_string substr(size_type __pos=0, size_type __n=npos) const
size_type length() const noexcept
const _CharT * c_str() const noexcept
static const size_type npos
size_type find(_CharT __c, size_type __pos=0) const noexcept
A class that handles replacing occurrences of a string within a file.
FileReplacer()
Default constructor for the FileReplacer class.
void processFile()
Processes the input file and performs the string replacement.
FileReplacer & operator=(const FileReplacer &other)
Copy assignment operator for the FileReplacer class.
const std::string & getS1() const
Gets the string to find (s1).
~FileReplacer()
Destructor for the FileReplacer class.
const std::string & getFileName() const
Gets the filename.
const std::string & getS2() const
Gets the string to replace with (s2).