{"id":16156,"url":"https://patchwork.libcamera.org/api/1.1/patches/16156/?format=json","web_url":"https://patchwork.libcamera.org/patch/16156/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220604185939.29163-2-laurent.pinchart@ideasonboard.com>","date":"2022-06-04T18:59:26","name":"[libcamera-devel,RFC,v2,01/14] libcamera: yaml_object: Turn Type into an enum class","commit_ref":null,"pull_url":null,"state":"rfc","archived":false,"hash":"92ec66f1a13d60763a882f79d118ea03e32803f1","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/16156/mbox/","series":[{"id":3161,"url":"https://patchwork.libcamera.org/api/1.1/series/3161/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3161","date":"2022-06-04T18:59:25","name":"Replace boost JSON parser with libyaml in Raspberry Pi IPA","version":2,"mbox":"https://patchwork.libcamera.org/series/3161/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16156/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16156/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 4B496C326B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat,  4 Jun 2022 19:00:01 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C680E633A6;\n\tSat,  4 Jun 2022 21:00:00 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5EC9865632\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  4 Jun 2022 20:59:58 +0200 (CEST)","from pendragon.ideasonboard.com (85-76-79-203-nat.elisa-mobile.fi\n\t[85.76.79.203])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 288DD87A;\n\tSat,  4 Jun 2022 20:59:56 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1654369200;\n\tbh=c+sScQK4fT7hxRiMXqN58bPZT5GyrKJgbTvVGkrF0lI=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=buEGYi0WsOyR3Zbav+TVu88AlJ/8s32iDbalgQkOppOIQ3ywAxOD1Wg/HFyUI+kCG\n\t/WAeMTXRDm8yWFoZFb2gLx1B2YwEVXRXT01/RBmA3OQdGq4svjvJOk8Ufbd2poYdDM\n\tMAcw9baz22ezetBSCJrARxBxwbTjgvlF4RBZn5L3nhLW2G43w7gveBnSo/VXfH31j6\n\t6JLbK51tB38fszzFu3r3agsIWeGF9/RKN190uqsjr2gplOp5O2BNwzR9mv8HAR421G\n\twtxDAYkj2DxFzZMmIkvv2bYBr0C7Ai4XlCZ7OOdRb11wr6IWfniu3eL0mp+enQsYD9\n\tWUNGKe6cWQT1Q==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1654369198;\n\tbh=c+sScQK4fT7hxRiMXqN58bPZT5GyrKJgbTvVGkrF0lI=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=UiGVzp+MmRfpl4ZMvQlwrJTLVd+YkldgRV5dsMyWdBehtJAg8kB4lv5RUfLQ+Jjl/\n\t6FxNtvl9t6tBLsjCJXe5syXh8Hberu5oetZuogOInMUj8ssRnDL3jm6KrJyglV2cap\n\tt+nLDq+GutD9gIP57R7fInwZkBA/zsld21R6fz8k="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"UiGVzp+M\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Sat,  4 Jun 2022 21:59:26 +0300","Message-Id":"<20220604185939.29163-2-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.35.1","In-Reply-To":"<20220604185939.29163-1-laurent.pinchart@ideasonboard.com>","References":"<20220604185939.29163-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [RFC PATCH v2 01/14] libcamera: yaml_object: Turn\n\tType into an enum class","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Turn the Type enum into an enum class to force qualifying 'List' and\n'Dictionary' in the YamlObject namespace scope. This will help avoiding\nambiguities when adding iterator support.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/internal/yaml_parser.h |  8 +++---\n src/libcamera/yaml_parser.cpp            | 32 ++++++++++++------------\n 2 files changed, 20 insertions(+), 20 deletions(-)","diff":"diff --git a/include/libcamera/internal/yaml_parser.h b/include/libcamera/internal/yaml_parser.h\nindex 3a4f3052fb65..e002fcf59278 100644\n--- a/include/libcamera/internal/yaml_parser.h\n+++ b/include/libcamera/internal/yaml_parser.h\n@@ -28,15 +28,15 @@ public:\n \n \tbool isValue() const\n \t{\n-\t\treturn type_ == Value;\n+\t\treturn type_ == Type::Value;\n \t}\n \tbool isList() const\n \t{\n-\t\treturn type_ == List;\n+\t\treturn type_ == Type::List;\n \t}\n \tbool isDictionary() const\n \t{\n-\t\treturn type_ == Dictionary;\n+\t\treturn type_ == Type::Dictionary;\n \t}\n \n #ifndef __DOXYGEN__\n@@ -65,7 +65,7 @@ private:\n \n \tfriend class YamlParserContext;\n \n-\tenum Type {\n+\tenum class Type {\n \t\tDictionary,\n \t\tList,\n \t\tValue,\ndiff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp\nindex 92fedaebebfd..4b5ea427bf45 100644\n--- a/src/libcamera/yaml_parser.cpp\n+++ b/src/libcamera/yaml_parser.cpp\n@@ -47,7 +47,7 @@ void setOk(bool *ok, bool result)\n  */\n \n YamlObject::YamlObject()\n-\t: type_(Value)\n+\t: type_(Type::Value)\n {\n }\n \n@@ -99,7 +99,7 @@ bool YamlObject::get(const bool &defaultValue, bool *ok) const\n {\n \tsetOk(ok, false);\n \n-\tif (type_ != Value)\n+\tif (type_ != Type::Value)\n \t\treturn defaultValue;\n \n \tif (value_ == \"true\") {\n@@ -118,7 +118,7 @@ int32_t YamlObject::get(const int32_t &defaultValue, bool *ok) const\n {\n \tsetOk(ok, false);\n \n-\tif (type_ != Value)\n+\tif (type_ != Type::Value)\n \t\treturn defaultValue;\n \n \tif (value_ == \"\")\n@@ -141,7 +141,7 @@ uint32_t YamlObject::get(const uint32_t &defaultValue, bool *ok) const\n {\n \tsetOk(ok, false);\n \n-\tif (type_ != Value)\n+\tif (type_ != Type::Value)\n \t\treturn defaultValue;\n \n \tif (value_ == \"\")\n@@ -175,7 +175,7 @@ double YamlObject::get(const double &defaultValue, bool *ok) const\n {\n \tsetOk(ok, false);\n \n-\tif (type_ != Value)\n+\tif (type_ != Type::Value)\n \t\treturn defaultValue;\n \n \tif (value_ == \"\")\n@@ -198,7 +198,7 @@ std::string YamlObject::get(const std::string &defaultValue, bool *ok) const\n {\n \tsetOk(ok, false);\n \n-\tif (type_ != Value)\n+\tif (type_ != Type::Value)\n \t\treturn defaultValue;\n \n \tsetOk(ok, true);\n@@ -210,7 +210,7 @@ Size YamlObject::get(const Size &defaultValue, bool *ok) const\n {\n \tsetOk(ok, false);\n \n-\tif (type_ != List)\n+\tif (type_ != Type::List)\n \t\treturn defaultValue;\n \n \tif (list_.size() != 2)\n@@ -248,7 +248,7 @@ Size YamlObject::get(const Size &defaultValue, bool *ok) const\n  */\n std::size_t YamlObject::size() const\n {\n-\tif (type_ != List)\n+\tif (type_ != Type::List)\n \t\treturn 0;\n \n \treturn list_.size();\n@@ -266,7 +266,7 @@ std::size_t YamlObject::size() const\n  */\n const YamlObject &YamlObject::operator[](std::size_t index) const\n {\n-\tif (type_ != List || index >= size())\n+\tif (type_ != Type::List || index >= size())\n \t\treturn empty;\n \n \treturn *list_[index];\n@@ -326,7 +326,7 @@ std::vector<std::string> YamlObject::memberNames() const\n  */\n const YamlObject &YamlObject::operator[](const std::string &key) const\n {\n-\tif (type_ != Dictionary || !contains(key))\n+\tif (type_ != Type::Dictionary || !contains(key))\n \t\treturn empty;\n \n \tauto iter = dictionary_.find(key);\n@@ -510,7 +510,7 @@ int YamlParserContext::parseDictionaryOrList(YamlObject::Type type,\n \t\t\t\t\t     const std::function<int(EventPtr event)> &parseItem)\n {\n \tyaml_event_type_t endEventType = YAML_SEQUENCE_END_EVENT;\n-\tif (type == YamlObject::Dictionary)\n+\tif (type == YamlObject::Type::Dictionary)\n \t\tendEventType = YAML_MAPPING_END_EVENT;\n \n \t/*\n@@ -554,22 +554,22 @@ int YamlParserContext::parseNextYamlObject(YamlObject &yamlObject, EventPtr even\n \n \tswitch (event->type) {\n \tcase YAML_SCALAR_EVENT:\n-\t\tyamlObject.type_ = YamlObject::Value;\n+\t\tyamlObject.type_ = YamlObject::Type::Value;\n \t\treadValue(yamlObject.value_, std::move(event));\n \t\treturn 0;\n \n \tcase YAML_SEQUENCE_START_EVENT: {\n-\t\tyamlObject.type_ = YamlObject::List;\n+\t\tyamlObject.type_ = YamlObject::Type::List;\n \t\tauto &list = yamlObject.list_;\n \t\tauto handler = [this, &list](EventPtr evt) {\n \t\t\tlist.emplace_back(new YamlObject());\n \t\t\treturn parseNextYamlObject(*list.back(), std::move(evt));\n \t\t};\n-\t\treturn parseDictionaryOrList(YamlObject::List, handler);\n+\t\treturn parseDictionaryOrList(YamlObject::Type::List, handler);\n \t}\n \n \tcase YAML_MAPPING_START_EVENT: {\n-\t\tyamlObject.type_ = YamlObject::Dictionary;\n+\t\tyamlObject.type_ = YamlObject::Type::Dictionary;\n \t\tauto &dictionary = yamlObject.dictionary_;\n \t\tauto handler = [this, &dictionary](EventPtr evtKey) {\n \t\t\t/* Parse key */\n@@ -592,7 +592,7 @@ int YamlParserContext::parseNextYamlObject(YamlObject &yamlObject, EventPtr even\n \t\t\tauto elem = dictionary.emplace(key, std::make_unique<YamlObject>());\n \t\t\treturn parseNextYamlObject(*elem.first->second.get(), std::move(evtValue));\n \t\t};\n-\t\treturn parseDictionaryOrList(YamlObject::Dictionary, handler);\n+\t\treturn parseDictionaryOrList(YamlObject::Type::Dictionary, handler);\n \t}\n \n \tdefault:\n","prefixes":["libcamera-devel","RFC","v2","01/14"]}