Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
macaon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Franck Dary
macaon
Commits
d6ac94e6
Commit
d6ac94e6
authored
5 years ago
by
Franck Dary
Browse files
Options
Downloads
Patches
Plain Diff
deleted namespace brackets
parent
742b3673
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/src/util.cpp
+13
-18
13 additions, 18 deletions
common/src/util.cpp
with
13 additions
and
18 deletions
common/src/util.cpp
+
13
−
18
View file @
d6ac94e6
...
...
@@ -11,31 +11,28 @@
#include
<ctime>
#include
<algorithm>
namespace
util
{
int
printedLength
(
std
::
string_view
s
)
int
util
::
printedLength
(
std
::
string_view
s
)
{
return
splitAsUtf8
(
s
).
size
();
}
std
::
string_view
getFilenameFromPath
(
std
::
string_view
s
)
std
::
string_view
util
::
getFilenameFromPath
(
std
::
string_view
s
)
{
int
indexOfSlash
=
s
.
find_last_of
(
'/'
);
return
{
s
.
data
()
+
indexOfSlash
+
1
,
s
.
size
()
-
1
-
indexOfSlash
};
}
bool
isSeparator
(
utf8char
c
)
bool
util
::
isSeparator
(
utf8char
c
)
{
return
c
==
' '
||
isIllegal
(
c
);
}
bool
isIllegal
(
utf8char
c
)
bool
util
::
isIllegal
(
utf8char
c
)
{
return
c
==
'\n'
||
c
==
'\t'
;
}
std
::
vector
<
std
::
string_view
>
split
(
std
::
string_view
remaining
,
char
delimiter
)
std
::
vector
<
std
::
string_view
>
util
::
split
(
std
::
string_view
remaining
,
char
delimiter
)
{
std
::
vector
<
std
::
string_view
>
result
;
...
...
@@ -52,7 +49,7 @@ std::vector<std::string_view> split(std::string_view remaining, char delimiter)
return
result
;
}
utf8string
splitAsUtf8
(
std
::
string_view
s
)
util
::
utf8string
util
::
splitAsUtf8
(
std
::
string_view
s
)
{
utf8string
result
;
const
char
*
beginPtr
=
s
.
data
();
...
...
@@ -78,28 +75,28 @@ utf8string splitAsUtf8(std::string_view s)
return
result
;
}
void
warning
(
std
::
string_view
message
,
const
std
::
experimental
::
source_location
&
location
)
void
util
::
warning
(
std
::
string_view
message
,
const
std
::
experimental
::
source_location
&
location
)
{
fmt
::
print
(
stderr
,
"WARNING ({}) : {}
\n
"
,
location
,
message
);
}
void
error
(
std
::
string_view
message
,
const
std
::
experimental
::
source_location
&
location
)
void
util
::
error
(
std
::
string_view
message
,
const
std
::
experimental
::
source_location
&
location
)
{
fmt
::
print
(
stderr
,
"ERROR ({}) : {}
\n
"
,
location
,
message
);
exit
(
1
);
}
void
error
(
const
std
::
exception
&
e
,
const
std
::
experimental
::
source_location
&
location
)
void
util
::
error
(
const
std
::
exception
&
e
,
const
std
::
experimental
::
source_location
&
location
)
{
error
(
e
.
what
(),
location
);
}
void
myThrow
(
std
::
string_view
message
,
const
std
::
experimental
::
source_location
&
location
)
void
util
::
myThrow
(
std
::
string_view
message
,
const
std
::
experimental
::
source_location
&
location
)
{
throw
std
::
invalid_argument
(
fmt
::
format
(
"from ({}) {}"
,
location
,
message
));
}
std
::
string
int2HumanStr
(
int
number
)
std
::
string
util
::
int2HumanStr
(
int
number
)
{
std
::
string
nb
=
std
::
to_string
(
number
);
std
::
string
result
;
...
...
@@ -114,7 +111,7 @@ std::string int2HumanStr(int number)
return
result
;
}
bool
doIfNameMatch
(
const
std
::
regex
&
reg
,
const
std
::
string
&
name
,
const
std
::
function
<
void
(
const
std
::
smatch
&
)
>
&
f
)
bool
util
::
doIfNameMatch
(
const
std
::
regex
&
reg
,
const
std
::
string
&
name
,
const
std
::
function
<
void
(
const
std
::
smatch
&
)
>
&
f
)
{
std
::
smatch
sm
;
std
::
regex_match
(
name
,
sm
,
reg
);
...
...
@@ -124,7 +121,5 @@ bool doIfNameMatch(const std::regex & reg, const std::string & name, const std::
f
(
sm
);
return
true
;
};
};
}
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