Commit 742dede3 authored by Joseph Mirabel's avatar Joseph Mirabel
Browse files

Use string.hh where relevant.

parent 23c7ef8e
Pipeline #14083 passed with stage
in 1 minute and 44 seconds
......@@ -16,7 +16,7 @@
#include "hpp/util/factories/sequence.hh"
#include <boost/algorithm/string.hpp>
#include <hpp/util/string.hh>
#include <iostream>
#include "hpp/util/debug.hh"
......@@ -98,22 +98,17 @@ namespace hpp {
{
values_.clear ();
std::string t(text->Value ());
typedef std::list<std::string> StringList;
StringList values;
boost::algorithm::split (values, t,
boost::algorithm::is_any_of (" \n\t\r"),
boost::algorithm::token_compress_on);
values.remove_if (StringIsEmpty());
if (size_ > 0 && values.size () != size_) {
typedef std::vector<std::string> strings_t;
strings_t values = string_split(t.begin(), t.end(), " \n\t\r");
auto end = std::remove(values.begin(), values.end(), std::string());
values.erase(end, values.end());
if (size_ > 0 && values.size () != size_)
throw std::invalid_argument ("Wrong sequence size");
}
ValueType v;
for (StringList::const_iterator it = values.begin ();
it != values.end (); it++) {
if (!cast <ValueType> (*it, &v)) {
hppDout (error, "could not parse value "<< *it);
for (const std::string s : values) {
if (!cast <ValueType> (s, &v)) {
hppDout (error, "could not parse value "<< s);
}
values_.push_back (v);
}
......
......@@ -20,9 +20,10 @@
#include "hpp/util/version.hh"
#include <string>
#include <assert.h>
#include <vector>
#include <boost/algorithm/string.hpp>
#include <hpp/util/string.hh>
namespace hpp
{
......@@ -32,11 +33,10 @@ namespace hpp
int checkVersion (const char* header_version)
{
std::vector<std::string> headerVersion;
std::vector<std::string> libraryVersion;
boost::split (headerVersion, header_version, boost::is_any_of("."));
boost::split (libraryVersion, version, boost::is_any_of("."));
std::vector<std::string> headerVersion
= string_split(header_version, header_version+std::strlen(header_version), '.');
std::vector<std::string> libraryVersion
= string_split(version, version+std::strlen(version), '.');
long unsigned s = std::max (headerVersion.size (),
libraryVersion.size ());
......@@ -46,10 +46,8 @@ namespace hpp
assert (headerVersion.size () == libraryVersion.size ());
for (long unsigned i = 0; i < s; ++i)
{
if (headerVersion != libraryVersion)
return (headerVersion > libraryVersion) ? -1 : 1;
}
if (headerVersion != libraryVersion)
return (headerVersion > libraryVersion) ? -1 : 1;
return 0;
}
} // end of namespace util.
......
......@@ -19,6 +19,7 @@
#include <iostream>
#include <hpp/util/debug.hh>
#include <hpp/util/version.hh>
#include "common.hh"
......@@ -27,7 +28,9 @@ int run_test ();
int run_test ()
{
return 0;
if (hpp::util::checkVersion(HPP_UTIL_VERSION) != 0)
return TEST_FAILED;
return TEST_SUCCEED;
}
GENERATE_TEST ()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment