=== modified file 'src/benchmark.cpp'
@@ -22,7 +22,7 @@
#include "benchmark.h"
#include "log.h"
-#include <sstream>
+#include "util.h"
using std::string;
using std::vector;
@@ -30,22 +30,12 @@
std::map<string, Scene *> Benchmark::mSceneMap;
-static void
-split(const string &s, char delim, vector<string> &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<string> elems;
- split(s, ':', elems);
+ Util::split(s, ':', elems);
const string &name = !elems.empty() ? elems[0] : "";
@@ -58,7 +48,7 @@
vector<Benchmark::OptionPair> options;
vector<string> elems;
- split(s, ':', elems);
+ Util::split(s, ':', elems);
for (vector<string>::const_iterator iter = ++elems.begin();
iter != elems.end();
@@ -66,7 +56,7 @@
{
vector<string> 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'
@@ -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<std::string> &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<std::string> 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<std::string> 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'
@@ -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 <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Alexandros Frantzis <alexandros.frantzis@linaro.org>
+ * Jesse Barker <jesse.barker@linaro.org>
+ */
+
+#include <sstream>
+
+#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<std::string> &elems)
+{
+ std::stringstream ss(s);
+
+ std::string item;
+ while(std::getline(ss, item, delim))
+ elems.push_back(item);
+}
+
=== added file 'src/util.h'
@@ -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 <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Alexandros Frantzis <alexandros.frantzis@linaro.org>
+ * Jesse Barker <jesse.barker@linaro.org>
+ */
+
+#ifndef UTIL_H_
+#define UTIL_H_
+
+#include <string>
+#include <vector>
+
+struct Util {
+ static void split(const std::string &s, char delim, std::vector<std::string> &elems);
+};
+
+#endif /* UTIL_H */