Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Simox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Leander Singer
Simox
Commits
0ef0b185
Commit
0ef0b185
authored
3 years ago
by
Rainer Kartmann
Browse files
Options
Downloads
Patches
Plain Diff
Use qualified name to detect signature mismatch
parent
909f3e26
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
SimoxUtility/algorithm/string/string_tools.cpp
+38
-18
38 additions, 18 deletions
SimoxUtility/algorithm/string/string_tools.cpp
SimoxUtility/algorithm/string/string_tools.h
+24
-10
24 additions, 10 deletions
SimoxUtility/algorithm/string/string_tools.h
with
62 additions
and
28 deletions
SimoxUtility/algorithm/string/string_tools.cpp
+
38
−
18
View file @
0ef0b185
#include
"string_tools.h"
#include
"
SimoxUtility/error/SimoxError.h
"
#include
<
SimoxUtility/error/SimoxError.h
>
#include
<boost/algorithm/string.hpp>
...
...
@@ -9,17 +9,19 @@
#include
<iomanip>
#include
<regex>
namespace
simox
::
alg
namespace
simox
{
std
::
string
to_lower
(
const
std
::
string
&
str
)
std
::
string
alg
::
to_lower
(
const
std
::
string
&
str
)
{
std
::
string
res
=
str
;
std
::
transform
(
res
.
begin
(),
res
.
end
(),
res
.
begin
(),
tolower
);
return
res
;
}
std
::
string
to_upper
(
const
std
::
string
&
str
)
std
::
string
alg
::
to_upper
(
const
std
::
string
&
str
)
{
std
::
string
res
=
str
;
std
::
transform
(
res
.
begin
(),
res
.
end
(),
res
.
begin
(),
toupper
);
...
...
@@ -27,7 +29,7 @@ std::string to_upper(const std::string& str)
}
std
::
string
capitalize_words
(
const
std
::
string
&
str
)
std
::
string
alg
::
capitalize_words
(
const
std
::
string
&
str
)
{
std
::
regex
regex
(
"
\\
s[a-z]"
);
std
::
stringstream
result
;
...
...
@@ -55,23 +57,33 @@ std::string capitalize_words(const std::string& str)
}
void
trim
(
std
::
string
&
str
,
const
std
::
locale
&
locale
)
{
void
alg
::
trim
(
std
::
string
&
str
,
const
std
::
locale
&
locale
)
{
boost
::
trim
(
str
,
locale
);
}
std
::
string
trim_copy
(
const
std
::
string
&
str
,
const
std
::
locale
&
locale
)
{
std
::
string
alg
::
trim_copy
(
const
std
::
string
&
str
,
const
std
::
locale
&
locale
)
{
return
boost
::
trim_copy
(
str
,
locale
);
}
void
trim_if
(
std
::
string
&
str
,
const
std
::
string
&
trim
)
{
void
alg
::
trim_if
(
std
::
string
&
str
,
const
std
::
string
&
trim
)
{
boost
::
trim_if
(
str
,
boost
::
is_any_of
(
trim
));
}
std
::
string
trim_copy_if
(
std
::
string
&
str
,
const
std
::
string
&
trim
)
{
std
::
string
alg
::
trim_copy_if
(
const
std
::
string
&
str
,
const
std
::
string
&
trim
)
{
return
boost
::
trim_copy_if
(
str
,
boost
::
is_any_of
(
trim
));
}
std
::
vector
<
std
::
string
>
split
(
const
std
::
string
&
str
,
const
std
::
string
&
splitBy
,
bool
trimElements
,
bool
removeEmptyElements
,
const
std
::
locale
&
locale
)
std
::
vector
<
std
::
string
>
alg
::
split
(
const
std
::
string
&
str
,
const
std
::
string
&
splitBy
,
bool
trimElements
,
bool
removeEmptyElements
,
const
std
::
locale
&
locale
)
{
std
::
vector
<
std
::
string
>
strs
;
boost
::
split
(
strs
,
str
,
boost
::
is_any_of
(
splitBy
));
...
...
@@ -93,7 +105,8 @@ std::vector<std::string> split(const std::string& str, const std::string& splitB
return
strs
;
}
std
::
vector
<
std
::
string
>
split_check_size
(
const
std
::
string
&
str
,
unsigned
int
expectedSize
,
const
std
::
string
&
splitBy
,
bool
trimElements
,
bool
removeEmptyElements
,
const
std
::
locale
&
locale
)
std
::
vector
<
std
::
string
>
alg
::
split_check_size
(
const
std
::
string
&
str
,
unsigned
int
expectedSize
,
const
std
::
string
&
splitBy
,
bool
trimElements
,
bool
removeEmptyElements
,
const
std
::
locale
&
locale
)
{
std
::
vector
<
std
::
string
>
strs
=
split
(
str
,
splitBy
,
trimElements
,
removeEmptyElements
,
locale
);
...
...
@@ -102,7 +115,8 @@ std::vector<std::string> split_check_size(const std::string& str, unsigned int e
return
strs
;
}
std
::
string
join
(
const
std
::
vector
<
std
::
string
>
vec
,
const
std
::
string
&
delimiter
,
bool
trimElements
,
bool
ignoreEmptyElements
,
const
std
::
locale
&
locale
)
{
std
::
string
alg
::
join
(
const
std
::
vector
<
std
::
string
>
vec
,
const
std
::
string
&
delimiter
,
bool
trimElements
,
bool
ignoreEmptyElements
,
const
std
::
locale
&
locale
)
{
std
::
ostringstream
ss
;
ss
.
imbue
(
locale
);
for
(
size_t
index
=
0
;
index
<
vec
.
size
();
index
++
)
...
...
@@ -126,32 +140,38 @@ std::string join(const std::vector<std::string> vec, const std::string& delimite
return
ss
.
str
();
}
std
::
string
replace_all
(
const
std
::
string
&
input
,
const
std
::
string
&
search
,
const
std
::
string
&
replace
)
std
::
string
alg
::
replace_all
(
const
std
::
string
&
input
,
const
std
::
string
&
search
,
const
std
::
string
&
replace
)
{
return
boost
::
algorithm
::
replace_all_copy
(
input
,
search
,
replace
);
}
std
::
string
replace_first
(
const
std
::
string
&
input
,
const
std
::
string
&
search
,
const
std
::
string
&
replace
)
std
::
string
alg
::
replace_first
(
const
std
::
string
&
input
,
const
std
::
string
&
search
,
const
std
::
string
&
replace
)
{
return
boost
::
algorithm
::
replace_first_copy
(
input
,
search
,
replace
);
}
std
::
string
replace_last
(
const
std
::
string
&
input
,
const
std
::
string
&
search
,
const
std
::
string
&
replace
)
std
::
string
alg
::
replace_last
(
const
std
::
string
&
input
,
const
std
::
string
&
search
,
const
std
::
string
&
replace
)
{
return
boost
::
algorithm
::
replace_last_copy
(
input
,
search
,
replace
);
}
bool
starts_with
(
const
std
::
string
&
input
,
const
std
::
string
&
search
)
bool
alg
::
starts_with
(
const
std
::
string
&
input
,
const
std
::
string
&
search
)
{
return
boost
::
starts_with
(
input
,
search
);
}
bool
ends_with
(
const
std
::
string
&
input
,
const
std
::
string
&
search
)
bool
alg
::
ends_with
(
const
std
::
string
&
input
,
const
std
::
string
&
search
)
{
return
boost
::
ends_with
(
input
,
search
);
}
bool
contains
(
const
std
::
string
&
haystack
,
const
std
::
string
&
needle
)
bool
alg
::
contains
(
const
std
::
string
&
haystack
,
const
std
::
string
&
needle
)
{
return
boost
::
algorithm
::
contains
(
haystack
,
needle
);
}
...
...
This diff is collapsed.
Click to expand it.
SimoxUtility/algorithm/string/string_tools.h
+
24
−
10
View file @
0ef0b185
...
...
@@ -54,15 +54,30 @@ namespace simox::alg
std
::
string
trim_copy_if
(
const
std
::
string
&
str
,
const
std
::
string
&
trim
=
"
\t
"
);
std
::
vector
<
std
::
string
>
split
(
const
std
::
string
&
str
,
const
std
::
string
&
splitBy
=
"
\t
"
,
bool
trimElements
=
true
,
bool
removeEmptyElements
=
true
,
const
std
::
locale
&
locale
=
DEFAULT_LOCALE
);
//! @param expectedSize throws SimoxError if split not matches expectedSize
std
::
vector
<
std
::
string
>
split_check_size
(
const
std
::
string
&
str
,
unsigned
int
expectedSize
,
const
std
::
string
&
splitBy
=
"
\t
"
,
bool
trimElements
=
true
,
bool
removeEmptyElements
=
true
,
const
std
::
locale
&
locale
=
DEFAULT_LOCALE
);
std
::
string
join
(
const
std
::
vector
<
std
::
string
>
vec
,
const
std
::
string
&
delimiter
=
" "
,
bool
trimElements
=
false
,
bool
ignoreEmptyElements
=
false
,
const
std
::
locale
&
locale
=
DEFAULT_LOCALE
);
std
::
vector
<
std
::
string
>
split
(
const
std
::
string
&
str
,
const
std
::
string
&
splitBy
=
"
\t
"
,
bool
trimElements
=
true
,
bool
removeEmptyElements
=
true
,
const
std
::
locale
&
locale
=
DEFAULT_LOCALE
);
/// @param expectedSize throws SimoxError if split not matches expectedSize
std
::
vector
<
std
::
string
>
split_check_size
(
const
std
::
string
&
str
,
unsigned
int
expectedSize
,
const
std
::
string
&
splitBy
=
"
\t
"
,
bool
trimElements
=
true
,
bool
removeEmptyElements
=
true
,
const
std
::
locale
&
locale
=
DEFAULT_LOCALE
);
std
::
string
join
(
const
std
::
vector
<
std
::
string
>
vec
,
const
std
::
string
&
delimiter
=
" "
,
bool
trimElements
=
false
,
bool
ignoreEmptyElements
=
false
,
const
std
::
locale
&
locale
=
DEFAULT_LOCALE
);
std
::
string
replace_first
(
std
::
string
const
&
input
,
std
::
string
const
&
search
,
std
::
string
const
&
replace
);
...
...
@@ -73,7 +88,6 @@ namespace simox::alg
bool
starts_with
(
std
::
string
const
&
input
,
std
::
string
const
&
search
);
bool
ends_with
(
std
::
string
const
&
input
,
std
::
string
const
&
search
);
bool
contains
(
const
std
::
string
&
haystack
,
const
std
::
string
&
needle
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment