From patchwork Wed Aug 10 13:58:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: alexandros.frantzis@linaro.org X-Patchwork-Id: 3374 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 7FC7F23F46 for ; Wed, 10 Aug 2011 13:58:24 +0000 (UTC) Received: from mail-qy0-f173.google.com (mail-qy0-f173.google.com [209.85.216.173]) by fiordland.canonical.com (Postfix) with ESMTP id 38D5CA18261 for ; Wed, 10 Aug 2011 13:58:24 +0000 (UTC) Received: by qyk31 with SMTP id 31so3277463qyk.11 for ; Wed, 10 Aug 2011 06:58:23 -0700 (PDT) Received: by 10.229.183.84 with SMTP id cf20mr6310494qcb.121.1312984703630; Wed, 10 Aug 2011 06:58:23 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.229.190.71 with SMTP id dh7cs81760qcb; Wed, 10 Aug 2011 06:58:23 -0700 (PDT) Received: from mr.google.com ([10.227.28.96]) by 10.227.28.96 with SMTP id l32mr9479984wbc.50.1312984702627 (num_hops = 1); Wed, 10 Aug 2011 06:58:22 -0700 (PDT) Received: by 10.227.28.96 with SMTP id l32mr6963574wbc.50.1312984701615; Wed, 10 Aug 2011 06:58:21 -0700 (PDT) Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by mx.google.com with ESMTP id ev21si692750wbb.3.2011.08.10.06.58.21; Wed, 10 Aug 2011 06:58:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) client-ip=91.189.90.139; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) smtp.mail=bounces@canonical.com Received: from loganberry.canonical.com ([91.189.90.37]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1Qr9Ia-0004nZ-Ry for ; Wed, 10 Aug 2011 13:58:20 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id D09202E8005 for ; Wed, 10 Aug 2011 13:58:20 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: glmark2 X-Launchpad-Branch: ~glmark2-dev/glmark2/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 118 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~glmark2-dev/glmark2/trunk] Rev 118: Move the string split() function to a separate Util module. Message-Id: <20110810135820.1453.95436.launchpad@loganberry.canonical.com> Date: Wed, 10 Aug 2011 13:58:20 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="13636"; Instance="initZopeless config overlay" X-Launchpad-Hash: f616a023adea9ca4e94ec34f70be018021d3e12a ------------------------------------------------------------ revno: 118 committer: Alexandros Frantzis branch nick: trunk timestamp: Tue 2011-08-09 13:34:49 +0300 message: Move the string split() function to a separate Util module. added: src/util.cpp src/util.h modified: src/benchmark.cpp src/scene-effect-2d.cpp --- lp:glmark2 https://code.launchpad.net/~glmark2-dev/glmark2/trunk You are subscribed to branch lp:glmark2. To unsubscribe from this branch go to https://code.launchpad.net/~glmark2-dev/glmark2/trunk/+edit-subscription === modified file 'src/benchmark.cpp' --- src/benchmark.cpp 2011-06-09 14:07:23 +0000 +++ src/benchmark.cpp 2011-08-09 10:34:49 +0000 @@ -22,7 +22,7 @@ #include "benchmark.h" #include "log.h" -#include +#include "util.h" using std::string; using std::vector; @@ -30,22 +30,12 @@ std::map Benchmark::mSceneMap; -static void -split(const string &s, char delim, vector &elems) -{ - std::stringstream ss(s); - - string item; - while(std::getline(ss, item, delim)) - elems.push_back(item); -} - static Scene & get_scene_from_description(const string &s) { vector elems; - split(s, ':', elems); + Util::split(s, ':', elems); const string &name = !elems.empty() ? elems[0] : ""; @@ -58,7 +48,7 @@ vector options; vector elems; - split(s, ':', elems); + Util::split(s, ':', elems); for (vector::const_iterator iter = ++elems.begin(); iter != elems.end(); @@ -66,7 +56,7 @@ { vector opt; - split(*iter, '=', opt); + Util::split(*iter, '=', opt); if (opt.size() == 2) options.push_back(Benchmark::OptionPair(opt[0], opt[1])); else === modified file 'src/scene-effect-2d.cpp' --- src/scene-effect-2d.cpp 2011-08-02 16:01:29 +0000 +++ src/scene-effect-2d.cpp 2011-08-09 10:34:49 +0000 @@ -30,6 +30,7 @@ #include "log.h" #include "program.h" #include "shader-source.h" +#include "util.h" SceneEffect2D::SceneEffect2D(Canvas &pCanvas) : @@ -169,23 +170,6 @@ } /** - * Splits a string using a delimiter - * - * @param s the string to split - * @param delim the delimitir to use - * @param elems the string vector to populate - */ -static void -split(const std::string &s, char delim, std::vector &elems) -{ - std::stringstream ss(s); - - std::string item; - while(std::getline(ss, item, delim)) - elems.push_back(item); -} - -/** * Parses a string representation of a matrix and returns it * in row-major format. * @@ -207,7 +191,7 @@ std::vector rows; unsigned int w = UINT_MAX; - split(str, ';', rows); + Util::split(str, ';', rows); Log::debug("Parsing kernel matrix:\n"); @@ -216,7 +200,7 @@ iter++) { std::vector elems; - split(*iter, ',', elems); + Util::split(*iter, ',', elems); if (w != UINT_MAX && elems.size() != w) { Log::error("Matrix row %u contains %u elements, whereas previous" === added file 'src/util.cpp' --- src/util.cpp 1970-01-01 00:00:00 +0000 +++ src/util.cpp 2011-08-09 10:34:49 +0000 @@ -0,0 +1,44 @@ +/* + * Copyright © 2011 Linaro Limited + * + * This file is part of glcompbench. + * + * glcompbench is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * glcompbench is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with glcompbench. If not, see . + * + * Authors: + * Alexandros Frantzis + * Jesse Barker + */ + +#include + +#include "util.h" + +/** + * Splits a string using a delimiter + * + * @param s the string to split + * @param delim the delimitir to use + * @param elems the string vector to populate + */ +void +Util::split(const std::string &s, char delim, std::vector &elems) +{ + std::stringstream ss(s); + + std::string item; + while(std::getline(ss, item, delim)) + elems.push_back(item); +} + === added file 'src/util.h' --- src/util.h 1970-01-01 00:00:00 +0000 +++ src/util.h 2011-08-09 10:34:49 +0000 @@ -0,0 +1,34 @@ +/* + * Copyright © 2011 Linaro Limited + * + * This file is part of glcompbench. + * + * glcompbench is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * glcompbench is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with glcompbench. If not, see . + * + * Authors: + * Alexandros Frantzis + * Jesse Barker + */ + +#ifndef UTIL_H_ +#define UTIL_H_ + +#include +#include + +struct Util { + static void split(const std::string &s, char delim, std::vector &elems); +}; + +#endif /* UTIL_H */