Preliminary support for custom formatting.

This commit is contained in:
Victor Zverovich
2012-12-17 14:56:44 -08:00
parent 059934fd10
commit ade5381f9a
3 changed files with 76 additions and 15 deletions

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(), ' ');
}