Phosphor
phosphor::tools::JSONExport Class Reference

#include <export.h>

Public Member Functions

 JSONExport (const TraceContext &_context)
 
size_t read (char *out, size_t length)
 
StringPtr read (size_t length)
 
StringPtr read ()
 
bool done ()
 

Protected Types

enum  State {
  opening, first_event, other_events, first_thread,
  other_threads, footer, dead
}
 

Protected Attributes

const TraceContextcontext
 
TraceBuffer::event_iterator it
 
std::unordered_map< uint64_t, std::string >::const_iterator tit
 
State state = State::opening
 
std::string cache
 

Detailed Description

The JSONExport class is a tool provided to allow exporting a TraceBuffer in the Chromium Tracing JSON format in a chunked manner (e.g. for over the network).

Usage:

auto buffer = phosphor::TraceLog::instance().getBuffer();
JSONExport exporter(*buffer);

do {
    p = exporter.read(80);
    std::cerr << p;
}  while(p.size());

The above will write the JSON to stderr.

Constructor & Destructor Documentation

phosphor::tools::JSONExport::JSONExport ( const TraceContext _context)

Creates the export object

Member Function Documentation

bool phosphor::tools::JSONExport::done ( )
Returns
True if the export is complete
size_t phosphor::tools::JSONExport::read ( char *  out,
size_t  length 
)

Read 'length' worth of JSON

Parameters
outroughly 'length' bytes of the JSON starting from the point that was previously left off. This will return less than 'length' at the end of the buffer.
lengthMax size in bytes of the JSON to put into out
Returns
Number of bytes written to out
StringPtr phosphor::tools::JSONExport::read ( size_t  length)

Read 'length' worth of JSON

Returns
roughly 'length' bytes of the JSON starting from the point that was previously left off. This will return less than 'length' at the end of the buffer.
StringPtr phosphor::tools::JSONExport::read ( )

Read entire buffer's worth of JSON

Returns
The entire buffer converted to JSON

The documentation for this class was generated from the following files: