1
0
forked from Alepha/Alepha

Use the stacked streambuf to implement wrapping.

This commit is contained in:
2023-10-17 17:27:57 -04:00
parent 87634c4549
commit 92d6b3840d
2 changed files with 18 additions and 52 deletions

View File

@ -7,27 +7,30 @@ static_assert( __cplusplus > 2020'00 );
#include <string>
#include <streambuf>
#include <Alepha/Utility/StackableStreambuf.h>
namespace Alepha::inline Cavorite ::detail:: word_wrap
{
inline namespace exports
{
std::string wordWrap( const std::string &text, std::size_t width, std::size_t nextLineOffset= 0 );
struct StartWrap
struct StartWrap_params
{
std::size_t width;
std::size_t nextLineOffset;
explicit StartWrap( const std::size_t width, const std::size_t nextLineOffset= 0 ) : width( width ), nextLineOffset( nextLineOffset ) {}
explicit StartWrap_params( const std::size_t width, const std::size_t nextLineOffset= 0 ) : width( width ), nextLineOffset( nextLineOffset ) {}
};
constexpr struct EndWrap_t {} EndWrap;
using StartWrap= Utility::PushStack< StartWrap_params >;
constexpr Utility::PopStack< StartWrap_params > EndWrap;
}
inline namespace impl
{
std::ostream &operator << ( std::ostream &, StartWrap );
std::ostream &operator << ( std::ostream &, EndWrap_t );
void build_streambuf( std::ostream &os, StartWrap &&args );
}
}