-
Notifications
You must be signed in to change notification settings - Fork 11
Input Output Streaming
Morestachio is build around the idea of streaming its input and output parameters. There is a balance to be held between having enough information in memory to construct the renderer and consuming the least amount of memory.
In its current form, the morestachio tokenizer constructs its tokens by using a ITemplateContainer
. The default implementation is the StringTemplateContainer
extending the TemplateContainerBase
where an base tokenizer is implemented. The base tokenizer does copy its information from the input into memory while reading the stream provided. This implementation is a read-only-forward strategy so that the underlying stream does not need to keep any read data but it does need to know the length in advance.
For Output the streaming idea is completely implemented. By using the IByteCounterStream
morestachio does write into an abstracted stream on byte level. The output is also completely write-forward only and supports .net2.1 ReadOnlySpan<byte>
. There are multiple implementations for this stream, according to your specific use-case:
-
ByteCounterStream
uses anSystem.IO.Stream
-
ByteCounterStringBuilder
uses anSystem.Text.StringBuilder
. Best for pure in-memory generation -
ByteCounterTextWriter
uses anSystem.IO.TextWriter
-
NullStream
does not write anything