Show a patch.

GET /api/1.1/patches/15700/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 15700,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/15700/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/15700/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/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": "<20220421172549.138360-1-utkarsh02t@gmail.com>",
    "date": "2022-04-21T17:25:48",
    "name": "[libcamera-devel,1/2] Support float data type in options",
    "commit_ref": null,
    "pull_url": null,
    "state": "rejected",
    "archived": false,
    "hash": "cfb2fd1faa2e49d591b9eb37be607f40c099dbfe",
    "submitter": {
        "id": 114,
        "url": "https://patchwork.libcamera.org/api/1.1/people/114/?format=api",
        "name": "Utkarsh Tiwari",
        "email": "utkarsh02t@gmail.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/15700/mbox/",
    "series": [
        {
            "id": 3065,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3065/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3065",
            "date": "2022-04-21T17:25:48",
            "name": "[libcamera-devel,1/2] Support float data type in options",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/3065/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/15700/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/15700/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 C69EDC3256\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 21 Apr 2022 17:26:10 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 25C8865644;\n\tThu, 21 Apr 2022 19:26:10 +0200 (CEST)",
            "from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com\n\t[IPv6:2607:f8b0:4864:20::1032])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C9118604AE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 21 Apr 2022 19:26:08 +0200 (CEST)",
            "by mail-pj1-x1032.google.com with SMTP id\n\tga4-20020a17090b038400b001d4b33c74ccso4451976pjb.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 21 Apr 2022 10:26:08 -0700 (PDT)",
            "from localhost.localdomain ([2404:bd00:3:db75:9357:7a99:9595:33ae])\n\tby smtp.gmail.com with ESMTPSA id\n\tiy2-20020a17090b16c200b001d75aabe050sm1080174pjb.34.2022.04.21.10.26.05\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 21 Apr 2022 10:26:06 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1650561970;\n\tbh=+urxSG/E5xvwO2xYJBZRCVQxtKl08cBhx9+Mfj7iAOU=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:Cc:From;\n\tb=T5QBD0YrjLiCuq8U82FO85os1g55zCJKj3DyVN1ozQraTzpxfLmzbtX66TNORrl28\n\tVEqBQlzqs4aHCbXwe18NGHftwSziBnGcU5/F9kHlJ8/1+bdHq+htfCoPrPekBm65q/\n\tUfXNqGLQa2cyTAXoVXsilu3N3UDoDVDiYwIpLUb/mgMcEklvwtl7np/y4QeKe1CGF0\n\t8illYDa1EChgyTxvRtUi13BpiYsGIGEHCQVeaDzxoM+I6PH4zp1h7Y4DhHOdpG3Mge\n\tC8hQGDtdz5U55kShOKkFAaORLdarLIr6mWOaMhpHgdhdUBcb1avmPQRxRxZAApunYy\n\tdtoG4z2xAVmhA==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=X0ZT5Pa+tAD/jLffaQn9PdWfu656Nph7ctdc2G4fb38=;\n\tb=Jw268Wp45T0FloBcLF73JI0SW2vqxlaWVVQHb5oEGkdX5dGHEh2SGPxCsBV0H3NiKc\n\tcUFCtAUP8crG4czsPOCIGpx7F+fANpB4uedmS8a0JHHldoEJgNjh+SL79mx7xG/fOWhN\n\tvrUDHyqsbCSgXKNHrt7F7ClDRUgigYB4DIoDvXarfqP/W4szBvkZ7tvBo/E9b6M/wtz4\n\t9wblWZ9unY61bt+BR5ndGmHSQ+Mo4Oq5r43QQIleRbSnOO7xHHmPHfP0DylMi6VTAQ56\n\tp1I5ZlNCNW0sevMSxGql//Ov90ibG3Z3JqxNdo0KTzm+/65aLrazju7vIwJocBA6g+em\n\tlj1Q=="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"Jw268Wp4\"; dkim-atps=neutral",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=X0ZT5Pa+tAD/jLffaQn9PdWfu656Nph7ctdc2G4fb38=;\n\tb=yp3k5gcGMQYXoNKR1CdUwDGKxPrcJSKMRU05Pnk/HKtoACHbRKSEKkFDOGP6serkhs\n\tCTEi6RGkUyzvflzF0NojTInw5KV8rlZ0laG5zN1hUw026Jqxy8JOyNFhC4XicxeJAwaA\n\t5DTuAGwmji4czaJTBM488ZM3eHf+hIxWMLMPX9OrOXdVDuh/pOlwZEqnk6Kl1396yYuK\n\tDiiQoA10LYb7Ot6viVMxWv6kDQJxx42ibQLCU0CxKB+GaYVdkoufjnz4qfOcqkUngrIx\n\tqQAiPb3sGlThxoaUsDvHdumu77iMIY91+ft6v0CbsW1zi7SjB0B7zFYdpy6u6C3+aVPI\n\tTKGQ==",
        "X-Gm-Message-State": "AOAM532uukPYFGHIQGk1PLmdO2wnigkSVfY5/i9BElS81WB3uTJNCT0g\n\tl2NpblrJ+UBXr5s6XlKgJPIIdab6Cps9Eg==",
        "X-Google-Smtp-Source": "ABdhPJxA2jSj/sy4weAUwj1ZhKAmH8gcChLWRAwlVcXI+ulwmBxwRJEinUGtRDu7O8bPyb1kuDYx+g==",
        "X-Received": "by 2002:a17:903:1205:b0:151:8ae9:93ea with SMTP id\n\tl5-20020a170903120500b001518ae993eamr461023plh.37.1650561966865; \n\tThu, 21 Apr 2022 10:26:06 -0700 (PDT)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 21 Apr 2022 22:55:48 +0530",
        "Message-Id": "<20220421172549.138360-1-utkarsh02t@gmail.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 1/2] Support float data type in options",
        "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": "Utkarsh Tiwari via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Utkarsh Tiwari <utkarsh02t@gmail.com>",
        "Cc": "Utkarsh Tiwari <utkarsh02t@gmail.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "---\n src/cam/options.cpp | 65 +++++++++++++++++++++++++++++++++++++++++++--\n src/cam/options.h   |  6 +++++\n 2 files changed, 69 insertions(+), 2 deletions(-)",
    "diff": "diff --git a/src/cam/options.cpp b/src/cam/options.cpp\nindex 4f7e8691..759328fc 100644\n--- a/src/cam/options.cpp\n+++ b/src/cam/options.cpp\n@@ -6,9 +6,11 @@\n  */\n \n #include <assert.h>\n+#include <cmath>\n #include <getopt.h>\n #include <iomanip>\n #include <iostream>\n+#include <limits>\n #include <string.h>\n \n #include \"options.h\"\n@@ -43,6 +45,9 @@\n  *\n  * \\var OptionType::OptionKeyValue\n  * \\brief key=value list argument\n+ *\n+ * \\var OptionType::OptionFloat\n+ * \\brief Float argument\n  */\n \n /* -----------------------------------------------------------------------------\n@@ -129,6 +134,9 @@ const char *Option::typeName() const\n \n \tcase OptionKeyValue:\n \t\treturn \"key=value\";\n+\n+\tcase OptionFloat:\n+\t\treturn \"float\";\n \t}\n \n \treturn \"unknown\";\n@@ -256,14 +264,14 @@ bool OptionsBase<T>::parseValue(const T &opt, const Option &option,\n \t\t\tinteger = 0;\n \t\t}\n \n-\t\tvalue = OptionValue(integer);\n+\t\tvalue = OptionValue(static_cast<int>(integer));\n \t\tbreak;\n \n \tcase OptionString:\n \t\tvalue = OptionValue(arg ? arg : \"\");\n \t\tbreak;\n \n-\tcase OptionKeyValue:\n+\tcase OptionKeyValue: {\n \t\tKeyValueParser *kvParser = option.keyValueParser;\n \t\tKeyValueParser::Options keyValues = kvParser->parse(arg);\n \t\tif (!keyValues.valid())\n@@ -273,6 +281,21 @@ bool OptionsBase<T>::parseValue(const T &opt, const Option &option,\n \t\tbreak;\n \t}\n \n+\tcase OptionFloat:\n+\t\tfloat float_val;\n+\n+\t\tif (arg) {\n+\t\t\tchar *endptr;\n+\t\t\tfloat_val = strtof(arg, &endptr);\n+\t\t\tif (*endptr != '\\0' || !std::isfinite(float_val))\n+\t\t\t\treturn false;\n+\t\t} else {\n+\t\t\tfloat_val = 0;\n+\t\t}\n+\t\tvalue = OptionValue(float_val);\n+\t\tbreak;\n+\t}\n+\n \tif (option.isArray)\n \t\tvalues_[opt].addValue(value);\n \telse\n@@ -283,6 +306,7 @@ bool OptionsBase<T>::parseValue(const T &opt, const Option &option,\n \n template class OptionsBase<int>;\n template class OptionsBase<std::string>;\n+template class OptionsBase<float>;\n \n /* -----------------------------------------------------------------------------\n  * KeyValueParser\n@@ -505,6 +529,9 @@ void KeyValueParser::usage(int indent)\n  *\n  * \\var OptionValue::ValueType::ValueArray\n  * \\brief Array value\n+ *\n+ * \\var OptionValue::ValueType::ValueFloat\n+ * \\brief Float value (float)\n  */\n \n /**\n@@ -561,6 +588,17 @@ OptionValue::OptionValue(const KeyValueParser::Options &value)\n {\n }\n \n+/**\n+ * \\brief Construct an float OptionValue instance\n+ * \\param[in] value The float value\n+ *\n+ * The value type is set to ValueType::ValueFloat.\n+ */\n+OptionValue::OptionValue(const float value)\n+\t: type_(ValueFloat), integer_(0), float_(value)\n+{\n+}\n+\n /**\n  * \\brief Add an entry to an array value\n  * \\param[in] value The entry value\n@@ -600,6 +638,16 @@ OptionValue::operator int() const\n \treturn toInteger();\n }\n \n+/**\n+ * \\brief Cast the value to an int\n+ * \\return The option value as an int, or 0 if the value type isn't\n+ * ValueType::ValueInteger\n+ */\n+OptionValue::operator float() const\n+{\n+\treturn toFloat();\n+}\n+\n /**\n  * \\brief Cast the value to a std::string\n  * \\return The option value as an std::string, or an empty string if the value\n@@ -662,6 +710,19 @@ const std::vector<OptionValue> &OptionValue::toArray() const\n \treturn array_;\n }\n \n+/**\n+ * \\brief Retrieve the value as an float\n+ * \\return The option value as an int, or signaling not-a-number if the value type isn't\n+ * ValueType::ValueFloat\n+ */\n+float OptionValue::toFloat() const\n+{\n+\tif (type_ != ValueFloat)\n+\t\treturn std::numeric_limits<float>::signaling_NaN();\n+\n+\treturn float_;\n+}\n+\n /**\n  * \\brief Retrieve the list of child values\n  * \\return The list of child values\ndiff --git a/src/cam/options.h b/src/cam/options.h\nindex 4ddd4987..f0636f82 100644\n--- a/src/cam/options.h\n+++ b/src/cam/options.h\n@@ -28,6 +28,7 @@ enum OptionType {\n \tOptionInteger,\n \tOptionString,\n \tOptionKeyValue,\n+\tOptionFloat,\n };\n \n template<typename T>\n@@ -124,6 +125,7 @@ public:\n \t\tValueString,\n \t\tValueKeyValue,\n \t\tValueArray,\n+\t\tValueFloat,\n \t};\n \n \tOptionValue();\n@@ -131,6 +133,7 @@ public:\n \tOptionValue(const char *value);\n \tOptionValue(const std::string &value);\n \tOptionValue(const KeyValueParser::Options &value);\n+\tOptionValue(const float value);\n \n \tvoid addValue(const OptionValue &value);\n \n@@ -139,11 +142,13 @@ public:\n \n \toperator int() const;\n \toperator std::string() const;\n+\toperator float() const;\n \n \tint toInteger() const;\n \tstd::string toString() const;\n \tconst KeyValueParser::Options &toKeyValues() const;\n \tconst std::vector<OptionValue> &toArray() const;\n+\tfloat toFloat() const;\n \n \tconst OptionsParser::Options &children() const;\n \n@@ -153,5 +158,6 @@ private:\n \tstd::string string_;\n \tKeyValueParser::Options keyValues_;\n \tstd::vector<OptionValue> array_;\n+\tfloat float_;\n \tOptionsParser::Options children_;\n };\n",
    "prefixes": [
        "libcamera-devel",
        "1/2"
    ]
}