CPP01 1.0
|
A class that handles replacing occurrences of a string within a file. [詳解]
#include <FileReplacer.hpp>
公開メンバ関数 | |
FileReplacer () | |
Default constructor for the FileReplacer class. | |
FileReplacer (const std::string &filename, const std::string &s1, const std::string &s2) | |
Parameterized constructor for the FileReplacer class. | |
FileReplacer (const FileReplacer &other) | |
Copy constructor for the FileReplacer class. | |
FileReplacer & | operator= (const FileReplacer &other) |
Copy assignment operator for the FileReplacer class. | |
~FileReplacer () | |
Destructor for the FileReplacer class. | |
const std::string & | getFileName () const |
Gets the filename. | |
const std::string & | getS1 () const |
Gets the string to find (s1). | |
const std::string & | getS2 () const |
Gets the string to replace with (s2). | |
void | processFile () |
Processes the input file and performs the string replacement. | |
A class that handles replacing occurrences of a string within a file.
FileReplacer.hpp の 29 行目に定義があります。
FileReplacer::FileReplacer | ( | ) |
Default constructor for the FileReplacer class.
Initializes filename, s1, and s2 to empty strings.
FileReplacer.cpp の 26 行目に定義があります。
FileReplacer::FileReplacer | ( | const std::string & | filename, |
const std::string & | s1, | ||
const std::string & | s2 | ||
) |
Parameterized constructor for the FileReplacer class.
Initializes the FileReplacer with the given filename, string to find (s1), and string to replace (s2).
filename | The name of the file to process. |
s1 | The string to find and replace. |
s2 | The string to replace occurrences of s1 with. |
FileReplacer.cpp の 38 行目に定義があります。
FileReplacer::FileReplacer | ( | const FileReplacer & | other | ) |
Copy constructor for the FileReplacer class.
Creates a new FileReplacer object as a copy of another.
other | The FileReplacer object to copy. |
FileReplacer.cpp の 48 行目に定義があります。
FileReplacer::~FileReplacer | ( | ) |
Destructor for the FileReplacer class.
FileReplacer.cpp の 70 行目に定義があります。
const std::string & FileReplacer::getFileName | ( | ) | const |
const std::string & FileReplacer::getS1 | ( | ) | const |
const std::string & FileReplacer::getS2 | ( | ) | const |
Gets the string to replace with (s2).
FileReplacer.cpp の 91 行目に定義があります。
FileReplacer & FileReplacer::operator= | ( | const FileReplacer & | other | ) |
Copy assignment operator for the FileReplacer class.
Assigns the state of one FileReplacer object to another.
other | The FileReplacer object to assign from. |
FileReplacer.cpp の 58 行目に定義があります。
void FileReplacer::processFile | ( | ) |
Processes the input file and performs the string replacement.
Processes the input file, replacing occurrences of s1 with s2, and writes the result to a new file with the ".replace" extension.
Throws std::runtime_error if the input or output file cannot be opened, or if s1 is empty.
FileReplacer.cpp の 100 行目に定義があります。