CatCode2
0.3.1indexedOffers a unique string format encoding system for creating structured, parameterized codes. Enables parsing, reading, writing, and serialization with customizable rules and escape sequences.
Offers a unique string format encoding system for creating structured, parameterized codes. Enables parsing, reading, writing, and serialization with customizable rules and escape sequences.
CatCode1前往 CatCode 查看。
猫猫码是一个具有特定格式的字符串格式编码,它看上去是这个样子的 👉 [CAT:xxx,param1=value1,param2=value2]
[开头,]结尾。CAT):分割。为了避免混淆整个存在猫猫码的文本中不允许出现:[、]、&
字符和制表符与换行符,猫猫码文本内中除了上述字符外,还不允许出现 , 与 = 字符。
因此,猫猫码的转义规则为:
任何符合规则 [HEAD:type,param=value,param=value,...] 的特殊码均可以视为猫猫码,尽管 HEAD 可能并不是 CAT。
CatCode2 核心库基于 Kotlin Multiplatform 支持多平台(JVM、JS、Native), 并且 CatCode2 提供了基于 kotlinx-serialization 的多平台序列化模块支持, 你可以借助 kotlinx-serialization 来自定义结构来描述你的猫猫码、序列化/反序列化你的猫猫码。
核心库 提供了针对猫猫码字符串的解析、读写与封装的核心基础功能,是最主要也是最基本的模块。
Note
👉 前往 核心库模块 获取更多信息。
CatCode2 提供了一些允许通过实体类作为载体来对猫猫码进行描述的模块, 例如对 kotlinx-serialization 的实现。
Note
👉 前往 序列化模块 获取更多信息。
walkCatCodeContinuously(
"[CAT:code,k1=v1,name=forte,tar=foo]",
true,
{ head: String -> println("head = $head") },
{ type: String -> println("type = $type") }
) { key: String, value: String -> println("$key: $value") }
val cat = catOf("[CAT:at,code=123]")
cat.code
cat.toCode("CQ")
cat.head
cat.type
cat.keys
val code: Int by cat.provider.int
val cat = buildCat(, ) {
-
(, , )
[] =
key() value
}
catCode = buildCatLiteral() {
-
(, , )
[] =
key() value
}
@Serializable
@SerialName("at") // or use @CatCodeTypeName("at")
data class At(val code: Long, val name: String)
fun sample {
at = At(, )
catcode = CatCode.encodeToString(At.serializer(), at)
newAt = CatCode.decodeFromString(At.serializer(), catcode)
}
=连接键与值,多对参数使用,分割。| 源 | 转 |
|---|
& | & |
[ | [ |
] | ] |
, | , |
= | = |
\n | |
\r | |
\t | 	 |
Surfaced from shared tags and platforms — no rankings paid for.