Change raw memory JSON representation

Fix bug reported by b1rdG
The new way permits to add more formats in the future without breaking
  retro-compatibility again.
Add support for RsJson in rsdebug for Android
This commit is contained in:
Gioacchino Mazzurco 2020-05-28 23:01:04 +02:00
parent 968f234bfd
commit c1c303218c
No known key found for this signature in database
GPG key ID: A1FBCA3872E87051
4 changed files with 63 additions and 53 deletions

View file

@ -32,6 +32,8 @@ std::ostream &operator<<(std::ostream& out, const std::error_condition& err);
# include <sstream>
# include <string>
# include "util/rsjson.h"
enum class RsLoggerCategories
{
DEBUG = ANDROID_LOG_DEBUG,
@ -55,6 +57,10 @@ struct t_RsLogger
inline stream_type& operator<<(const T& val)
{ ostr << val; return *this; }
template<typename T>
inline stream_type& operator<<(const RsJson& val)
{ ostr << val; return *this; }
/// needed for manipulators and things like std::endl
stream_type& operator<<(std::ostream& (*pf)(std::ostream&))
{
@ -111,7 +117,7 @@ struct t_RsLogger
const auto now = system_clock::now();
const auto sec = time_point_cast<seconds>(now);
const auto msec = duration_cast<milliseconds>(now - sec);
std::stringstream tstream;
std::ostringstream tstream;
tstream << static_cast<char>(CATEGORY) << " "
<< sec.time_since_epoch().count() << "."
<< std::setfill('0') << std::setw(3) << msec.count()

View file

@ -29,7 +29,7 @@
typedef rapidjson::Document RsJson;
/**
* Print out RsJson to a stream, use std::stringstream to get the string
* Print out RsJson to a stream, use std::ostringstream to get the string
* @param[out] out output stream
* @param[in] jDoc JSON document to print
* @return same output stream passed as out parameter