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

Use string.hh where relevant.

parent 23c7ef8e
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "hpp/util/factories/sequence.hh" #include "hpp/util/factories/sequence.hh"
#include <boost/algorithm/string.hpp> #include <hpp/util/string.hh>
#include <iostream> #include <iostream>
#include "hpp/util/debug.hh" #include "hpp/util/debug.hh"
...@@ -98,22 +98,17 @@ namespace hpp { ...@@ -98,22 +98,17 @@ namespace hpp {
{ {
values_.clear (); values_.clear ();
std::string t(text->Value ()); std::string t(text->Value ());
typedef std::list<std::string> StringList; typedef std::vector<std::string> strings_t;
StringList values; strings_t values = string_split(t.begin(), t.end(), " \n\t\r");
auto end = std::remove(values.begin(), values.end(), std::string());
boost::algorithm::split (values, t, values.erase(end, values.end());
boost::algorithm::is_any_of (" \n\t\r"), if (size_ > 0 && values.size () != size_)
boost::algorithm::token_compress_on);
values.remove_if (StringIsEmpty());
if (size_ > 0 && values.size () != size_) {
throw std::invalid_argument ("Wrong sequence size"); throw std::invalid_argument ("Wrong sequence size");
}
ValueType v; ValueType v;
for (StringList::const_iterator it = values.begin (); for (const std::string s : values) {
it != values.end (); it++) { if (!cast <ValueType> (s, &v)) {
if (!cast <ValueType> (*it, &v)) { hppDout (error, "could not parse value "<< s);
hppDout (error, "could not parse value "<< *it);
} }
values_.push_back (v); values_.push_back (v);
} }
......
...@@ -20,9 +20,10 @@ ...@@ -20,9 +20,10 @@
#include "hpp/util/version.hh" #include "hpp/util/version.hh"
#include <string> #include <string>
#include <assert.h>
#include <vector> #include <vector>
#include <boost/algorithm/string.hpp> #include <hpp/util/string.hh>
namespace hpp namespace hpp
{ {
...@@ -32,11 +33,10 @@ namespace hpp ...@@ -32,11 +33,10 @@ namespace hpp
int checkVersion (const char* header_version) int checkVersion (const char* header_version)
{ {
std::vector<std::string> headerVersion; std::vector<std::string> headerVersion
std::vector<std::string> libraryVersion; = string_split(header_version, header_version+std::strlen(header_version), '.');
std::vector<std::string> libraryVersion
boost::split (headerVersion, header_version, boost::is_any_of(".")); = string_split(version, version+std::strlen(version), '.');
boost::split (libraryVersion, version, boost::is_any_of("."));
long unsigned s = std::max (headerVersion.size (), long unsigned s = std::max (headerVersion.size (),
libraryVersion.size ()); libraryVersion.size ());
...@@ -46,10 +46,8 @@ namespace hpp ...@@ -46,10 +46,8 @@ namespace hpp
assert (headerVersion.size () == libraryVersion.size ()); assert (headerVersion.size () == libraryVersion.size ());
for (long unsigned i = 0; i < s; ++i) for (long unsigned i = 0; i < s; ++i)
{ if (headerVersion != libraryVersion)
if (headerVersion != libraryVersion) return (headerVersion > libraryVersion) ? -1 : 1;
return (headerVersion > libraryVersion) ? -1 : 1;
}
return 0; return 0;
} }
} // end of namespace util. } // end of namespace util.
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <iostream> #include <iostream>
#include <hpp/util/debug.hh> #include <hpp/util/debug.hh>
#include <hpp/util/version.hh>
#include "common.hh" #include "common.hh"
...@@ -27,7 +28,9 @@ int run_test (); ...@@ -27,7 +28,9 @@ int run_test ();
int run_test () int run_test ()
{ {
return 0; if (hpp::util::checkVersion(HPP_UTIL_VERSION) != 0)
return TEST_FAILED;
return TEST_SUCCEED;
} }
GENERATE_TEST () 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