arg_router
1.4.0
C++ command line argument parsing and routing
|
#include <arg_router/multi_lang/root_wrapper.hpp>
Public Member Functions | |
root_wrapper_t (std::string_view iso_language, Fn &&f) | |
void | parse (int argc, char **argv) const |
void | help (std::ostream &stream) const |
string | help () const |
A wrapper around a root node that provides multi-language support.
The wrapper relies on the use of string_selector (or SM_) to provide compile-time selection of language variants for strings. The wrapper simply creates a root variant for the given ISO language code. If the given ISO language code does not match any of the supporting ones, then the first supported language is used as a fallback.
As implied by the above example, the supported language is given by index to the function object that returns the root instance. This means that each use of string_selector must have the same number of language options, in the same order. The latter requirement is especially important as this cannot be checked by arg_router.
Fn is a function object used to return a given root type from a supported language index, its signature must match:
The SupportedISOLanguageCodes parameters can be any set of unique strings, but as they are compared against an input that would usually come from a std::locale()
call, then ISO language codes are least troublesome and easiest to read.
Fn | Function object type that accepts an integral constant (the supported language index) and returns a root instance |
SupportedISOLanguageCodes | The supported ISO language codes as compile time strings |
Definition at line 67 of file root_wrapper.hpp.
|
inlineexplicit |
Constructor
iso_language | The runtime language selection, if it doesn't match any of SupportedISOLanguageCodes, then the first language in SupportedISOLanguageCodes is used |
f | Function object that returns the root instance for a given supported language index |
Definition at line 92 of file root_wrapper.hpp.
|
inline |
Calls the help method on the selected root.
Definition at line 132 of file root_wrapper.hpp.
|
inline |
Calls the help method on the selected root.
stream | Output stream to write into |
Definition at line 123 of file root_wrapper.hpp.
|
inline |
Calls the parse method on the selected root.
argc | Number of arguments |
argv | Array of char pointers to the command line tokens |
Definition at line 114 of file root_wrapper.hpp.