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

Static Public Member Functions

static shared_value from_any_ref (unwrapped_value value, std::string origin_description="")
 Creates a ConfigValue from a plain value, which may be a bool, long, string, unordered_map, vector or nullptr. More...
 

Detailed Description

Definition at line 8 of file config_value_factory.hpp.

Member Function Documentation

◆ from_any_ref()

static shared_value hocon::config_value_factory::from_any_ref ( unwrapped_value  value,
std::string  origin_description = "" 
)
static

Creates a ConfigValue from a plain value, which may be a bool, long, string, unordered_map, vector or nullptr.

An unordered_map must be a unordered_map from string to more values that can be supplied to from_any_ref(). An unordered_map will become a ConfigObject and a vector will become a ConfigList.

In a unordered_map passed to from_any_ref(), the map's keys are plain keys, not path expressions. So if your unordered_map has a key "foo.bar" then you will get one object with a key called "foo.bar", rather than an object with a key "foo" containing another object with a key "bar".

The origin_description will be used to set the origin() field on the ConfigValue. It should normally be the name of the file the values came from, or something short describing the value such as "default settings". The origin_description is prefixed to error messages so users can tell where problematic values are coming from.

Supplying the result of ConfigValue.unwrapped() to this function is guaranteed to work and should give you back a ConfigValue that matches the one you unwrapped. The re-wrapped ConfigValue will lose some information that was present in the original such as its origin, but it will have matching values.

Parameters
unwrapped_valueobject object to convert to ConfigValue
stringorigin_description name of origin file or brief description of what the value is
Returns
shared_value a new value

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