[libcamera-devel,1/6] cam: options: move enum OptionArgument

Message ID 20190128004109.25860-2-niklas.soderlund@ragnatech.se
State Superseded
Headers show
Series
  • cam: add --format option to configure a stream
Related show

Commit Message

Niklas Söderlund Jan. 28, 2019, 12:41 a.m. UTC
The enumeration of the different possibilities for arguments can be used
by other parser then OptionsParser. Move it outside the class to make it
ready to be used by other parsers.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
---
 src/cam/main.cpp  |  3 +--
 src/cam/options.h | 12 ++++++------
 2 files changed, 7 insertions(+), 8 deletions(-)

Comments

Kieran Bingham Jan. 29, 2019, 9:33 a.m. UTC | #1
Hi Niklas,

On 28/01/2019 00:41, Niklas Söderlund wrote:
> The enumeration of the different possibilities for arguments can be used
> by other parser then OptionsParser. Move it outside the class to make it
> ready to be used by other parsers.
> 

Seems trivial and painless:

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> ---
>  src/cam/main.cpp  |  3 +--
>  src/cam/options.h | 12 ++++++------
>  2 files changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/src/cam/main.cpp b/src/cam/main.cpp
> index cb98d302dcf30331..bde47a8f17983912 100644
> --- a/src/cam/main.cpp
> +++ b/src/cam/main.cpp
> @@ -38,8 +38,7 @@ static int parseOptions(int argc, char *argv[])
>  	OptionsParser parser;
>  
>  	parser.addOption(OptCamera, "Specify which camera to operate on",
> -			 "camera", OptionsParser::ArgumentRequired,
> -			 "camera");
> +			 "camera", ArgumentRequired, "camera");
>  	parser.addOption(OptHelp, "Display this help message", "help");
>  	parser.addOption(OptList, "List all cameras", "list");
>  
> diff --git a/src/cam/options.h b/src/cam/options.h
> index f99ea7300a71c24f..491f6a316fffbe5b 100644
> --- a/src/cam/options.h
> +++ b/src/cam/options.h
> @@ -11,15 +11,15 @@
>  #include <map>
>  #include <vector>
>  
> +enum OptionArgument {
> +	ArgumentNone,
> +	ArgumentRequired,
> +	ArgumentOptional,
> +};
> +
>  class OptionsParser
>  {
>  public:
> -	enum OptionArgument {
> -		ArgumentNone,
> -		ArgumentRequired,
> -		ArgumentOptional,
> -	};
> -
>  	class Options {
>  	public:
>  		Options();
>
Laurent Pinchart Jan. 31, 2019, 9:51 a.m. UTC | #2
Hi Niklas,

Thank you for the patch.

On Mon, Jan 28, 2019 at 01:41:04AM +0100, Niklas Söderlund wrote:
> The enumeration of the different possibilities for arguments can be used
> by other parser then OptionsParser. Move it outside the class to make it
> ready to be used by other parsers.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  src/cam/main.cpp  |  3 +--
>  src/cam/options.h | 12 ++++++------
>  2 files changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/src/cam/main.cpp b/src/cam/main.cpp
> index cb98d302dcf30331..bde47a8f17983912 100644
> --- a/src/cam/main.cpp
> +++ b/src/cam/main.cpp
> @@ -38,8 +38,7 @@ static int parseOptions(int argc, char *argv[])
>  	OptionsParser parser;
>  
>  	parser.addOption(OptCamera, "Specify which camera to operate on",
> -			 "camera", OptionsParser::ArgumentRequired,
> -			 "camera");
> +			 "camera", ArgumentRequired, "camera");
>  	parser.addOption(OptHelp, "Display this help message", "help");
>  	parser.addOption(OptList, "List all cameras", "list");
>  
> diff --git a/src/cam/options.h b/src/cam/options.h
> index f99ea7300a71c24f..491f6a316fffbe5b 100644
> --- a/src/cam/options.h
> +++ b/src/cam/options.h
> @@ -11,15 +11,15 @@
>  #include <map>
>  #include <vector>
>  
> +enum OptionArgument {
> +	ArgumentNone,
> +	ArgumentRequired,
> +	ArgumentOptional,
> +};
> +
>  class OptionsParser
>  {
>  public:
> -	enum OptionArgument {
> -		ArgumentNone,
> -		ArgumentRequired,
> -		ArgumentOptional,
> -	};
> -
>  	class Options {
>  	public:
>  		Options();
> -- 
> 2.20.1
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/src/cam/main.cpp b/src/cam/main.cpp
index cb98d302dcf30331..bde47a8f17983912 100644
--- a/src/cam/main.cpp
+++ b/src/cam/main.cpp
@@ -38,8 +38,7 @@  static int parseOptions(int argc, char *argv[])
 	OptionsParser parser;
 
 	parser.addOption(OptCamera, "Specify which camera to operate on",
-			 "camera", OptionsParser::ArgumentRequired,
-			 "camera");
+			 "camera", ArgumentRequired, "camera");
 	parser.addOption(OptHelp, "Display this help message", "help");
 	parser.addOption(OptList, "List all cameras", "list");
 
diff --git a/src/cam/options.h b/src/cam/options.h
index f99ea7300a71c24f..491f6a316fffbe5b 100644
--- a/src/cam/options.h
+++ b/src/cam/options.h
@@ -11,15 +11,15 @@ 
 #include <map>
 #include <vector>
 
+enum OptionArgument {
+	ArgumentNone,
+	ArgumentRequired,
+	ArgumentOptional,
+};
+
 class OptionsParser
 {
 public:
-	enum OptionArgument {
-		ArgumentNone,
-		ArgumentRequired,
-		ArgumentOptional,
-	};
-
 	class Options {
 	public:
 		Options();