Renamed IndentedPrintDecorator into IndentedPrint

This commit is contained in:
Benoit Blanchon
2014-08-26 09:56:05 +02:00
parent b5002265cf
commit 23e61cc0f7
9 changed files with 19 additions and 19 deletions

View File

@ -0,0 +1,37 @@
#include "IndentedPrint.h"
void IndentedPrint::indent()
{
if (level<127)
level++;
}
void IndentedPrint::unindent()
{
if (level>0)
level--;
}
size_t IndentedPrint::write(uint8_t c)
{
size_t n = 0;
if (isNewLine)
n += writeTabs();
n += sink.write(c);
isNewLine = c == '\n';
return n;
}
size_t IndentedPrint::writeTabs()
{
size_t n = 0;
for (int i = 0; i<level; i++)
n += sink.write(' ');
return n;
}