{"id":16167,"url":"https://patchwork.libcamera.org/api/1.1/patches/16167/?format=json","web_url":"https://patchwork.libcamera.org/patch/16167/","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-13-laurent.pinchart@ideasonboard.com>","date":"2022-06-04T18:59:37","name":"[libcamera-devel,RFC,v2,12/14] libcamera: yaml_parser: Add get() specializations for 16-bit integers","commit_ref":null,"pull_url":null,"state":"rfc","archived":false,"hash":"6cc7fccb79f966700e8ede3057bf52a8ebac229d","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/16167/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/16167/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16167/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 7329EC327C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat,  4 Jun 2022 19:00:19 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0E2E06563F;\n\tSat,  4 Jun 2022 21:00:19 +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 9A3A165644\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  4 Jun 2022 21:00:17 +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 662F36D4;\n\tSat,  4 Jun 2022 21:00:16 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1654369219;\n\tbh=TqHiVr4QGQxzOpjf0XHtdsxLe3op6/BtgX5oVoQx3UM=;\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=lBmfT72x//xbgBDzpesbhnZVgzzX5SnARlpCI9THg8drZxqpLXdi1TZcGjfroXXoa\n\tfmKwulcaMtN8LZLYWnlNDbySIeH1KzrBXzUmF3LCIaRs/JzkmqbmSmpMFLag3U9K4z\n\tMpkfoUqDsejxVPIRRvni4I2DP0sOv9yO2mlMCchxL8fYvpBYIIrZHdXDnGTKTUto5L\n\tf+l2wkACqF4C/18w2aB1KJulrpVlRJpDHFWobNs3nZQ0UWpIG4wT5uCyWWEuY/yEgq\n\tAyebuxqBKD4lEhfssk9QcXpGidWvNnTjT1BW8AR/phhHboERzQR9pnTJ/GW5Ysai9l\n\t8GxZz4nFOV6Lg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1654369217;\n\tbh=TqHiVr4QGQxzOpjf0XHtdsxLe3op6/BtgX5oVoQx3UM=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=EyHhAKPIqo9QWObfkxWrGc54i9Lxh6zwzRT5YpXEX+vRt1DKSW5Sq6I40xeoUbHsA\n\tHlbPSnPFafGT4pFh8r9Ey26NcrOKaY3H21FzQYKXo3osZ+baseo/aVsHV/6eNamF2H\n\tofgtQoJtPvIorATAU/GJwFrjLOPTXkR97fMULsS4="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"EyHhAKPI\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Sat,  4 Jun 2022 21:59:37 +0300","Message-Id":"<20220604185939.29163-13-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 12/14] libcamera: yaml_parser: Add\n\tget() specializations for 16-bit integers","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":"Extend the YamlObject::get() function template to support 16-bit\nintegers.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/internal/yaml_parser.h |  2 +\n src/libcamera/yaml_parser.cpp            | 61 ++++++++++++++++++++++++\n 2 files changed, 63 insertions(+)","diff":"diff --git a/include/libcamera/internal/yaml_parser.h b/include/libcamera/internal/yaml_parser.h\nindex d0ddb5f682b2..eebfff2c8a8a 100644\n--- a/include/libcamera/internal/yaml_parser.h\n+++ b/include/libcamera/internal/yaml_parser.h\n@@ -163,6 +163,8 @@ public:\n \t\t typename std::enable_if_t<\n \t\t\t std::is_same<bool, T>::value ||\n \t\t\t std::is_same<double, T>::value ||\n+\t\t\t std::is_same<int16_t, T>::value ||\n+\t\t\t std::is_same<uint16_t, T>::value ||\n \t\t\t std::is_same<int32_t, T>::value ||\n \t\t\t std::is_same<uint32_t, T>::value ||\n \t\t\t std::is_same<std::string, T>::value ||\ndiff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp\nindex 3fb6fec695ee..3faebe61d338 100644\n--- a/src/libcamera/yaml_parser.cpp\n+++ b/src/libcamera/yaml_parser.cpp\n@@ -137,6 +137,67 @@ bool YamlObject::get(const bool &defaultValue, bool *ok) const\n \treturn defaultValue;\n }\n \n+template<>\n+int16_t YamlObject::get(const int16_t &defaultValue, bool *ok) const\n+{\n+\tsetOk(ok, false);\n+\n+\tif (type_ != Type::Value)\n+\t\treturn defaultValue;\n+\n+\tif (value_ == \"\")\n+\t\treturn defaultValue;\n+\n+\tchar *end;\n+\n+\terrno = 0;\n+\tint16_t value = std::strtol(value_.c_str(), &end, 10);\n+\n+\tif ('\\0' != *end || errno == ERANGE ||\n+\t    value < std::numeric_limits<int16_t>::min() ||\n+\t    value > std::numeric_limits<int16_t>::max())\n+\t\treturn defaultValue;\n+\n+\tsetOk(ok, true);\n+\treturn value;\n+}\n+\n+template<>\n+uint16_t YamlObject::get(const uint16_t &defaultValue, bool *ok) const\n+{\n+\tsetOk(ok, false);\n+\n+\tif (type_ != Type::Value)\n+\t\treturn defaultValue;\n+\n+\tif (value_ == \"\")\n+\t\treturn defaultValue;\n+\n+\t/*\n+\t * libyaml parses all scalar values as strings. When a string has\n+\t * leading spaces before a minus sign, for example \"  -10\", strtoul\n+\t * skips leading spaces, accepts the leading minus sign, and the\n+\t * calculated digits are negated as if by unary minus. Rule it out in\n+\t * case the user gets a large number when the value is negative.\n+\t */\n+\tstd::size_t found = value_.find_first_not_of(\" \\t\");\n+\tif (found != std::string::npos && value_[found] == '-')\n+\t\treturn defaultValue;\n+\n+\tchar *end;\n+\n+\terrno = 0;\n+\tuint16_t value = std::strtoul(value_.c_str(), &end, 10);\n+\n+\tif ('\\0' != *end || errno == ERANGE ||\n+\t    value < std::numeric_limits<uint16_t>::min() ||\n+\t    value > std::numeric_limits<uint16_t>::max())\n+\t\treturn defaultValue;\n+\n+\tsetOk(ok, true);\n+\treturn value;\n+}\n+\n template<>\n int32_t YamlObject::get(const int32_t &defaultValue, bool *ok) const\n {\n","prefixes":["libcamera-devel","RFC","v2","12/14"]}