Closed joe-barnier closed 8 months ago
Hi @p-ranav, is there anything you're looking for from me to help push this forward? Or should I just be patient? :)
Really appreciate your contribution @joe-barnier :)
Thanks for the bump, I did lose track of this in my notifications. Merged now.
The existing
Table::add_row
member function is limited to accepting only strings and inner tables. In many cases, the data being added to a table is not string data, and forcing applications to always serialize that data before callingadd_row
may be needlessly cumbersome (at least it often feels that way when I am using the library).This PR adds a
RowStream
class that takes advantage ofstd::ostringstream
formatting to streamline application code.RowStream
is implicitly convertible to aTable::Row_t
to minimize disruption to the existing API.RowStream
is expected to provide all the standard formatting behavior ofstd::ostringstream
(e.g..imbue(...)
,.precision(...)
,<< std::setprecision(...)
, etc.). Thus more complex formatting is supported.Another possible option that I considered would be to add another
add_row
overload (or perhaps a differently named member function) that returns a similarRowStream
object that adds the row data when it goes out of scope. This option would allow for the following application code:While it is more concise, I ruled against this option because I think it is more foreign to the existing API. However, if there is interest I would be willing to change the implementation accordingly.
I also considered a variadic template solution, but then formatting options would be significantly limited.
Thank you for your consideration.