|
OpenTTD Source 20260218-master-g2123fca5ea
|
Compose data into a growing std::string. More...
#include <string_builder.hpp>
Public Types | |
| using | back_insert_iterator = std::back_insert_iterator<std::string> |
| Iterator for inserting at the back of our buffer. | |
| Public Types inherited from BaseStringBuilder | |
| using | size_type = std::string_view::size_type |
| The type of the size of our strings. | |
Public Member Functions | |
| StringBuilder (std::string &dest) | |
| Construct StringBuilder into destination string. | |
| bool | AnyBytesWritten () const noexcept |
| Check whether any bytes have been written. | |
| size_type | GetBytesWritten () const noexcept |
| Get number of already written bytes. | |
| const std::string & | GetWrittenData () const noexcept |
| Get already written data. | |
| std::string & | GetString () noexcept |
| Get mutable already written data. | |
| void | PutBuffer (std::span< const char > str) override |
| Append buffer. | |
| StringBuilder & | operator+= (std::string_view str) |
| Append string. | |
| back_insert_iterator | back_inserter () |
| Create a back-insert-iterator. | |
| Public Member Functions inherited from BaseStringBuilder | |
| void | Put (std::string_view str) |
| Append string. | |
| void | PutUint8 (uint8_t value) |
| Append binary uint8. | |
| void | PutSint8 (int8_t value) |
| Append binary int8. | |
| void | PutUint16LE (uint16_t value) |
| Append binary uint16 using little endian. | |
| void | PutSint16LE (int16_t value) |
| Append binary int16 using little endian. | |
| void | PutUint32LE (uint32_t value) |
| Append binary uint32 using little endian. | |
| void | PutSint32LE (int32_t value) |
| Append binary int32 using little endian. | |
| void | PutUint64LE (uint64_t value) |
| Append binary uint64 using little endian. | |
| void | PutSint64LE (int64_t value) |
| Append binary int64 using little endian. | |
| void | PutChar (char c) |
| Append 8-bit char. | |
| void | PutUtf8 (char32_t c) |
| Append UTF-8 char. | |
| template<class T> | |
| void | PutIntegerBase (T value, int base) |
| Append integer 'value' in given number 'base'. | |
Private Attributes | |
| std::string * | dest |
| The string to write to. | |
Compose data into a growing std::string.
Definition at line 68 of file string_builder.hpp.
| using StringBuilder::back_insert_iterator = std::back_insert_iterator<std::string> |
Iterator for inserting at the back of our buffer.
Definition at line 113 of file string_builder.hpp.
|
inline |
Construct StringBuilder into destination string.
| dest | The string to write into. |
Definition at line 76 of file string_builder.hpp.
References dest.
Referenced by operator+=().
|
inlinenodiscardnoexcept |
Check whether any bytes have been written.
true iff the buffer isn't empty. Definition at line 82 of file string_builder.hpp.
|
inline |
Create a back-insert-iterator.
Definition at line 118 of file string_builder.hpp.
Referenced by FormatBytes(), and FormatString().
|
inlinenodiscardnoexcept |
Get number of already written bytes.
Definition at line 87 of file string_builder.hpp.
Referenced by MakeEnglishOriginalTownName().
|
inlinenodiscardnoexcept |
Get mutable already written data.
Definition at line 97 of file string_builder.hpp.
References dest.
Referenced by IConsoleAliasExec(), MakeEnglishAdditionalTownName(), MakeEnglishOriginalTownName(), and MakeFinnishTownName().
|
inlinenodiscardnoexcept |
Get already written data.
Definition at line 92 of file string_builder.hpp.
References dest.
|
inline |
Append string.
| str | The string to append. |
Definition at line 106 of file string_builder.hpp.
References BaseStringBuilder::Put(), and StringBuilder().
|
overridevirtual |
Append buffer.
| str | The string to append to the buffer. |
Implements BaseStringBuilder.
Definition at line 133 of file string_builder.cpp.
References dest.
|
private |
The string to write to.
Definition at line 69 of file string_builder.hpp.
Referenced by GetString(), GetWrittenData(), PutBuffer(), and StringBuilder().