2026-08-11 17:40:36 +03:00
|
|
|
#include "constructors.hpp"
|
|
|
|
|
|
|
|
|
|
namespace oop {
|
|
|
|
|
|
|
|
|
|
|
2026-08-15 20:56:31 +03:00
|
|
|
StringBuilder::StringBuilder(const std::string &initial)
|
|
|
|
|
: buffer_(initial.begin(), initial.end()) {}
|
|
|
|
|
|
|
|
|
|
StringBuilder::StringBuilder(const StringBuilder& other)
|
|
|
|
|
: buffer_(other.buffer_) {}
|
2026-08-11 17:40:36 +03:00
|
|
|
|
|
|
|
|
auto StringBuilder::operator=(const StringBuilder& other) -> StringBuilder& {
|
|
|
|
|
if (this != &other) {
|
|
|
|
|
buffer_ = other.buffer_;
|
|
|
|
|
}
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StringBuilder::append(const std::string& text) {
|
2026-08-15 20:56:31 +03:00
|
|
|
std::ranges::copy(text, std::back_inserter(this->buffer_));
|
2026-08-11 17:40:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|