diff options
| author | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-12-30 19:10:58 +0000 | 
|---|---|---|
| committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-12-30 19:10:58 +0000 | 
| commit | cc3bc93388925c8de112a6e8cfc412219c16cf37 (patch) | |
| tree | 7b348e5a0a2d1e7eb329b6c319b5beff517a3207 | |
| parent | Remove clang options not supported on build server (diff) | |
| download | libadhocutil-cc3bc93388925c8de112a6e8cfc412219c16cf37.tar.bz2 libadhocutil-cc3bc93388925c8de112a6e8cfc412219c16cf37.tar.xz libadhocutil-cc3bc93388925c8de112a6e8cfc412219c16cf37.zip  | |
Add macros to ease declartion of formatters
| -rw-r--r-- | libadhocutil/compileTimeFormatter.h | 6 | ||||
| -rw-r--r-- | libadhocutil/unittests/testCompileTimeFormatter.cpp | 7 | 
2 files changed, 13 insertions, 0 deletions
diff --git a/libadhocutil/compileTimeFormatter.h b/libadhocutil/compileTimeFormatter.h index 631b0f7..7734f9c 100644 --- a/libadhocutil/compileTimeFormatter.h +++ b/libadhocutil/compileTimeFormatter.h @@ -213,3 +213,9 @@ namespace AdHoc {  	};  } +#define AdHocFormatterTypedef(name, str, id) \ +	extern constexpr auto id = str; \ +	typedef ::AdHoc::Formatter<id> name +#define AdHocFormatter(name, str) \ +	AdHocFormatterTypedef(name, str, name ## __COUNTER__) + diff --git a/libadhocutil/unittests/testCompileTimeFormatter.cpp b/libadhocutil/unittests/testCompileTimeFormatter.cpp index df0d93c..030dbc9 100644 --- a/libadhocutil/unittests/testCompileTimeFormatter.cpp +++ b/libadhocutil/unittests/testCompileTimeFormatter.cpp @@ -196,6 +196,13 @@ BOOST_AUTO_TEST_CASE ( typedefFormat )  	BOOST_REQUIRE_EQUAL(this->str(), "custom -( expr )-");  } +AdHocFormatter(TypedefWrapper, "Typedef wrapper %?."); +BOOST_AUTO_TEST_CASE ( typedefWrapper ) +{ +	TypedefWrapper::write(*this, "expr"); +	BOOST_REQUIRE_EQUAL(this->str(), "Typedef wrapper expr."); +} +  BOOST_AUTO_TEST_CASE ( longFormatString )  {  	Formatter<formatStringLong>::write(*this);  | 
