Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dhtnet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
dhtnet
Commits
986f0eb1
Commit
986f0eb1
authored
1 year ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
string utils: cleanup
Change-Id: I6940503526bf42874047dc3802a33f955aa972ce
parent
d8e666dc
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/string_utils.h
+0
-51
0 additions, 51 deletions
include/string_utils.h
src/string_utils.cpp
+0
-27
0 additions, 27 deletions
src/string_utils.cpp
with
0 additions
and
78 deletions
include/string_utils.h
+
0
−
51
View file @
986f0eb1
...
...
@@ -163,55 +163,4 @@ std::vector<unsigned> split_string_to_unsigned(std::string_view s, char sep);
void
string_replace
(
std
::
string
&
str
,
const
std
::
string
&
from
,
const
std
::
string
&
to
);
std
::
string_view
string_remove_suffix
(
std
::
string_view
str
,
char
separator
);
std
::
string
string_join
(
const
std
::
set
<
std
::
string
>&
set
,
std
::
string_view
separator
=
"/"
);
std
::
set
<
std
::
string
>
string_split_set
(
std
::
string
&
str
,
std
::
string_view
separator
=
"/"
);
}
// namespace dhtnet
/*
// Add string operators missing from standard
// see https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/1RcShRhrmRc
namespace std {
inline string
operator+(const string& s, const string_view& sv)
{
return dhtnet::concat(s, sv);
}
inline string
operator+(const string_view& sv, const string& s)
{
return dhtnet::concat(sv, s);
}
using svmatch = match_results<string_view::const_iterator>;
using svsub_match = sub_match<string_view::const_iterator>;
constexpr string_view svsub_match_view(const svsub_match& submatch) noexcept {
return string_view(&*submatch.first, submatch.second - submatch.first);
}
inline bool
regex_match(string_view sv,
svmatch& m,
const regex& e,
regex_constants::match_flag_type flags = regex_constants::match_default)
{
return regex_match(sv.begin(), sv.end(), m, e, flags);
}
inline bool
regex_match(string_view sv,
const regex& e,
regex_constants::match_flag_type flags = regex_constants::match_default)
{
return regex_match(sv.begin(), sv.end(), e, flags);
}
inline bool
regex_search(string_view sv,
svmatch& m,
const regex& e,
regex_constants::match_flag_type flags = regex_constants::match_default)
{
return regex_search(sv.begin(), sv.end(), m, e, flags);
}
} // namespace std
*/
This diff is collapsed.
Click to expand it.
src/string_utils.cpp
+
0
−
27
View file @
986f0eb1
...
...
@@ -132,31 +132,4 @@ string_replace(std::string& str, const std::string& from, const std::string& to)
}
}
std
::
string_view
string_remove_suffix
(
std
::
string_view
str
,
char
separator
)
{
auto
it
=
str
.
find
(
separator
);
if
(
it
!=
std
::
string_view
::
npos
)
str
=
str
.
substr
(
0
,
it
);
return
str
;
}
std
::
string
string_join
(
const
std
::
set
<
std
::
string
>&
set
,
std
::
string_view
separator
)
{
return
fmt
::
format
(
"{}"
,
fmt
::
join
(
set
,
separator
));
}
std
::
set
<
std
::
string
>
string_split_set
(
std
::
string
&
str
,
std
::
string_view
separator
)
{
std
::
set
<
std
::
string
>
output
;
for
(
auto
first
=
str
.
data
(),
second
=
str
.
data
(),
last
=
first
+
str
.
size
();
second
!=
last
&&
first
!=
last
;
first
=
second
+
1
)
{
second
=
std
::
find_first_of
(
first
,
last
,
std
::
cbegin
(
separator
),
std
::
cend
(
separator
));
if
(
first
!=
second
)
output
.
emplace
(
first
,
second
-
first
);
}
return
output
;
}
}
// namespace dhtnet
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