The C++ framework for developing highly scalable, high performance servers on Windows platforms.

StreamWriterBuilder Class Reference

Inheritance diagram for StreamWriterBuilder:
Collaboration diagram for StreamWriterBuilder:

List of all members.


Detailed Description

Build a StreamWriter implementation.

Usage:

  using namespace Json;
  Value value = ...;
  StreamWriterBuilder builder;
  builder.settings_["commentStyle"] = "None";
  builder.settings_["indentation"] = "   ";  // or whatever you like
  std::unique_ptr<Json::StreamWriter> writer(
      builder.newStreamWriter());
  writer->write(value, &std::cout);
  std::cout << std::endl;  // add lf and flush

Public Member Functions

 StreamWriterBuilder ()
virtual ~StreamWriterBuilder ()
virtual StreamWriternewStreamWriter () const
 
Exceptions:
std::exception if something goes wrong (e.g.

bool validate (Json::Value *invalid) const
 
Returns:
true if 'settings' are legal and consistent; otherwise, indicate bad settings via 'invalid'.

 StreamWriterBuilder ()
virtual ~StreamWriterBuilder ()
virtual StreamWriternewStreamWriter () const
 
Exceptions:
std::exception if something goes wrong (e.g.

bool validate (Json::Value *invalid) const
 
Returns:
true if 'settings' are legal and consistent; otherwise, indicate bad settings via 'invalid'.


Static Public Member Functions

static void setDefaults (Json::Value *settings)
 Called by ctor, but you can use this to reset settings_.
static void setDefaults (Json::Value *settings)
 Called by ctor, but you can use this to reset settings_.

Public Attributes

Json::Value settings_
 Configuration of this builder.

Constructor & Destructor Documentation

~StreamWriterBuilder (  )  [virtual]

virtual ~StreamWriterBuilder (  )  [virtual]


Member Function Documentation

StreamWriter * newStreamWriter (  )  const [virtual]

Exceptions:
std::exception if something goes wrong (e.g.

invalid settings)

Implements StreamWriter::Factory.

bool validate ( Json::Value invalid  )  const

Returns:
true if 'settings' are legal and consistent; otherwise, indicate bad settings via 'invalid'.

void setDefaults ( Json::Value settings  )  [static]

Called by ctor, but you can use this to reset settings_.

Precondition:
'settings' != NULL (but Json::null is fine)
Remarks:
Defaults: src/lib_json/json_writer.cpp StreamWriterBuilderDefaults

[StreamWriterBuilderDefaults]

[StreamWriterBuilderDefaults]

virtual StreamWriter* newStreamWriter (  )  const [virtual]

Exceptions:
std::exception if something goes wrong (e.g.

invalid settings)

Implements StreamWriter::Factory.

bool validate ( Json::Value invalid  )  const

Returns:
true if 'settings' are legal and consistent; otherwise, indicate bad settings via 'invalid'.

static void setDefaults ( Json::Value settings  )  [static]

Called by ctor, but you can use this to reset settings_.

Precondition:
'settings' != NULL (but Json::null is fine)
Remarks:
Defaults: src/lib_json/json_writer.cpp StreamWriterBuilderDefaults


Member Data Documentation

Configuration of this builder.

Available settings (case-sensitive):

  • "commentStyle": "None" or "All"
  • "indentation": "<anything>"
  • "enableYAMLCompatibility": false or true
    • slightly change the whitespace around colons
  • "dropNullPlaceholders": false or true
    • Drop the "null" string from the writer's output for nullValues. Strictly speaking, this is not valid JSON. But when the output is being fed to a browser's Javascript, it makes for smaller output and the browser can handle the output just fine.

You can examine 'settings_` yourself to see the defaults. You can also write and read them just like any JSON Value.

See also:
setDefaults()


Generated on Sun Sep 12 19:12:00 2021 for The Server Framework - v7.4 by doxygen 1.5.3