forked from Alepha/Alepha
Started work on some formatting primitives.
Things like markdown and indent fixing in UDLs.
This commit is contained in:
40
Format.dir/format.h
Normal file
40
Format.dir/format.h
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
static_assert( __cplusplus > 2020'99 );
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Alepha/Alepha.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace Alepha::Hydrogen::Format ::detail:: format_m
|
||||||
|
{
|
||||||
|
inline namespace exports
|
||||||
|
{
|
||||||
|
std::string operator ""_format ( const char *p, std::size_t sz );
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::string
|
||||||
|
exports::operator ""_format ( const char *const p, const std::size_t sz )
|
||||||
|
{
|
||||||
|
std::string s{ p, p + s };
|
||||||
|
|
||||||
|
if( s.empty() ) return s;
|
||||||
|
std::size_t indent= 0;
|
||||||
|
if( s.at( 0 ) == '\n' )
|
||||||
|
{
|
||||||
|
s= s.substr( 1 );
|
||||||
|
while( s.at( 0 ) == ' ' )
|
||||||
|
{
|
||||||
|
++indent;
|
||||||
|
s= s.substr( 1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Alepha::Hydrogen::Format::inline exports::inline format_m
|
||||||
|
{
|
||||||
|
using namespace detail::format_m::exports;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user