From 4cec1a72993b9c4cc571c4277ec90c52ef4aa541 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Thu, 4 Apr 2024 18:18:11 -0400 Subject: [PATCH] Started work on some formatting primitives. Things like markdown and indent fixing in UDLs. --- Format.dir/format.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Format.dir/format.h diff --git a/Format.dir/format.h b/Format.dir/format.h new file mode 100644 index 0000000..678d03f --- /dev/null +++ b/Format.dir/format.h @@ -0,0 +1,40 @@ +static_assert( __cplusplus > 2020'99 ); + +#pragma once + +#include + +#include + +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; +}