-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e6e6d85
commit dd538a7
Showing
44 changed files
with
1,593 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
l.mik.wtf | ||
lavalink.kord.dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
core/src/commonMain/kotlin/dev/schlaubi/lavakord/internal/GenerateQueryHelper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package dev.schlaubi.lavakord.internal | ||
|
||
/** | ||
* Annotation to generate utility functions for search queries. | ||
*/ | ||
@Target(AnnotationTarget.FILE) | ||
@Retention(AnnotationRetention.SOURCE) | ||
@Repeatable | ||
internal annotation class GenerateQueryHelper( | ||
val serviceName: String, | ||
val serviceWebsite: String, | ||
val generateSearchAndPlayFunction: Boolean, | ||
val packageName: String, | ||
val prefix: String, | ||
val parameters: Array<Parameter> = [Parameter("query")], | ||
val builderOptions: Array<Parameter> = [], | ||
val builderFunction: String = "", | ||
val operationName: String = "search" | ||
) { | ||
@Target(AnnotationTarget.FILE) | ||
@Retention(AnnotationRetention.SOURCE) | ||
annotation class Parameter( | ||
val name: String, | ||
val queryName: String = "", | ||
val kDoc: String = "", | ||
val type: Type = Type.STRING, | ||
val enumTypes: Array<EnumType> = [] | ||
) { | ||
annotation class EnumType( | ||
val name: String, | ||
val value: String, | ||
val kDoc: String | ||
) | ||
|
||
enum class Type { | ||
STRING, | ||
INT, | ||
ENUM | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Interface for all generated query builders. | ||
*/ | ||
public interface QueryBuilder | ||
|
||
internal fun taggedQuery(vararg parameters: Pair<String, Any?>): String = buildString { | ||
val iterator = parameters.iterator() | ||
while (iterator.hasNext()) { | ||
val (name, value) = iterator.next() | ||
if (name.isEmpty()) { | ||
append(value) | ||
} else if (value != null) { | ||
append("$name:${value.toString().replace(" ", "%20")}") | ||
} | ||
if (iterator.hasNext() && value != null) { | ||
append("%20") | ||
} | ||
} | ||
} |
Oops, something went wrong.