4 #include "config_mergeable.hpp" 5 #include "config_origin.hpp" 6 #include "config_object.hpp" 7 #include "config_resolve_options.hpp" 8 #include "config_value.hpp" 9 #include "config_list.hpp" 10 #include "config_exception.hpp" 16 #include <leatherman/locale/locale.hpp> 20 enum class time_unit { NANOSECONDS, MICROSECONDS, MILLISECONDS, SECONDS, MINUTES, HOURS, DAYS };
211 static shared_config parse_file_any_syntax(std::string file_basename,
config_parse_options options);
221 static shared_config parse_file_any_syntax(std::string file_basename);
239 static shared_config parse_string(std::string s);
248 virtual shared_object root()
const;
256 virtual shared_origin origin()
const;
258 std::shared_ptr<const config_mergeable> with_fallback(std::shared_ptr<const config_mergeable> other)
const override;
260 shared_value to_fallback_value()
const override;
313 virtual shared_config resolve()
const;
338 virtual bool is_resolved()
const;
360 virtual shared_config resolve_with(shared_config source)
const;
448 virtual void check_valid(shared_config reference, std::vector<std::string> restrict_to_paths)
const;
471 virtual bool has_path(std::string
const&
path)
const;
510 virtual bool has_path_or_null(std::string
const&
path)
const;
518 virtual bool is_empty()
const;
542 virtual std::set<std::pair<std::string, std::shared_ptr<const config_value>>> entry_set()
const;
565 virtual bool get_is_null(std::string
const&
path)
const;
567 virtual bool get_bool(std::string
const&
path)
const;
568 virtual int get_int(std::string
const&
path)
const;
569 virtual int64_t get_long(std::string
const&
path)
const;
570 virtual double get_double(std::string
const&
path)
const;
571 virtual std::string get_string(std::string
const&
path)
const;
572 virtual std::shared_ptr<const config_object> get_object(std::string
const&
path)
const;
573 virtual shared_config get_config(std::string
const&
path)
const;
574 virtual unwrapped_value get_any_ref(std::string
const&
path)
const;
575 virtual std::shared_ptr<const config_value> get_value(std::string
const&
path)
const;
578 std::vector<T> get_homogeneous_unwrapped_list(std::string
const&
path)
const {
579 auto list = boost::get<std::vector<unwrapped_value>>(get_list(
path)->unwrapped());
580 std::vector<T> T_list;
581 for (
auto item : list) {
583 T_list.push_back(boost::get<T>(item));
584 }
catch (boost::bad_get &ex) {
585 throw config_exception(leatherman::locale::format(
"The list did not contain only the desired type."));
591 virtual shared_list get_list(std::string
const&
path)
const;
592 virtual std::vector<bool> get_bool_list(std::string
const&
path)
const;
593 virtual std::vector<int> get_int_list(std::string
const&
path)
const;
594 virtual std::vector<int64_t> get_long_list(std::string
const&
path)
const;
595 virtual std::vector<double> get_double_list(std::string
const&
path)
const;
596 virtual std::vector<std::string> get_string_list(std::string
const&
path)
const;
597 virtual std::vector<shared_object> get_object_list(std::string
const&
path)
const;
598 virtual std::vector<shared_config> get_config_list(std::string
const&
path)
const;
610 virtual int64_t get_duration(std::string
const&
path, time_unit unit)
const;
623 virtual shared_config with_only_path(std::string
const&
path)
const;
635 virtual shared_config without_path(std::string
const&
path)
const;
648 virtual shared_config at_path(std::string
const&
path)
const;
660 virtual shared_config at_key(std::string
const& key)
const;
677 virtual shared_config with_value(std::string
const&
path, std::shared_ptr<const config_value>
value)
const;
681 config(shared_object
object);
683 static shared_object env_variables_as_config_object();
686 shared_value find(std::string
const& path_expression,
config_value::type expected)
const;
689 shared_config at_key(shared_origin origin, std::string
const& key)
const;
691 static shared_includer default_includer();
706 static duration parse_duration(std::string input, shared_origin origin_for_exception, std::string path_for_exception);
708 static duration convert(int64_t number, time_unit units);
709 static duration convert(
double number, time_unit units);
710 static time_unit get_units(std::string
const& unit_string);
713 shared_value has_path_peek(std::string
const& path_expression)
const;
714 shared_value peek_path(
path desired_path)
const;
716 static void find_paths(std::set<std::pair<std::string, std::shared_ptr<const config_value>>>& entries,
717 path parent, shared_object obj);
719 static shared_value find_key(shared_object
self, std::string
const& key,
721 static shared_value find_key_or_null(shared_object
self, std::string
const& key,
723 static shared_value find_or_null(shared_object
self,
path desired_path,
725 shared_value find_or_null(std::string
const& path_expression,
config_value::type expected)
const;
728 shared_object _object;
732 std::vector<int64_t> config::get_homogeneous_unwrapped_list(std::string
const&
path)
const;
A set of options related to parsing.
An immutable map from config paths to config values.
All exceptions thrown by the library are subclasses of config_exception.
type
The type of a configuration value (following the JSON type schema).
Factory for creating config_document instances.
An opaque handle to something that can be parsed, obtained from config_include_context.
std::pair< int64_t, int > duration
A duration represented as a 64-bit integer of seconds plus a 32-bit number of nanoseconds representin...
A set of options related to resolving substitutions.
bool operator==(config_document const &lhs, config_document const &rhs)
Config documents compare via rendered strings.
An immutable value, following the JSON type schema.