[libcamera-devel] [PATCH 06/30] cam: options: Slit OptionsParser::usage() in two functions
Kieran Bingham
kieran.bingham at ideasonboard.com
Mon Jul 12 15:33:31 CEST 2021
In $SUBJECT : s/Slit/Split/
On 07/07/2021 03:19, Laurent Pinchart wrote:
> To prepare for code reuse, split the printing of options out of
> OptionsParser::usage() to a separate function.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
> ---
> src/cam/options.cpp | 12 +++++++++---
> src/cam/options.h | 2 ++
> 2 files changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/src/cam/options.cpp b/src/cam/options.cpp
> index 2f71860d0466..f4fd8973f97a 100644
> --- a/src/cam/options.cpp
> +++ b/src/cam/options.cpp
> @@ -903,8 +903,6 @@ OptionsParser::Options OptionsParser::parse(int argc, char **argv)
> */
> void OptionsParser::usage()
> {
> - std::cerr << "Options:" << std::endl;
> -
> unsigned int indent = 0;
>
> for (const Option &option : options_) {
> @@ -924,7 +922,15 @@ void OptionsParser::usage()
>
> indent = (indent + 7) / 8 * 8;
>
> - for (const Option &option : options_) {
> + std::cerr << "Options:" << std::endl;
> +
> + usageOptions(options_, indent);
> +}
> +
> +void OptionsParser::usageOptions(const std::list<Option> &options,
> + unsigned int indent)
> +{
> + for (const Option &option : options) {
> std::string argument;
> if (option.hasShortOption())
> argument = std::string(" -")
> diff --git a/src/cam/options.h b/src/cam/options.h
> index 0b8bb172d184..01a5d36a63fb 100644
> --- a/src/cam/options.h
> +++ b/src/cam/options.h
> @@ -95,6 +95,8 @@ public:
> void usage();
>
> private:
> + void usageOptions(const std::list<Option> &options, unsigned int indent);
> +
> std::list<Option> options_;
> std::map<unsigned int, Option *> optionsMap_;
> };
>
More information about the libcamera-devel
mailing list