[Glacier] Add the ability to remove a character from a StringBuilder.

This commit is contained in:
Drew Galbraith 2023-11-26 13:39:18 -08:00
parent 134185117d
commit c8e5441c7f
3 changed files with 33 additions and 0 deletions

View file

@ -19,6 +19,14 @@ void VariableStringBuilder::PushBack(const StringView& str) {
void VariableStringBuilder::PushBack(const char str) { data_.PushBack(str); }
void VariableStringBuilder::DeleteLast() {
if (data_.size() > 0) {
data_.PopBack();
}
}
void VariableStringBuilder::Reset() { data_ = glcr::Vector<char>(); }
String VariableStringBuilder::ToString() const {
return String(data_.RawPtr(), size());
}
@ -50,4 +58,12 @@ FixedStringBuilder::operator StringView() const {
return StringView(buffer_, size_);
}
void FixedStringBuilder::DeleteLast() {
if (size_ > 0) {
size_--;
}
}
void FixedStringBuilder::Reset() { size_ = 0; }
} // namespace glcr