forked from Alepha/Alepha
Make the underlying streambuf private in stacks.
This commit is contained in:
14
word_wrap.cc
14
word_wrap.cc
@ -64,28 +64,27 @@ namespace Alepha::Hydrogen ::detail:: word_wrap_m
|
||||
void
|
||||
WordWrapStreambuf::writeChar( const char ch )
|
||||
{
|
||||
std::ostream outWrap{ underlying };
|
||||
if( ch == '\n' )
|
||||
{
|
||||
const auto prev= currentLineLength;
|
||||
const auto size= currentWord.size();
|
||||
currentLineLength= applyWordToLine( maximumWidth, nextLineOffset, currentLineLength, std::move( currentWord ), outWrap );
|
||||
currentLineLength= applyWordToLine( maximumWidth, nextLineOffset, currentLineLength, std::move( currentWord ), out() );
|
||||
currentWord.clear();
|
||||
outWrap << '\n';
|
||||
out() << '\n';
|
||||
if( currentLineLength == prev + size )
|
||||
{
|
||||
std::fill_n( std::ostream_iterator< char >{ outWrap }, nextLineOffset, ' ' );
|
||||
std::fill_n( std::ostream_iterator< char >{ out() }, nextLineOffset, ' ' );
|
||||
currentLineLength= nextLineOffset;
|
||||
}
|
||||
else currentLineLength= 0;
|
||||
}
|
||||
else if( ch == ' ' )
|
||||
{
|
||||
currentLineLength= applyWordToLine( maximumWidth, nextLineOffset, currentLineLength, std::move( currentWord ), outWrap );
|
||||
currentLineLength= applyWordToLine( maximumWidth, nextLineOffset, currentLineLength, std::move( currentWord ), out() );
|
||||
currentWord.clear();
|
||||
if( currentLineLength < maximumWidth )
|
||||
{
|
||||
outWrap << ' ';
|
||||
out() << ' ';
|
||||
++currentLineLength;
|
||||
}
|
||||
}
|
||||
@ -96,8 +95,7 @@ namespace Alepha::Hydrogen ::detail:: word_wrap_m
|
||||
WordWrapStreambuf::drain()
|
||||
{
|
||||
if( currentWord.empty() ) return;
|
||||
std::ostream outWrap{ underlying };
|
||||
applyWordToLine( maximumWidth, nextLineOffset, currentLineLength, std::move( currentWord ), outWrap );
|
||||
applyWordToLine( maximumWidth, nextLineOffset, currentLineLength, std::move( currentWord ), out() );
|
||||
}
|
||||
|
||||
std::string
|
||||
|
Reference in New Issue
Block a user