[libcamera-devel,v2,2/8] cam: options: Move struct Option

Message ID 20190131234721.22606-3-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • cam: add --format option to configure a stream
Related show

Commit Message

Laurent Pinchart Jan. 31, 2019, 11:47 p.m. UTC
The Option structure is declared within the OptionsParser, but will
later be needed by other parsers. Move it outside the OptionsParser
class.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/cam/options.h | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

Comments

Niklas Söderlund Feb. 1, 2019, 8:57 a.m. UTC | #1
Hi Laurent,

Thanks for your work.

On 2019-02-01 01:47:15 +0200, Laurent Pinchart wrote:
> The Option structure is declared within the OptionsParser, but will
> later be needed by other parsers. Move it outside the OptionsParser
> class.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> ---
>  src/cam/options.h | 22 +++++++++++-----------
>  1 file changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/src/cam/options.h b/src/cam/options.h
> index 491f6a316fff..6d1b12d235d8 100644
> --- a/src/cam/options.h
> +++ b/src/cam/options.h
> @@ -17,6 +17,17 @@ enum OptionArgument {
>  	ArgumentOptional,
>  };
>  
> +struct Option {
> +	int opt;
> +	const char *name;
> +	OptionArgument argument;
> +	const char *argumentName;
> +	const char *help;
> +
> +	bool hasShortOption() const { return isalnum(opt); }
> +	bool hasLongOption() const { return name != nullptr; }
> +};
> +
>  class OptionsParser
>  {
>  public:
> @@ -42,17 +53,6 @@ public:
>  	void usage();
>  
>  private:
> -	struct Option {
> -		int opt;
> -		const char *name;
> -		OptionArgument argument;
> -		const char *argumentName;
> -		const char *help;
> -
> -		bool hasShortOption() const { return isalnum(opt); }
> -		bool hasLongOption() const { return name != nullptr; }
> -	};
> -
>  	std::vector<Option> options_;
>  	std::map<unsigned int, Option *> optionsMap_;
>  };
> -- 
> Regards,
> 
> Laurent Pinchart
>

Patch

diff --git a/src/cam/options.h b/src/cam/options.h
index 491f6a316fff..6d1b12d235d8 100644
--- a/src/cam/options.h
+++ b/src/cam/options.h
@@ -17,6 +17,17 @@  enum OptionArgument {
 	ArgumentOptional,
 };
 
+struct Option {
+	int opt;
+	const char *name;
+	OptionArgument argument;
+	const char *argumentName;
+	const char *help;
+
+	bool hasShortOption() const { return isalnum(opt); }
+	bool hasLongOption() const { return name != nullptr; }
+};
+
 class OptionsParser
 {
 public:
@@ -42,17 +53,6 @@  public:
 	void usage();
 
 private:
-	struct Option {
-		int opt;
-		const char *name;
-		OptionArgument argument;
-		const char *argumentName;
-		const char *help;
-
-		bool hasShortOption() const { return isalnum(opt); }
-		bool hasLongOption() const { return name != nullptr; }
-	};
-
 	std::vector<Option> options_;
 	std::map<unsigned int, Option *> optionsMap_;
 };