The Configuru namespace.
More...
|
using | DocInfo_SP = std::shared_ptr< DocInfo > |
|
using | Index = unsigned |
|
using | Comment = std::string |
|
using | Comments = std::vector< Comment > |
|
|
template<typename T > |
T | as (const configuru::Config &config) |
|
bool | operator== (const Config &a, const Config &b) |
|
bool | operator!= (const Config &a, const Config &b) |
|
std::ostream & | operator<< (std::ostream &os, const Config &cfg) |
| Prints in JSON but in a fail-safe mannor, allowing uninitalized keys and inf/nan.
|
|
template<class Config , class Visitor > |
void | visit_configs (Config &&config, Visitor &&visitor) |
| Recursively visit all values in a config.
|
|
void | clear_doc (Config &root) |
|
FormatOptions | make_json_options () |
| Returns FormatOptions that are describe a JSON file format.
|
|
FormatOptions | make_forgiving_options () |
| Returns format options that allow us parsing most files.
|
|
Config | parse_string (const char *str, const FormatOptions &options, const char *name) |
|
Config | parse_file (const std::string &path, const FormatOptions &options) |
|
Config | parse_string (const char *str, const FormatOptions &options, DocInfo _doc, ParseInfo &info) |
| Advanced usage:
|
|
Config | parse_file (const std::string &path, const FormatOptions &options, DocInfo_SP doc, ParseInfo &info) |
|
std::string | dump_string (const Config &config, const FormatOptions &options) |
|
void | dump_file (const std::string &path, const Config &config, const FormatOptions &options) |
|
|
const Index | BAD_INDEX = static_cast<Index>(-1) |
|
Overload this (in cofiguru namespace) for you own types, e.g:
template<>
inline Vector2f
as(
const Config& config)
{
auto&& array = config.as_array();
config.check(array.size() == 2, "Expected Vector2f");
return {(float)array[0], (float)array[1]};
}
}
void configuru::dump_file |
( |
const std::string & |
path, |
|
|
const Config & |
config, |
|
|
const FormatOptions & |
options |
|
) |
| |
Writes the config to a file. Like dump_string, but can may also call CONFIGURU_ONERROR if it fails to write to the given path.
Writes the config as a string in the given format. May call CONFIGURU_ONERROR if the given config is invalid. This can happen if a Config is unitialized (and options write_uninitialized is not set) or a Config contains inf/nan (and options.inf/options.nan aren't set).
Config configuru::parse_string |
( |
const char * |
str, |
|
|
const FormatOptions & |
options, |
|
|
const char * |
name |
|
) |
| |
The parser may throw ParseError. str
should be a zero-ended Utf-8 encoded string of characters. The name
should be something akin to a filename. It is only for error reporting.