Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
partons
core
elementary-utils
Commits
4044e1e3
Commit
4044e1e3
authored
Apr 30, 2019
by
Pawel Sznajder
Browse files
add new members in StringUtils (trim)
parent
19899287
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/ElementaryUtils/string_utils/StringUtils.h
View file @
4044e1e3
...
@@ -72,6 +72,9 @@ public:
...
@@ -72,6 +72,9 @@ public:
// Remove leading and trailing spaces from a string
// Remove leading and trailing spaces from a string
static
void
trim
(
std
::
string
&
str
,
const
std
::
string
&
whitespace
=
"
\t
"
);
static
void
trim
(
std
::
string
&
str
,
const
std
::
string
&
whitespace
=
"
\t
"
);
// Remove all white spaces from a string
static
void
trimAll
(
std
::
string
&
str
,
const
std
::
string
&
whitespace
=
"
\t
"
);
static
unsigned
int
count
(
std
::
string
str
,
static
unsigned
int
count
(
std
::
string
str
,
const
std
::
string
&
searchString
);
const
std
::
string
&
searchString
);
...
...
src/ElementaryUtils/string_utils/StringUtils.cpp
View file @
4044e1e3
...
@@ -181,6 +181,15 @@ void StringUtils::trim(std::string &str, const std::string& whitespace) {
...
@@ -181,6 +181,15 @@ void StringUtils::trim(std::string &str, const std::string& whitespace) {
}
}
}
}
void
StringUtils
::
trimAll
(
std
::
string
&
str
,
const
std
::
string
&
whitespace
)
{
std
::
string
::
const_iterator
it
;
for
(
it
=
whitespace
.
begin
();
it
!=
whitespace
.
end
();
++
it
)
{
str
.
erase
(
std
::
remove
(
str
.
begin
(),
str
.
end
(),
*
it
),
str
.
end
());
}
}
unsigned
int
StringUtils
::
count
(
std
::
string
str
,
unsigned
int
StringUtils
::
count
(
std
::
string
str
,
const
std
::
string
&
searchString
)
{
const
std
::
string
&
searchString
)
{
unsigned
int
resultat
=
0
;
unsigned
int
resultat
=
0
;
...
@@ -367,7 +376,8 @@ size_t StringUtils::findFirst(const std::string& file,
...
@@ -367,7 +376,8 @@ size_t StringUtils::findFirst(const std::string& file,
return
fileSize
;
return
fileSize
;
}
}
std
::
string
StringUtils
::
formatDate
(
const
time_t
&
time
,
const
std
::
string
&
format
)
{
std
::
string
StringUtils
::
formatDate
(
const
time_t
&
time
,
const
std
::
string
&
format
)
{
// see : http://stackoverflow.com/questions/16357999/current-date-and-time-as-string
// see : http://stackoverflow.com/questions/16357999/current-date-and-time-as-string
...
...
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