Builds a string by appending pieces in amortized constant time.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| character(len=:), | private, | allocatable | :: | buf |
storage; only |
||
| integer, | private | :: | n | = | 0 |
length of the string so far |
Append str to the string, doubling the storage when it is full.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(string_builder_t), | intent(inout) | :: | self |
the builder |
||
| character(len=*), | intent(in) | :: | str |
the piece to append |
The string built so far.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(string_builder_t), | intent(in) | :: | self |
the builder |
Length of the string built so far.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(string_builder_t), | intent(in) | :: | self |
the builder |
type, public :: string_builder_t !! Builds a string by appending pieces in amortized constant time. private character(len=:), allocatable :: buf !! storage; only `buf(1:n)` is in use integer :: n = 0 !! length of the string so far contains procedure :: append => builder_append procedure :: get => builder_get procedure :: length => builder_length end type string_builder_t