$darkmode
#include <filesystem>#include <functional>#include <string>#include <utility>#include <vector>#include <fmt/format.h>#include <fable/fable_fwd.hpp>#include <fable/json.hpp>Go to the source code of this file.
Classes | |
| class | fable::Conf |
This file contains Conf and ConfError, two classes which aim to be a user and developer friendly approach to reading in JSON.
One of the biggest challenges of reading a configuration is that of error management. How do we ensure that we are getting the values that we need when we need them, and in all other cases inform the user of their mistake.
One approach to this is to verify each input via a schema. There is an RFC currently being developed to add a JSON schema, but this poses two problems for us:
Another problem that needs to be solved in reading configurations is that of relative paths. When a relative path is specified, the user expects that the path is relative to the configuration being read. But once a JSON has be deserialized, there is no intrinsic information telling the program where that JSON file once resided, especially if we use a modular configuration system. This means, we somehow need to add origin information to configuration data. This is also necessary when we need to provide user-friendly error messages.
The Conf type attempts to address this problem by wrapping all JSON data with a class that provides consistent and transparent error message propagation and handling.