make `folly::Formatter` extendible
authorTyler MacDonald <crackerjack@fb.com>
Wed, 9 Jul 2014 00:27:36 +0000 (17:27 -0700)
committerTudor Bosman <tudorb@fb.com>
Wed, 9 Jul 2014 20:52:13 +0000 (13:52 -0700)
commit664e121a978ce90afb6fddeaec6ad9d76c84cdd7
treea722b8b44fa918ecfbc1c6125219e70b8e8ad330
parenteaed555139d0186bab0fd71a50434b5041a23a66
make `folly::Formatter` extendible

Summary:
on advice of @tudorb, move most of `folly::Formatter` into `folly::BaseFormatter` so that we can use compile-time polymorphism to provide different types of Formatters.

I wasn't able to get the recursive formatter to be polymorphic -- whenever I tried to convert `class FormatValue<Formatter<containerMode, Args...>, void>` into `class FormatValue<BaseFormatter...`, `FormatTest.cpp:Test(Format, Nested)` wouldn't compile because it couldn't find the template. @tudorb, if you have an easy fix for this, lmk, otherwise I'm (reluctantly) okay with requiring that `Formatter`s define their own nesting `FormatValue`.

phew. the last time I did this sort of metaprogramming was over 5 years ago in perl. Doing it in C++ is... interesting.

Test Plan: `fbconfig -r thrift folly cold_storage && fbmake dbg && fbmake runtests`

Reviewed By: tudorb@fb.com

Subscribers: tudorb, dgp

FB internal diff: D1422343

Tasks: 4624268
folly/Format-inl.h
folly/Format.h
folly/test/FormatTest.cpp