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
8d9347ed
Commit
8d9347ed
authored
Sep 12, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Util/WStringCompare: use struct WStringView
parent
eff821c1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
31 deletions
+15
-31
WStringCompare.cxx
src/util/WStringCompare.cxx
+0
-26
WStringCompare.hxx
src/util/WStringCompare.hxx
+15
-5
No files found.
src/util/WStringCompare.cxx
View file @
8d9347ed
...
...
@@ -18,17 +18,6 @@
*/
#include "WStringCompare.hxx"
#include "WStringAPI.hxx"
#include <assert.h>
#include <string.h>
bool
StringStartsWith
(
const
wchar_t
*
haystack
,
const
wchar_t
*
needle
)
noexcept
{
const
size_t
length
=
StringLength
(
needle
);
return
StringIsEqual
(
haystack
,
needle
,
length
);
}
bool
StringEndsWith
(
const
wchar_t
*
haystack
,
const
wchar_t
*
needle
)
noexcept
...
...
@@ -41,21 +30,6 @@ StringEndsWith(const wchar_t *haystack, const wchar_t *needle) noexcept
}
const
wchar_t
*
StringAfterPrefix
(
const
wchar_t
*
string
,
const
wchar_t
*
prefix
)
noexcept
{
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert
(
string
!=
nullptr
);
assert
(
prefix
!=
nullptr
);
#endif
size_t
prefix_length
=
StringLength
(
prefix
);
return
StringIsEqual
(
string
,
prefix
,
prefix_length
)
?
string
+
prefix_length
:
nullptr
;
}
const
wchar_t
*
FindStringSuffix
(
const
wchar_t
*
p
,
const
wchar_t
*
suffix
)
noexcept
{
const
size_t
p_length
=
StringLength
(
p
);
...
...
src/util/WStringCompare.hxx
View file @
8d9347ed
...
...
@@ -30,6 +30,8 @@
#ifndef WSTRING_COMPARE_HXX
#define WSTRING_COMPARE_HXX
#include "WStringView.hxx"
#include "WStringAPI.hxx"
#include "Compiler.h"
#include <wchar.h>
...
...
@@ -40,9 +42,12 @@ StringIsEmpty(const wchar_t *string) noexcept
return
*
string
==
0
;
}
gcc_pure
bool
StringStartsWith
(
const
wchar_t
*
haystack
,
const
wchar_t
*
needle
)
noexcept
;
gcc_pure
gcc_nonnull_all
static
inline
bool
StringStartsWith
(
const
wchar_t
*
haystack
,
WStringView
needle
)
noexcept
{
return
StringIsEqual
(
haystack
,
needle
.
data
,
needle
.
size
);
}
gcc_pure
bool
...
...
@@ -54,8 +59,13 @@ StringEndsWith(const wchar_t *haystack, const wchar_t *needle) noexcept;
* nullptr.
*/
gcc_pure
gcc_nonnull_all
const
wchar_t
*
StringAfterPrefix
(
const
wchar_t
*
string
,
const
wchar_t
*
prefix
)
noexcept
;
static
inline
const
wchar_t
*
StringAfterPrefix
(
const
wchar_t
*
haystack
,
WStringView
needle
)
noexcept
{
return
StringStartsWith
(
haystack
,
needle
)
?
haystack
+
needle
.
size
:
nullptr
;
}
/**
* Check if the given string ends with the specified suffix. If yes,
...
...
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