Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Guilhem Saurel
hpp-util
Commits
742dede3
Commit
742dede3
authored
Dec 17, 2020
by
Joseph Mirabel
Browse files
Use string.hh where relevant.
parent
23c7ef8e
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/factories/sequence.cc
View file @
742dede3
...
...
@@ -16,7 +16,7 @@
#include "hpp/util/factories/sequence.hh"
#include <
boost/algorithm
/string.h
pp
>
#include <
hpp/util
/string.h
h
>
#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
);
}
...
...
src/version.cc
View file @
742dede3
...
...
@@ -20,9 +20,10 @@
#include "hpp/util/version.hh"
#include <string>
#include <assert.h>
#include <vector>
#include <
boost/algorithm
/string.h
pp
>
#include <
hpp/util
/string.h
h
>
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.
...
...
tests/simple-test.cc
View file @
742dede3
...
...
@@ -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
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment