Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
1fda842e
Commit
1fda842e
authored
Sep 12, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util/StringView: use StringAPI.hxx
parent
f71e20d0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
9 deletions
+8
-9
StringView.hxx
src/util/StringView.hxx
+8
-9
No files found.
src/util/StringView.hxx
View file @
1fda842e
...
@@ -31,8 +31,7 @@
...
@@ -31,8 +31,7 @@
#define STRING_VIEW_HXX
#define STRING_VIEW_HXX
#include "ConstBuffer.hxx"
#include "ConstBuffer.hxx"
#include "StringAPI.hxx"
#include <string.h>
struct
StringView
:
ConstBuffer
<
char
>
{
struct
StringView
:
ConstBuffer
<
char
>
{
StringView
()
=
default
;
StringView
()
=
default
;
...
@@ -45,7 +44,7 @@ struct StringView : ConstBuffer<char> {
...
@@ -45,7 +44,7 @@ struct StringView : ConstBuffer<char> {
StringView
(
pointer_type
_data
)
noexcept
StringView
(
pointer_type
_data
)
noexcept
:
ConstBuffer
(
_data
,
:
ConstBuffer
(
_data
,
_data
!=
nullptr
?
strlen
(
_data
)
:
0
)
{}
_data
!=
nullptr
?
StringLength
(
_data
)
:
0
)
{}
constexpr
StringView
(
std
::
nullptr_t
n
)
noexcept
constexpr
StringView
(
std
::
nullptr_t
n
)
noexcept
:
ConstBuffer
(
n
)
{}
:
ConstBuffer
(
n
)
{}
...
@@ -61,32 +60,32 @@ struct StringView : ConstBuffer<char> {
...
@@ -61,32 +60,32 @@ struct StringView : ConstBuffer<char> {
gcc_pure
gcc_pure
pointer_type
Find
(
value_type
ch
)
const
noexcept
{
pointer_type
Find
(
value_type
ch
)
const
noexcept
{
return
(
pointer_type
)
memchr
(
data
,
ch
,
size
);
return
StringFind
(
data
,
ch
,
size
);
}
}
gcc_pure
gcc_pure
bool
StartsWith
(
StringView
needle
)
const
noexcept
{
bool
StartsWith
(
StringView
needle
)
const
noexcept
{
return
size
>=
needle
.
size
&&
return
size
>=
needle
.
size
&&
memcmp
(
data
,
needle
.
data
,
needle
.
size
)
==
0
;
StringIsEqual
(
data
,
needle
.
data
,
needle
.
size
)
;
}
}
gcc_pure
gcc_pure
bool
EndsWith
(
StringView
needle
)
const
noexcept
{
bool
EndsWith
(
StringView
needle
)
const
noexcept
{
return
size
>=
needle
.
size
&&
return
size
>=
needle
.
size
&&
memcmp
(
data
+
size
-
needle
.
size
,
StringIsEqual
(
data
+
size
-
needle
.
size
,
needle
.
data
,
needle
.
size
)
==
0
;
needle
.
data
,
needle
.
size
)
;
}
}
gcc_pure
gcc_pure
bool
Equals
(
StringView
other
)
const
noexcept
{
bool
Equals
(
StringView
other
)
const
noexcept
{
return
size
==
other
.
size
&&
return
size
==
other
.
size
&&
memcmp
(
data
,
other
.
data
,
size
)
==
0
;
StringIsEqual
(
data
,
other
.
data
,
size
)
;
}
}
gcc_pure
gcc_pure
bool
EqualsIgnoreCase
(
StringView
other
)
const
noexcept
{
bool
EqualsIgnoreCase
(
StringView
other
)
const
noexcept
{
return
size
==
other
.
size
&&
return
size
==
other
.
size
&&
strncasecmp
(
data
,
other
.
data
,
size
)
==
0
;
StringIsEqualIgnoreCase
(
data
,
other
.
data
,
size
)
;
}
}
/**
/**
...
...
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