JsonStreamer#

Fully qualified name: omni::structuredlog::JsonStreamer

Defined in omni/structuredlog/JsonSerializer.h

template<typename OutputIt>
class JsonStreamer : public omni::structuredlog::JsonConsumer#

An implementation of JsonConsumer that just prints to an iterator.

Public Functions

JsonStreamer() = default#

Default constructor.

inline JsonStreamer(OutputIt output)#

Create a streamer from an output iterator.

Parameters:

output[in] The output iterator to write to.

inline void reset(OutputIt output) noexcept#

Reinitialize the printer with a new iterator.

Parameters:

output[in] The output iterator to write to.

inline virtual void consume(
const char *json,
size_t jsonLen,
JsonToken token,
) noexcept override#

Write a string into the buffer.

Parameters:
  • json[in] The data to write into the buffer.

  • jsonLen[in] The length of json, excluding any null terminator.

  • token[in] Unused token type.

inline virtual void consumeRaw(JsonRawValue value) noexcept override#

The function that will consume raw non-string JSON values.

Remark

This will be called if the class returns true from canConsumeRaw().

Parameters:

value[in] The raw value being consumed.

inline virtual void terminate() noexcept override#

Terminate the output, if needed.

Remark

This will be called to ensure the output is null terminated.

inline virtual bool canConsumeRaw() noexcept override#

Determines whether the consumer wants to consume raw values.

Note

If this returns true, string values will no longer be escaped.

Note

Regardless of the return value of this, consume() will still be called and may still be called when JsonToken is eValue.

Returns:

true if the consumer wants to consume raw values, false otherwise.

inline size_t charsWritten() noexcept#

Get the number of characters written.

Returns:

The number of characters written.

inline OutputIt getIterator() noexcept#

Get the iterator.

Note

The returned iterator may be invalidated if this class is used further.

Returns:

The iterator.