[libcamera-devel,v3,11/33] cam: options: Add empty() function to OptionValue class
diff mbox series

Message ID 20210715211459.19373-12-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • Multi-camera support in the cam application
Related show

Commit Message

Laurent Pinchart July 15, 2021, 9:14 p.m. UTC
Add a convenience helper to check if an option value is empty, based on
the value type. This is useful as a shortcut syntax to check if an
option has been set.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/cam/options.cpp | 7 +++++++
 src/cam/options.h   | 1 +
 2 files changed, 8 insertions(+)

Comments

Jacopo Mondi July 22, 2021, 12:51 p.m. UTC | #1
Hi Laurent,

On Fri, Jul 16, 2021 at 12:14:37AM +0300, Laurent Pinchart wrote:
> Add a convenience helper to check if an option value is empty, based on
> the value type. This is useful as a shortcut syntax to check if an
> option has been set.

Looks good!
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
  j

>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  src/cam/options.cpp | 7 +++++++
>  src/cam/options.h   | 1 +
>  2 files changed, 8 insertions(+)
>
> diff --git a/src/cam/options.cpp b/src/cam/options.cpp
> index fda6d9764ac5..481ac189f115 100644
> --- a/src/cam/options.cpp
> +++ b/src/cam/options.cpp
> @@ -583,6 +583,13 @@ void OptionValue::addValue(const OptionValue &value)
>   * \return The value type
>   */
>
> +/**
> + * \fn OptionValue::empty()
> + * \brief Check if the value is empty
> + * \return True if the value is empty (type set to ValueType::ValueNone), or
> + * false otherwise
> + */
> +
>  /**
>   * \brief Cast the value to an int
>   * \return The option value as an int, or 0 if the value type isn't
> diff --git a/src/cam/options.h b/src/cam/options.h
> index 210e502a24e1..83c409ae4d28 100644
> --- a/src/cam/options.h
> +++ b/src/cam/options.h
> @@ -135,6 +135,7 @@ public:
>  	void addValue(const OptionValue &value);
>
>  	ValueType type() const { return type_; }
> +	bool empty() const { return type_ == ValueType::ValueNone; }
>
>  	operator int() const;
>  	operator std::string() const;
> --
> Regards,
>
> Laurent Pinchart
>

Patch
diff mbox series

diff --git a/src/cam/options.cpp b/src/cam/options.cpp
index fda6d9764ac5..481ac189f115 100644
--- a/src/cam/options.cpp
+++ b/src/cam/options.cpp
@@ -583,6 +583,13 @@  void OptionValue::addValue(const OptionValue &value)
  * \return The value type
  */
 
+/**
+ * \fn OptionValue::empty()
+ * \brief Check if the value is empty
+ * \return True if the value is empty (type set to ValueType::ValueNone), or
+ * false otherwise
+ */
+
 /**
  * \brief Cast the value to an int
  * \return The option value as an int, or 0 if the value type isn't
diff --git a/src/cam/options.h b/src/cam/options.h
index 210e502a24e1..83c409ae4d28 100644
--- a/src/cam/options.h
+++ b/src/cam/options.h
@@ -135,6 +135,7 @@  public:
 	void addValue(const OptionValue &value);
 
 	ValueType type() const { return type_; }
+	bool empty() const { return type_ == ValueType::ValueNone; }
 
 	operator int() const;
 	operator std::string() const;