On Wed, 2016-07-20 at 08:00 -0700, Tobias Duckworth wrote: > The proton::value conversions are pretty comprehensive actually, I'm > not sure > I need any more than it already caters for. > > However, since a common use case might be converting to a string > (even if > just for debug purposes), I think a conversion to an empty string by > means > of an additional function that doesn't throw an exception would be > nice to > have.
I just added proton::to_string(value) (also takes scalar or url) that does exactly that. It's just a wrapper for ostream << but it's a handy wrapper - same idea as std::to_string. Also I made an empty scalar or value print as "" instead of "<null>". On reflection that seems more consistent with C++ practice - e.g. an empty std::string prints as "", not "<empty-string>". The strings are mostly intended just to be readable. The string reps for scalar types (or values containing a scalar type) are identical to their normal ostream operator<< so compatible with istream operator>>, but complex types use a python-esque syntax which you should not try to parse or use for anything but debugging. Cheers, Alan. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
