Patch Detail
Show a patch.
GET /api/patches/16157/?format=api
{ "id": 16157, "url": "https://patchwork.libcamera.org/api/patches/16157/?format=api", "web_url": "https://patchwork.libcamera.org/patch/16157/", "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": "<20220604185939.29163-3-laurent.pinchart@ideasonboard.com>", "date": "2022-06-04T18:59:27", "name": "[libcamera-devel,RFC,v2,02/14] libcamera: yaml_parser: Extend YamlObject::size() to dictionaries", "commit_ref": null, "pull_url": null, "state": "rfc", "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/16157/mbox/", "series": [ { "id": 3161, "url": "https://patchwork.libcamera.org/api/series/3161/?format=api", "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/16157/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/16157/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 61F8BC3273\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 4 Jun 2022 19:00:02 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 366A865639;\n\tSat, 4 Jun 2022 21:00:01 +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 0722765632\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 4 Jun 2022 21:00:00 +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 C43EB6D4;\n\tSat, 4 Jun 2022 20:59:58 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1654369201;\n\tbh=nhjLA//4m1HvlSUtXkPDjGURRb36QN5w86OMCpUkbyc=;\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=Uoo1IiCsDxI2iFbQkz82wu18OvOy/l4dMyAFsIhmBbEOdtsWQzEqm3msiMy/xCvEr\n\tlScRHbVJ5VHZmqut1bQ0LltO19fUNz+06ao1hcw4WduzUsOEOwDu1GAnJG7YDtHwm3\n\tBjtYSZ1gQm1mdMhqPRi7CX/rTxCN8mDsL0DqgwT8twomdeEGVJbBqNNIvA1PCEgMGT\n\t0msUKlNSNp8811F09jl5ZdIKEid0XogH5uYzchvrSc3j7J2innVE/gLPDEZmDolmvy\n\tR/haNubhkgumGSKCsF5gyTYxU75Ea7Cu1AuWQyAwAJCQ6nJYXvFa+uwMIp4vuK/Fp6\n\tg9Sli870EIlqA==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1654369199;\n\tbh=nhjLA//4m1HvlSUtXkPDjGURRb36QN5w86OMCpUkbyc=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=XExsG9DYSDtI7Vz6AQMeLM6YAjfU1iw/G50KmjNdeOioNNrI/wQrvRRAXrNWq4OD9\n\tGqPWJ3cDeOqO9by31BnVB8tCtN2sKYiPRQWX6KlhH+6jiO/Ti2SYUqcefoUfY2xlly\n\tTxo8jIvw6wDXAq6oI8jOHynB0rIRDH8bXf1RIgV0=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"XExsG9DY\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Sat, 4 Jun 2022 21:59:27 +0300", "Message-Id": "<20220604185939.29163-3-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 02/14] libcamera: yaml_parser:\n\tExtend YamlObject::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 5315d99fae5d..c5b4ddbb19e5 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", "v2", "02/14" ] }