a text buffer. text is appended with the add methods, and the
result is buf%s(1:buf%n). the storage is on the heap, and grows
(doubles) as needed.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| character(len=:), | public, | allocatable | :: | s |
the storage |
||
| integer, | public | :: | n | = | 0 |
number of characters used |
make room for this many more characters
Make sure the buffer has room for nchars more characters.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(text_buffer), | intent(inout) | :: | me | |||
| integer, | intent(in) | :: | nchars |
empty it (keeping the storage)
Empty the buffer (the storage is kept, to be reused).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(text_buffer), | intent(inout) | :: | me |
append a string
Append a string.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(text_buffer), | intent(inout) | :: | me | |||
| character(len=*), | intent(in) | :: | str |
append an integer
Append an integer.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(text_buffer), | intent(inout) | :: | me | |||
| integer, | intent(in) | :: | i |
append a real number (JSON syntax)
Append a real number, in JSON syntax, in double precision (also when wp is
quad precision: the trajectory files are for plotting and SPK files, which are
double precision), with 17 significant digits
(e.g., 8.2031911203980994E+8; trailing zeros are removed, e.g. 1.5E+0).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(text_buffer), | intent(inout) | :: | me | |||
| real(kind=wp), | intent(in) | :: | x |
the number (converted to double precision, if |
append a JSON array of real numbers
Append a JSON array of real numbers ([x1, x2, ...]).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(text_buffer), | intent(inout) | :: | me | |||
| real(kind=wp), | intent(in), | dimension(:) | :: | x |
append real numbers separated by commas (no brackets)
Append a list of real numbers, separated by commas (x1, x2, ...: the
contents of a JSON array, for writing a large array in pieces).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(text_buffer), | intent(inout) | :: | me | |||
| real(kind=wp), | intent(in), | dimension(:) | :: | x |
type,public :: text_buffer !! a text buffer. text is appended with the `add` methods, and the !! result is `buf%s(1:buf%n)`. the storage is on the heap, and grows !! (doubles) as needed. character(len=:),allocatable :: s !! the storage integer :: n = 0 !! number of characters used contains procedure,public :: reserve !! make room for this many more characters procedure,public :: clear !! empty it (keeping the storage) procedure,public :: add_str !! append a string procedure,public :: add_int !! append an integer procedure,public :: add_real !! append a real number (JSON syntax) procedure,public :: add_real_array !! append a JSON array of real numbers procedure,public :: add_real_list !! append real numbers separated by commas (no brackets) end type text_buffer