30 lines
733 B
C++
30 lines
733 B
C++
#include "constructors.hpp"
|
|
|
|
namespace oop {
|
|
|
|
|
|
StringBuilder::StringBuilder(const std::string &initial)
|
|
: buffer_(initial.begin(), initial.end()) {}
|
|
|
|
StringBuilder::StringBuilder(const StringBuilder& other)
|
|
: buffer_(other.buffer_) {}
|
|
|
|
auto StringBuilder::operator=(const StringBuilder& other) -> StringBuilder& {
|
|
if (this != &other) {
|
|
buffer_ = other.buffer_;
|
|
}
|
|
return *this;
|
|
}
|
|
|
|
void StringBuilder::append(const std::string& text) {
|
|
std::ranges::copy(text, std::back_inserter(this->buffer_));
|
|
}
|
|
|
|
auto StringBuilder::str() const -> std::string {
|
|
return std::string(buffer_.begin(), buffer_.end());
|
|
}
|
|
|
|
auto StringBuilder::size() const -> std::size_t { return buffer_.size(); }
|
|
|
|
} // namespace oop
|