From patchwork Wed Mar 27 00:21:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 816 Return-Path: Received: from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net [195.74.38.229]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 42449600F9 for ; Wed, 27 Mar 2019 01:21:22 +0100 (CET) X-Halon-ID: 37c01866-5026-11e9-8144-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id 37c01866-5026-11e9-8144-0050569116f7; Wed, 27 Mar 2019 01:21:08 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Wed, 27 Mar 2019 01:21:05 +0100 Message-Id: <20190327002107.24487-2-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190327002107.24487-1-niklas.soderlund@ragnatech.se> References: <20190327002107.24487-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/3] cam: options: Create separate enum for OptionValue types X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Mar 2019 00:21:22 -0000 In preparation for support of multiple instances of the same option, create a separate enum for the OptionValue types as it will diverge from enum OptionType. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- src/cam/options.cpp | 16 ++++++++-------- src/cam/options.h | 11 +++++++++-- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/cam/options.cpp b/src/cam/options.cpp index 655aa36bb9c93b85..497833397d894f82 100644 --- a/src/cam/options.cpp +++ b/src/cam/options.cpp @@ -248,27 +248,27 @@ void KeyValueParser::usage(int indent) */ OptionValue::OptionValue() - : type_(OptionNone) + : type_(ValueNone) { } OptionValue::OptionValue(int value) - : type_(OptionInteger), integer_(value) + : type_(ValueInteger), integer_(value) { } OptionValue::OptionValue(const char *value) - : type_(OptionString), string_(value) + : type_(ValueString), string_(value) { } OptionValue::OptionValue(const std::string &value) - : type_(OptionString), string_(value) + : type_(ValueString), string_(value) { } OptionValue::OptionValue(const KeyValueParser::Options &value) - : type_(OptionKeyValue), keyValues_(value) + : type_(ValueKeyValue), keyValues_(value) { } @@ -289,7 +289,7 @@ OptionValue::operator KeyValueParser::Options() const int OptionValue::toInteger() const { - if (type_ != OptionInteger) + if (type_ != ValueInteger) return 0; return integer_; @@ -297,7 +297,7 @@ int OptionValue::toInteger() const std::string OptionValue::toString() const { - if (type_ != OptionString) + if (type_ != ValueString) return std::string(); return string_; @@ -305,7 +305,7 @@ std::string OptionValue::toString() const KeyValueParser::Options OptionValue::toKeyValues() const { - if (type_ != OptionKeyValue) + if (type_ != ValueKeyValue) return KeyValueParser::Options(); return keyValues_; diff --git a/src/cam/options.h b/src/cam/options.h index 745f4a4a3a433f9e..b33a90fc6058febf 100644 --- a/src/cam/options.h +++ b/src/cam/options.h @@ -79,13 +79,20 @@ private: class OptionValue { public: + enum ValueType { + ValueNone, + ValueInteger, + ValueString, + ValueKeyValue, + }; + OptionValue(); OptionValue(int value); OptionValue(const char *value); OptionValue(const std::string &value); OptionValue(const KeyValueParser::Options &value); - OptionType type() const { return type_; } + ValueType type() const { return type_; } operator int() const; operator std::string() const; @@ -96,7 +103,7 @@ public: KeyValueParser::Options toKeyValues() const; private: - OptionType type_; + ValueType type_; int integer_; std::string string_; KeyValueParser::Options keyValues_;