cpp-hocon  0.3.0
Public Member Functions | Static Public Member Functions | List of all members
hocon::config_render_options Class Reference

Public Member Functions

 config_render_options (bool origin_comments=true, bool comments=true, bool formatted=true, bool json=true)
 Leaving the default arguments will result in a verbose rendering, which contains comments and therefore is not valid JSON. More...
 
config_render_options set_comments (bool value)
 Returns options with comments toggled. More...
 
bool get_comments () const
 Returns whether the options enable comments. More...
 
config_render_options set_origin_comments (bool value)
 Returns options with origin comments toggled. More...
 
bool get_origin_comments () const
 Returns whether the options enable automated origin comments. More...
 
config_render_options set_formatted (bool value)
 Returns options with formatting toggled. More...
 
bool get_formatted () const
 Returns whether the options enable formatting. More...
 
config_render_options set_json (bool value)
 Returns options with JSON toggled. More...
 
bool get_json () const
 Returns whether the options enable JSON. More...
 

Static Public Member Functions

static config_render_options concise ()
 Returns concise render options (no whitespace or comments). More...
 

Detailed Description

A set of options related to rendering a config_value. Passed to config_value#render(config_render_options).

Here is an example of creating a

:

    config_render_options options =
        config_render_options().set_comments(false)

Definition at line 20 of file config_render_options.hpp.

Constructor & Destructor Documentation

◆ config_render_options()

hocon::config_render_options::config_render_options ( bool  origin_comments = true,
bool  comments = true,
bool  formatted = true,
bool  json = true 
)

Leaving the default arguments will result in a verbose rendering, which contains comments and therefore is not valid JSON.

See config_render_options#concise for stripped-down options.

Member Function Documentation

◆ concise()

static config_render_options hocon::config_render_options::concise ( )
static

Returns concise render options (no whitespace or comments).

For a resolved config, the concise rendering will be valid JSON.

Returns
the concise render options

◆ get_comments()

bool hocon::config_render_options::get_comments ( ) const

Returns whether the options enable comments.

This method is mostly used by the config lib internally, not by applications.

Returns
true if comments should be rendered

◆ get_formatted()

bool hocon::config_render_options::get_formatted ( ) const

Returns whether the options enable formatting.

This method is mostly used by the config lib internally, not by applications.

Returns
true if the options enable formatting

◆ get_json()

bool hocon::config_render_options::get_json ( ) const

Returns whether the options enable JSON.

This method is mostly used by the config lib internally, not by applications.

Returns
true if only JSON should be rendered

◆ get_origin_comments()

bool hocon::config_render_options::get_origin_comments ( ) const

Returns whether the options enable automated origin comments.

This method is mostly used by the config lib internally, not by applications.

Returns
true if origin comments should be rendered

◆ set_comments()

config_render_options hocon::config_render_options::set_comments ( bool  value)

Returns options with comments toggled.

This controls human-written comments but not the autogenerated "origin of this setting" comments, which are controlled by config_render_options#set_origin_comments.

Parameters
valuetrue to include comments in the render
Returns
options with requested setting for comments

◆ set_formatted()

config_render_options hocon::config_render_options::set_formatted ( bool  value)

Returns options with formatting toggled.

Formatting means indentation and whitespace, enabling formatting makes things prettier but larger.

Parameters
valuetrue to enable formatting
Returns
options with requested setting for formatting

◆ set_json()

config_render_options hocon::config_render_options::set_json ( bool  value)

Returns options with JSON toggled.

JSON means that HOCON extensions (omitting commas, quotes for example) won't be used. However, whether to use comments is controlled by the separate set_comments(boolean) and set_origin_comments(boolean) options. So if you enable comments you will get invalid JSON despite setting this to true.

Parameters
valuetrue to include non-JSON extensions in the render
Returns
options with requested setting for JSON

◆ set_origin_comments()

config_render_options hocon::config_render_options::set_origin_comments ( bool  value)

Returns options with origin comments toggled.

If this is enabled, the library generates comments for each setting based on the config_value#origin of that setting's value. For example these comments might tell you which file a setting comes from.

controls only these autogenerated "origin of this setting" comments, to toggle regular comments use config_render_options#set_comments.

Parameters
valuetrue to include autogenerated setting-origin comments in the render
Returns
options with origin comments toggled

The documentation for this class was generated from the following file:
hocon::config_render_options::config_render_options
config_render_options(bool origin_comments=true, bool comments=true, bool formatted=true, bool json=true)
Leaving the default arguments will result in a verbose rendering, which contains comments and therefo...
hocon::config_render_options::set_origin_comments
config_render_options set_origin_comments(bool value)
Returns options with origin comments toggled.