From 7ebd5f9f540e907de06d8fdc76d95ccacabbbe1f Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 5 Aug 2021 19:36:34 +0300 Subject: Add support for option positions to load_default_options() --- libbutl/default-options.mxx | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'libbutl/default-options.mxx') diff --git a/libbutl/default-options.mxx b/libbutl/default-options.mxx index 2d44333..1694d48 100644 --- a/libbutl/default-options.mxx +++ b/libbutl/default-options.mxx @@ -11,6 +11,7 @@ #include // move(), forward(), make_pair() #include // reverse() +#include // invalid_argument #include #endif @@ -107,6 +108,15 @@ LIBBUTL_MODEXPORT namespace butl // // Note that the extra directory options files are never considered remote. // + // For the convenience of implementation, the function parses the option + // files in the reverse order. Thus, to make sure that positions in the + // options list monotonically increase, it needs the maximum number of + // arguments, globally and per file, to be specified. This way the starting + // options position for each file will be less than for the previously + // parsed file by arg_max_file and equal to arg_max - arg_max_file for the + // first file. If the actual number of arguments exceeds the specified, then + // invalid_argument is thrown. + // template default_options load_default_options (const optional& sys_dir, @@ -115,6 +125,8 @@ LIBBUTL_MODEXPORT namespace butl const default_options_files&, F&&, const std::string& option, + std::size_t arg_max, + std::size_t arg_max_file, bool args = false); // Merge the default options/arguments and the command line -- cgit v1.1