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
49968541
Commit
49968541
authored
Dec 12, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sticker/Match: add inequality operators
parent
cc143105
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
0 deletions
+39
-0
protocol.xml
doc/protocol.xml
+5
-0
StickerCommands.cxx
src/command/StickerCommands.cxx
+4
-0
Match.hxx
src/sticker/Match.hxx
+12
-0
StickerDatabase.cxx
src/sticker/StickerDatabase.cxx
+18
-0
No files found.
doc/protocol.xml
View file @
49968541
...
...
@@ -2155,6 +2155,11 @@ OK
<para>
Searches for stickers with the given value.
</para>
<para>
Other supported operators are:
"
<function>
<
</function>
", "
<function>
>
</function>
"
</para>
</listitem>
</varlistentry>
</variablelist>
...
...
src/command/StickerCommands.cxx
View file @
49968541
...
...
@@ -155,6 +155,10 @@ handle_sticker_song(Client &client, ConstBuffer<const char *> args)
if
(
strcmp
(
op_s
,
"="
)
==
0
)
op
=
StickerOperator
::
EQUALS
;
else
if
(
strcmp
(
op_s
,
"<"
)
==
0
)
op
=
StickerOperator
::
LESS_THAN
;
else
if
(
strcmp
(
op_s
,
">"
)
==
0
)
op
=
StickerOperator
::
GREATER_THAN
;
else
{
command_error
(
client
,
ACK_ERROR_ARG
,
"bad operator"
);
...
...
src/sticker/Match.hxx
View file @
49968541
...
...
@@ -32,6 +32,18 @@ enum class StickerOperator {
* exists.
*/
EQUALS
,
/**
* Matches if a sticker with the specified name exists with a
* value smaller than the specified one.
*/
LESS_THAN
,
/**
* Matches if a sticker with the specified name exists with a
* value bigger than the specified one.
*/
GREATER_THAN
,
};
#endif
src/sticker/StickerDatabase.cxx
View file @
49968541
...
...
@@ -44,6 +44,8 @@ enum sticker_sql {
STICKER_SQL_DELETE_VALUE
,
STICKER_SQL_FIND
,
STICKER_SQL_FIND_VALUE
,
STICKER_SQL_FIND_LT
,
STICKER_SQL_FIND_GT
,
};
static
const
char
*
const
sticker_sql
[]
=
{
...
...
@@ -64,6 +66,12 @@ static const char *const sticker_sql[] = {
//[STICKER_SQL_FIND_VALUE] =
"SELECT uri,value FROM sticker WHERE type=? AND uri LIKE (? || '%') AND name=? AND value=?"
,
//[STICKER_SQL_FIND_LT] =
"SELECT uri,value FROM sticker WHERE type=? AND uri LIKE (? || '%') AND name=? AND value<?"
,
//[STICKER_SQL_FIND_GT] =
"SELECT uri,value FROM sticker WHERE type=? AND uri LIKE (? || '%') AND name=? AND value>?"
,
};
static
const
char
sticker_sql_create
[]
=
...
...
@@ -392,6 +400,16 @@ BindFind(const char *type, const char *base_uri, const char *name,
return
BindAllOrNull
(
error
,
sticker_stmt
[
STICKER_SQL_FIND_VALUE
],
type
,
base_uri
,
name
,
value
);
case
StickerOperator
:
:
LESS_THAN
:
return
BindAllOrNull
(
error
,
sticker_stmt
[
STICKER_SQL_FIND_LT
],
type
,
base_uri
,
name
,
value
);
case
StickerOperator
:
:
GREATER_THAN
:
return
BindAllOrNull
(
error
,
sticker_stmt
[
STICKER_SQL_FIND_GT
],
type
,
base_uri
,
name
,
value
);
}
assert
(
false
);
...
...
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