cpp-hocon  0.3.0
Public Member Functions | List of all members
hocon::simple_config_document Class Reference
Inheritance diagram for hocon::simple_config_document:
hocon::config_document

Public Member Functions

 simple_config_document (std::shared_ptr< const config_node_root > root, config_parse_options opts)
 
std::unique_ptr< config_documentwith_value_text (std::string path, std::string new_value) const override
 Returns a new config_document that is a copy of the current config_document, but with the desired value set at the desired path. More...
 
std::unique_ptr< config_documentwith_value (std::string path, std::shared_ptr< config_value > new_value) const override
 Returns a new config_document that is a copy of the current config_document, but with the desired value set at the desired path. More...
 
std::unique_ptr< config_documentwithout_path (std::string path) const override
 Returns a new config_document that is a copy of the current config_document, but with all values at the desired path removed. More...
 
bool has_path (std::string const &path) const override
 Returns a boolean indicating whether or not a config_document has a value at the desired path. More...
 
std::string render () const override
 The original text of the input, modified if necessary with any replaced or added values. More...
 

Detailed Description

Definition at line 10 of file simple_config_document.hpp.

Member Function Documentation

◆ has_path()

bool hocon::simple_config_document::has_path ( std::string const &  path) const
overridevirtual

Returns a boolean indicating whether or not a config_document has a value at the desired path.

null counts as a value for purposes of this check.

Parameters
paththe path to check
Returns
true if the path exists in the document, otherwise false

Implements hocon::config_document.

◆ render()

std::string hocon::simple_config_document::render ( ) const
overridevirtual

The original text of the input, modified if necessary with any replaced or added values.

Returns
the modified original text

Implements hocon::config_document.

◆ with_value()

std::unique_ptr<config_document> hocon::simple_config_document::with_value ( std::string  path,
std::shared_ptr< config_value new_value 
) const
overridevirtual

Returns a new config_document that is a copy of the current config_document, but with the desired value set at the desired path.

Works like with_value_text(string, string), but takes a config_value instead of a string.

Parameters
paththe path at which to set the desired value
new_valuethe value to set at the desired path, represented as a config_value. The rendered text of the config_value will be inserted into the config_document.
Returns
a copy of the config_document with the desired value at the desired path

Implements hocon::config_document.

◆ with_value_text()

std::unique_ptr<config_document> hocon::simple_config_document::with_value_text ( std::string  path,
std::string  newValue 
) const
overridevirtual

Returns a new config_document that is a copy of the current config_document, but with the desired value set at the desired path.

If the path exists, it will remove all duplicates before the final occurrence of the path, and replace the value at the final occurrence of the path. If the path does not exist, it will be added. If the document has an array as the root value, an exception will be thrown.

Parameters
paththe path at which to set the desired value
new_valuethe value to set at the desired path, represented as a string. This string will be parsed into a config_node using the same options used to parse the entire document, and the text will be inserted as-is into the document. Leading and trailing comments, whitespace, or newlines are not allowed, and if present an exception will be thrown. If a concatenation is passed in for newValue but the document was parsed with JSON, the first value in the concatenation will be parsed and inserted into the config_document.
Returns
a copy of the config_document with the desired value at the desired path

Implements hocon::config_document.

◆ without_path()

std::unique_ptr<config_document> hocon::simple_config_document::without_path ( std::string  path) const
overridevirtual

Returns a new config_document that is a copy of the current config_document, but with all values at the desired path removed.

If the path does not exist in the document, a copy of the current document will be returned. If there is an array at the root, an exception will be thrown.

Parameters
paththe path to remove from the document
Returns
a copy of the config_document with the desired value removed from the document.

Implements hocon::config_document.


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