Patch Detail
Show a patch.
GET /api/patches/16028/?format=api
{ "id": 16028, "url": "https://patchwork.libcamera.org/api/patches/16028/?format=api", "web_url": "https://patchwork.libcamera.org/patch/16028/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "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-3-laurent.pinchart@ideasonboard.com>", "date": "2022-05-24T22:58:06", "name": "[libcamera-devel,RFC,02/12] libcamera: yaml_parser: Extend YamlObject::size() to dictionaries", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "ba57489e3fa3efc65c8654a6abb9cbb42a4b327f", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/16028/mbox/", "series": [ { "id": 3135, "url": "https://patchwork.libcamera.org/api/series/3135/?format=api", "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/16028/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/16028/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 60E71C3256\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 24 May 2022 22:58:31 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 49B1965673;\n\tWed, 25 May 2022 00:58:30 +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 7919D60416\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 25 May 2022 00:58:25 +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 ED87CA5E;\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=1653433110;\n\tbh=6snE1bRh0/Y/freE7UR3RHw585z+/5KDONypF6MBOh0=;\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=e9i8A1bQxgjIUeSuUj/CmMVhXnlhAe1jba7W0mn0R5PAYvQjDBSC42AWhOAsosjLq\n\tpuIgYlh1iIiHbOqoy/8Tc9zDOrrZwPsmtUvHj3+1Vdn3v722z49cRVXqnefZVjUFdV\n\tS5C2TIh8FWlBXM0EsZEnPqIQYPxD1hKzW81FogcDWt3lCdY2wJWiI8qMTS9gO8Xs1V\n\tiIWdYqscWb7LWdHso21TplK0Mb4cEVWqEFW2sEXZ7tIqZ4xSYydQ9ackBlZNoc8HV/\n\tWLXP05Ehy1nS6RuaEIwEQ+SmjSI2l+4SL9I+vg7iCx3X3pEVtEU7OYXbqY3ffxGvFi\n\teZCguK/iHPYNg==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1653433105;\n\tbh=6snE1bRh0/Y/freE7UR3RHw585z+/5KDONypF6MBOh0=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=b81PIlm6uxTR5CUNGqnCdhSxrLpWcnKrDZhY4WvoVDESwisKH0jeMUa59brEcjuJr\n\tyfL+yIHp0AY6FjQjqKqrTw2DQy/h2DH9MI5r3Da0Q3sNxBs6RMb3wc6SfX6WnrjwgL\n\t8g5U8aBcazNN/7/1dDx5qx0x/n1uxHH6WhP+S4+M=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"b81PIlm6\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 25 May 2022 01:58:06 +0300", "Message-Id": "<20220524225816.6830-3-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 02/12] libcamera: yaml_parser: Extend\n\tYamlObject::size() to dictionaries", "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": "Dictionaries have a size too, extend the size() function to support\nthem.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/internal/yaml_parser.h | 3 +-\n src/libcamera/yaml_parser.cpp | 42 +++++++++++++-----------\n test/yaml-parser.cpp | 5 +++\n 3 files changed, 30 insertions(+), 20 deletions(-)", "diff": "diff --git a/include/libcamera/internal/yaml_parser.h b/include/libcamera/internal/yaml_parser.h\nindex e002fcf59278..b4f852b1ce54 100644\n--- a/include/libcamera/internal/yaml_parser.h\n+++ b/include/libcamera/internal/yaml_parser.h\n@@ -39,6 +39,8 @@ public:\n \t\treturn type_ == Type::Dictionary;\n \t}\n \n+\tstd::size_t size() const;\n+\n #ifndef __DOXYGEN__\n \ttemplate<typename T,\n \t\t typename std::enable_if_t<\n@@ -53,7 +55,6 @@ public:\n #endif\n \tT get(const T &defaultValue, bool *ok = nullptr) const;\n \n-\tstd::size_t size() const;\n \tconst YamlObject &operator[](std::size_t index) const;\n \n \tbool contains(const std::string &key) const;\ndiff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp\nindex 4b5ea427bf45..5b872dbb0a2d 100644\n--- a/src/libcamera/yaml_parser.cpp\n+++ b/src/libcamera/yaml_parser.cpp\n@@ -74,6 +74,29 @@ YamlObject::~YamlObject() = default;\n * \\return True if the YamlObject is a dictionary, false otherwise\n */\n \n+/**\n+ * \\fn YamlObject::size()\n+ * \\brief Retrieve the number of elements in a dictionary or list YamlObject\n+ *\n+ * This function retrieves the size of the YamlObject, defined as the number of\n+ * child elements it contains. Only YamlObject instances of Dictionary or List\n+ * types have a size, calling this function on other types of instances is\n+ * invalid and results in undefined behaviour.\n+ *\n+ * \\return The size of the YamlObject\n+ */\n+std::size_t YamlObject::size() const\n+{\n+\tswitch (type_) {\n+\tcase Type::Dictionary:\n+\t\treturn dictionary_.size();\n+\tcase Type::List:\n+\t\treturn list_.size();\n+\tdefault:\n+\t\treturn 0;\n+\t}\n+}\n+\n /**\n * \\fn template<typename T> YamlObject::get<T>(\n *\tconst T &defaultValue, bool *ok) const\n@@ -235,25 +258,6 @@ Size YamlObject::get(const Size &defaultValue, bool *ok) const\n \n #endif /* __DOXYGEN__ */\n \n-/**\n- * \\fn YamlObject::size()\n- * \\brief Retrieve the number of elements in a list YamlObject\n- *\n- * This function retrieves the size of the YamlObject, defined as the number of\n- * child elements it contains. Only YamlObject instances of List type have a\n- * size, calling this function on other types of instances is invalid and\n- * results in undefined behaviour.\n- *\n- * \\return The size of the YamlObject\n- */\n-std::size_t YamlObject::size() const\n-{\n-\tif (type_ != Type::List)\n-\t\treturn 0;\n-\n-\treturn list_.size();\n-}\n-\n /**\n * \\fn YamlObject::operator[](std::size_t index) const\n * \\brief Retrieve the element from list YamlObject by index\ndiff --git a/test/yaml-parser.cpp b/test/yaml-parser.cpp\nindex 652adf53d0cc..585b545b71c5 100644\n--- a/test/yaml-parser.cpp\n+++ b/test/yaml-parser.cpp\n@@ -421,6 +421,11 @@ protected:\n \t\t\treturn TestFail;\n \t\t}\n \n+\t\tif (dictObj.size() != 3) {\n+\t\t\tcerr << \"Dictionary object parse with wrong size\" << std::endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n \t\tauto memeberNames = dictObj.memberNames();\n \t\tsort(memeberNames.begin(), memeberNames.end());\n \n", "prefixes": [ "libcamera-devel", "RFC", "02/12" ] }