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
589639f8
Commit
589639f8
authored
Jun 06, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tag/ParseName: add StringView overloads
parent
548aa001
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
2 deletions
+43
-2
ParseName.cxx
src/tag/ParseName.cxx
+32
-1
ParseName.hxx
src/tag/ParseName.hxx
+11
-1
No files found.
src/tag/ParseName.cxx
View file @
589639f8
/*
* Copyright 2003-201
8
The Music Player Daemon Project
* Copyright 2003-201
9
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -19,6 +19,7 @@
#include "ParseName.hxx"
#include "util/ASCII.hxx"
#include "util/StringView.hxx"
#include <assert.h>
#include <string.h>
...
...
@@ -39,6 +40,21 @@ tag_name_parse(const char *name) noexcept
}
TagType
tag_name_parse
(
StringView
name
)
noexcept
{
assert
(
name
!=
nullptr
);
for
(
unsigned
i
=
0
;
i
<
TAG_NUM_OF_ITEM_TYPES
;
++
i
)
{
assert
(
tag_item_names
[
i
]
!=
nullptr
);
if
(
name
.
Equals
(
tag_item_names
[
i
]))
return
(
TagType
)
i
;
}
return
TAG_NUM_OF_ITEM_TYPES
;
}
TagType
tag_name_parse_i
(
const
char
*
name
)
noexcept
{
assert
(
name
!=
nullptr
);
...
...
@@ -52,3 +68,18 @@ tag_name_parse_i(const char *name) noexcept
return
TAG_NUM_OF_ITEM_TYPES
;
}
TagType
tag_name_parse_i
(
StringView
name
)
noexcept
{
assert
(
name
!=
nullptr
);
for
(
unsigned
i
=
0
;
i
<
TAG_NUM_OF_ITEM_TYPES
;
++
i
)
{
assert
(
tag_item_names
[
i
]
!=
nullptr
);
if
(
name
.
EqualsIgnoreCase
(
tag_item_names
[
i
]))
return
(
TagType
)
i
;
}
return
TAG_NUM_OF_ITEM_TYPES
;
}
src/tag/ParseName.hxx
View file @
589639f8
/*
* Copyright 2003-201
8
The Music Player Daemon Project
* Copyright 2003-201
9
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -23,6 +23,8 @@
#include "Type.h"
#include "util/Compiler.h"
struct
StringView
;
/**
* Parse the string, and convert it into a #TagType. Returns
* #TAG_NUM_OF_ITEM_TYPES if the string could not be recognized.
...
...
@@ -31,6 +33,10 @@ gcc_pure
TagType
tag_name_parse
(
const
char
*
name
)
noexcept
;
gcc_pure
TagType
tag_name_parse
(
StringView
name
)
noexcept
;
/**
* Parse the string, and convert it into a #TagType. Returns
* #TAG_NUM_OF_ITEM_TYPES if the string could not be recognized.
...
...
@@ -41,4 +47,8 @@ gcc_pure
TagType
tag_name_parse_i
(
const
char
*
name
)
noexcept
;
gcc_pure
TagType
tag_name_parse_i
(
StringView
name
)
noexcept
;
#endif
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