https://github.com/burner/stringbuffer
A stack based string buffer that grows into the heap if needed.
https://github.com/burner/stringbuffer
dlang stack string stringbuffer
Last synced: 2 months ago
JSON representation
A stack based string buffer that grows into the heap if needed.
- Host: GitHub
- URL: https://github.com/burner/stringbuffer
- Owner: burner
- License: lgpl-3.0
- Created: 2017-02-23T23:17:14.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-05-19T13:08:17.000Z (over 8 years ago)
- Last Synced: 2025-01-23T18:51:20.683Z (11 months ago)
- Topics: dlang, stack, string, stringbuffer
- Language: D
- Size: 8.79 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
StringBuffer
============

A simple stack based StringBuffer that overflows into the heap and releases
all used memory on destruction.
By default the StringBuffer can store 512 chars on the stack.
If a different number of chars on the stack is required create an
```d
alias MyStringBuffer = StringBufferImpl!1337;
```
like this.
The two important methods of the StringBuffer are writer and getData.
The method writer returns a OutputRange that can be used with formattedWrite
from std.format;
The method getData returns a string of the stored data.
No reference to the returned data from writer and getData must be used after
the associated StringBuffer is destructed.
Example
-------
```d
unittest {
import std.format : formattedWrite;
StringBuffer buf;
auto w = buf.writer();
formattedWrite(w, "foobar %d", 10);
assert(buf.getData() == "foobar 10");
}
```