OpenTTD Source: InPlaceBuilder Class Reference

OpenTTD Source 15.3

Data Structures | Public Member Functions | Private Member Functions | Private Attributes | Friends
InPlaceBuilder Class Referencefinal

Builder implementation for InPlaceReplacement. More...

`#include <string_inplace.hpp>`

Inheritance diagram for InPlaceBuilder:

## Data Structures
class | back_insert_iterator
| Implementation of std::back_insert_iterator for non-growing destination buffer. More...

## Public Member Functions
| InPlaceBuilder (const InPlaceBuilder &)=delete
InPlaceBuilder & | operator= (const InPlaceBuilder &)=delete
bool | AnyBytesWritten () const noexcept
| Check whether any bytes have been written.
size_type | GetBytesWritten () const noexcept
| Get number of already written bytes.
std::string_view | GetWrittenData () const noexcept
| Get already written data.
bool | AnyBytesUnused () const noexcept
| Check whether any unused bytes are left between the Builder and Consumer position.
size_type | GetBytesUnused () const noexcept
| Get number of unused bytes left between the Builder and Consumer position.
void | PutBuffer (std::span< const char > str) override
| Append buffer.
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 Member Functions
| InPlaceBuilder (std::span< char > dest, const StringConsumer &consumer)
| InPlaceBuilder (const InPlaceBuilder &src, const StringConsumer &consumer)
void | AssignBuffer (const InPlaceBuilder &src)

## Private Attributes
std::span< char > | dest
size_type | position = 0
const StringConsumer & | consumer

## Friends
class | InPlaceReplacement

## Additional Inherited Members
Public Types inherited from BaseStringBuilder
using | size_type = std::string_view::size_type

## Detailed Description

Builder implementation for InPlaceReplacement.

Definition at line 21 of file string_inplace.hpp.

## Constructor & Destructor Documentation

## ◆ InPlaceBuilder() [1/2]

InPlaceBuilder::InPlaceBuilder | ( | std::span< char > | dest,
|  | const StringConsumer & | consumer
| ) |  |
| inlineexplicitprivate

Definition at line 27 of file string_inplace.hpp.

## ◆ InPlaceBuilder() [2/2]

InPlaceBuilder::InPlaceBuilder | ( | const InPlaceBuilder & | src,
|  | const StringConsumer & | consumer
| ) |  |
| inlineprivate

Definition at line 28 of file string_inplace.hpp.

## Member Function Documentation

## ◆ AnyBytesUnused()

bool InPlaceBuilder::AnyBytesUnused | ( |  | ) | const
| noexcept

Check whether any unused bytes are left between the Builder and Consumer position.

Definition at line 19 of file string_inplace.cpp.

Referenced by StrMakeValidInPlace().

## ◆ AnyBytesWritten()

bool InPlaceBuilder::AnyBytesWritten | ( |  | ) | const
| inlinenoexcept

Check whether any bytes have been written.

Definition at line 37 of file string_inplace.hpp.

## ◆ AssignBuffer()

void InPlaceBuilder::AssignBuffer | ( | const InPlaceBuilder & | src | ) |
| inlineprivate

Definition at line 29 of file string_inplace.hpp.

## ◆ back_inserter()

back_insert_iterator InPlaceBuilder::back_inserter | ( |  | ) |
| inline

Create a back-insert-iterator.

Definition at line 79 of file string_inplace.hpp.

## ◆ GetBytesUnused()

InPlaceBuilder::size_type InPlaceBuilder::GetBytesUnused | ( |  | ) | const
| noexcept

Get number of unused bytes left between the Builder and Consumer position.

Definition at line 27 of file string_inplace.cpp.

Referenced by PutBuffer().

## ◆ GetBytesWritten()

size_type InPlaceBuilder::GetBytesWritten | ( |  | ) | const
| inlinenoexcept

Get number of already written bytes.

Definition at line 41 of file string_inplace.hpp.

Referenced by StrMakeValidInPlace().

## ◆ GetWrittenData()

std::string_view InPlaceBuilder::GetWrittenData | ( |  | ) | const
| inlinenoexcept

Get already written data.

Definition at line 45 of file string_inplace.hpp.

## ◆ PutBuffer()

void InPlaceBuilder::PutBuffer | ( | std::span< const char > | str | ) |
| overridevirtual

Append buffer.

Implements BaseStringBuilder.

Definition at line 35 of file string_inplace.cpp.

References GetBytesUnused().

## Friends And Related Symbol Documentation

## ◆ InPlaceReplacement

friend class InPlaceReplacement
| friend

Definition at line 26 of file string_inplace.hpp.

## Field Documentation

## ◆ consumer

const StringConsumer& InPlaceBuilder::consumer
| private

Definition at line 24 of file string_inplace.hpp.

## ◆ dest

std::span<char> InPlaceBuilder::dest
| private

Definition at line 22 of file string_inplace.hpp.

## ◆ position

size_type InPlaceBuilder::position = 0
| private

Definition at line 23 of file string_inplace.hpp.

The documentation for this class was generated from the following files:

- src/core/string_inplace.hpp
- src/core/string_inplace.cpp