[libcamera-devel,v2,21/32] libcamera: controls: Convert bool ControlValue to lowercase strings

Message ID 20200306160002.30549-22-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • libcamera: Add support for array controls
Related show

Commit Message

Laurent Pinchart March 6, 2020, 3:59 p.m. UTC
The C++ boolean types are lower case, and std::ostream::operator<<(bool)
produces a lowercase string (when std::boolalpha is in effect, otherwise
it produces 0 or 1).  Switch ControlValue::toString() to produce
lowercase "true" and "false" strings too for consistency.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/libcamera/controls.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Kieran Bingham March 6, 2020, 4:04 p.m. UTC | #1
On 06/03/2020 15:59, Laurent Pinchart wrote:
> The C++ boolean types are lower case, and std::ostream::operator<<(bool)
> produces a lowercase string (when std::boolalpha is in effect, otherwise
> it produces 0 or 1).  Switch ControlValue::toString() to produce
> lowercase "true" and "false" strings too for consistency.

Ok, that's fine then.

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

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

> ---
>  src/libcamera/controls.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp
> index 0663a2201609..94bdbdd9c388 100644
> --- a/src/libcamera/controls.cpp
> +++ b/src/libcamera/controls.cpp
> @@ -198,7 +198,7 @@ std::string ControlValue::toString() const
>  		switch (type_) {
>  		case ControlTypeBool: {
>  			const bool *value = reinterpret_cast<const bool *>(data);
> -			str += *value ? "True" : "False";
> +			str += *value ? "true" : "false";
>  			break;
>  		}
>  		case ControlTypeByte: {
>

Patch

diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp
index 0663a2201609..94bdbdd9c388 100644
--- a/src/libcamera/controls.cpp
+++ b/src/libcamera/controls.cpp
@@ -198,7 +198,7 @@  std::string ControlValue::toString() const
 		switch (type_) {
 		case ControlTypeBool: {
 			const bool *value = reinterpret_cast<const bool *>(data);
-			str += *value ? "True" : "False";
+			str += *value ? "true" : "false";
 			break;
 		}
 		case ControlTypeByte: {