1
0
forked from Alepha/Alepha
Files
Alepha/delimited_list.h

52 lines
1.1 KiB
C++

static_assert( __cplusplus > 2020'99 );
#pragma once
#include <Alepha/Alepha.h>
#include <ostream>
#include <Alepha/IOStreams/StackableStreambuf.h>
namespace Alepha::Hydrogen ::detail:: delimited_list_m
{
inline namespace exports {}
using DelimiterWriter= std::function< void ( std::ostream & ) >;
struct DelimitedList_params
{
DelimiterWriter writer;
explicit
DelimitedList_params( const std::string delimiter )
: writer( [delimiter] ( std::ostream &os ) { os << delimiter; } )
{}
explicit
DelimitedList_params( DelimiterWriter writer )
: writer( writer )
{}
};
struct MarkItem_t {};
namespace exports
{
constexpr MarkItem_t NextItem;;
using StartDelimitedList= IOStreams::PushStack< DelimitedList_params >;
constexpr IOStreams::PopStack EndDelimitedList;
}
inline namespace impl
{
void build_streambuf( std::ostream &, StartDelimitedList && );
std::ostream &operator << ( std::ostream &os, MarkItem_t );
}
}
namespace Alepha::Hydrogen::inline exports::inline delimited_list_m
{
using namespace detail::delimited_list_m::exports;
}