From patchwork Tue Aug 23 17:43:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17187 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 066FEC0DA4 for ; Tue, 23 Aug 2022 17:43:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9D06761FC6; Tue, 23 Aug 2022 19:43:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1661276604; bh=AIqh8KnQAwpofCVdLbbi6JYWl9cUMSB1QZZKu/dFNTo=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=xQbw+9xpwrxZ9OmWgjcA7CSZGpdyEYEBwHyxbwpazOuWrI/n7LWrUhbb1JI+sV+vc AJ5Q6O3o/nppdLwOZ1iVdETlAN8rWf7wbEAQ3H7b5wGiFVnhG42GiM+qFmX2NwTZ3u ACJjg+jvQIha2P3O375V+iHSODJ3zEvNfi1uhINVSVlNMTCIBWuOOtE6uPjI1mZiR2 cvepVbhtlxi0Hc7tDnAZk9NjW0SVT7gg0A5Mrl+fgQc5xkodPh516frYsykbqx4Zj9 wcCe3wxljJvqL2hUsQXlciaTdnYSouSo9IMDHLuWX6B3dEGPZpHppHxx1IWA7iLX+S a/5CRjmjvV6pg== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 85EE661FA1 for ; Tue, 23 Aug 2022 19:43:21 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="mHbjLnFd"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 147212B3 for ; Tue, 23 Aug 2022 19:43:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1661276601; bh=AIqh8KnQAwpofCVdLbbi6JYWl9cUMSB1QZZKu/dFNTo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mHbjLnFdS22MG60nAjudtxylxa8rd4JZmeDqAskWgozbAXu59ESYflUY3gc8x0Pht Fz8YZGk1jQp5C/k+3hwhNNuETgHNOCuUVB3Ddtkm41lw+XeIl4mYvqBxuAFXFXnUeA 73YAQUutbMGk50hble6ycbHWC7egHSvGIHiNzFHs= To: libcamera-devel@lists.libcamera.org Date: Tue, 23 Aug 2022 20:43:09 +0300 Message-Id: <20220823174314.14881-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220823174314.14881-1-laurent.pinchart@ideasonboard.com> References: <20220823174314.14881-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/6] utils: Satisfy LegacyInputIterator with StringSplitter::iterator X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The StringSplitter::iterator is used with the utils::split() function to iterate over components of a split string. Add the necessary member types expected by std::iterator_trait in order to satisfy the LegacyInputIterator requirement and make the iterator usable in constructors for various containers. Signed-off-by: Laurent Pinchart Reviewed-by: Umang Jain Reviewed-by: Paul Elder --- include/libcamera/base/utils.h | 6 ++++++ test/utils.cpp | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h index 889bb4a2270e..ed88b7163770 100644 --- a/include/libcamera/base/utils.h +++ b/include/libcamera/base/utils.h @@ -170,6 +170,12 @@ public: class iterator { public: + using difference_type = std::size_t; + using value_type = std::string; + using pointer = value_type *; + using reference = value_type &; + using iterator_category = std::input_iterator_tag; + iterator(const StringSplitter *ss, std::string::size_type pos); iterator &operator++(); diff --git a/test/utils.cpp b/test/utils.cpp index 129807a63ec6..58b5a59dd17d 100644 --- a/test/utils.cpp +++ b/test/utils.cpp @@ -276,6 +276,14 @@ protected: return TestFail; } + const auto &split = utils::split(path, ":"); + dirs = std::vector{ split.begin(), split.end() }; + + if (dirs != elements) { + cerr << "utils::split() LegacyInputIterator test failed" << endl; + return TestFail; + } + /* utils::join() with conversion function test. */ std::vector sizes = { { 0, 0 }, { 100, 100 } }; s = utils::join(sizes, "/", [](const Size &size) {