{"id":16027,"url":"https://patchwork.libcamera.org/api/1.1/patches/16027/?format=json","web_url":"https://patchwork.libcamera.org/patch/16027/","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":"<20220524225816.6830-2-laurent.pinchart@ideasonboard.com>","date":"2022-05-24T22:58:05","name":"[libcamera-devel,RFC,01/12] libcamera: yaml_object: Turn Type into an enum class","commit_ref":null,"pull_url":null,"state":"accepted","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/16027/mbox/","series":[{"id":3135,"url":"https://patchwork.libcamera.org/api/1.1/series/3135/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3135","date":"2022-05-24T22:58:04","name":"Replace boost JSON parser with libyaml in Raspberry Pi IPA","version":1,"mbox":"https://patchwork.libcamera.org/series/3135/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16027/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16027/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 8A0B8BD161\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 24 May 2022 22:58:29 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1756C65670;\n\tWed, 25 May 2022 00:58:29 +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 ED3C360416\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 25 May 2022 00:58:24 +0200 (CEST)","from pendragon.ideasonboard.com (ip-109-40-241-133.web.vodafone.de\n\t[109.40.241.133])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6CEEAA58;\n\tWed, 25 May 2022 00:58:24 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1653433109;\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=TOw6v4PTnvFZDpvDMyZ4pPa+zMoBb/vQfnj7W0/nVYuzBrwz+X5+hXmbpZkxH44k/\n\t9uOEdiOLirz7mfYSwTV20d3qwLl9zcn0yNlZYKuYs0i5vXfuryJnYe+KGYnM4GBn1Q\n\teIbWE3w7p5jrkyQoCiR42wynosZyqC9sHG5DfRTnd37FETyu2Ya1gWJDiJgZHh5Yes\n\tJVTbzQQbfB2I/v66DtshQoYW6f7LMGjqJFyOWh4+rYvMUgpNce8a/eLDji3njl0AOf\n\tKDjLdjCNnVgAU590ngvCQA3LzqMpGOXiTvitWp/vSH+rqdg2F7TF4OUcRFjfpuGuDK\n\tQusKWQ4aTwgEw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1653433104;\n\tbh=c+sScQK4fT7hxRiMXqN58bPZT5GyrKJgbTvVGkrF0lI=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=Q+/WmQuafk/xWtnEjVIIKrqgq7RGQqR3uWfSruTsigpU3q25HLysEyV7fGuSbtCty\n\t0VfHg0JBPnITMLjkhl5DJq3uopY4aMorGnuZ3HEj3Tsd2Ntwuo2A29amecqBvVHLlS\n\ty8K2DA8thXbBTPwUsIdQHRdzc5d/okibD+IyibMk="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"Q+/WmQua\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 25 May 2022 01:58:05 +0300","Message-Id":"<20220524225816.6830-2-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.35.1","In-Reply-To":"<20220524225816.6830-1-laurent.pinchart@ideasonboard.com>","References":"<20220524225816.6830-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [RFC PATCH 01/12] 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","01/12"]}