/** Copyright: Copyright (c) 2017-2018 Andrey Penechko. License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). Authors: Andrey Penechko. */ module voxelman.text.textsink; struct TextSink { import std.format : formattedWrite; import std..string : stripRight; import voxelman.container.buffer; Buffer!char data; void clear() { data.clear(); } string text() { return stripRight(cast(string)data.data); } void put(in char[] str) { if (str.length == 0) return; data.put(str); data.stealthPut('\0'); } void putf(Args...)(const(char)[] fmt, Args args) { formattedWrite(&this, fmt, args); } void putfln(Args...)(const(char)[] fmt, Args args) { formattedWrite(&this, fmt, args); put("\n"); } void putln(const(char)[] str) { put(str); put("\n"); } }