Preliminary support for custom formatting.

This commit is contained in:
Victor Zverovich committed 2012-12-17 14:56:44 -08:00
1 parent 059934fd10
commit ade5381f9a
3 files changed
+76 -15

No files matched your search

+7
View File
@@ -433,3 +433,10 @@ void Formatter::DoFormat() {
buffer_.append(start, s + 1);
buffer_.resize(buffer_.size() - 1); // Don't count the terminating zero.
}
void Formatter::Write(const std::string &s, unsigned width) {
char *out = GrowBuffer(std::max<std::size_t>(width, s.size()));
std::copy(s.begin(), s.end(), out);
if (width > s.size())
std::fill_n(out + s.size(), width - s.size(), ' ');
}