commit
38e86d4a07
23 files changed
+3219
No files matched your search
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
// TS3 command wire format: "commandname key=value key=value|key=value".
|
||||
// Ported from ts6-manager tslib/commands.ts.
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace Echoion::Protocol
|
||||
{
|
||||
|
||||
// Escape / unescape a single token per the TS3 rules
|
||||
// (\\ \/ \s \p \f \n \r \t \v).
|
||||
std::string tsEscape(const std::string& str);
|
||||
std::string tsUnescape(const std::string& str);
|
||||
|
||||
// Ordered key/value params for a command. std::map keeps a stable order so
|
||||
// serialization is deterministic (helpful for tests); the server does not
|
||||
// care about ordering.
|
||||
using CommandParams = std::map<std::string, std::string>;
|
||||
|
||||
struct ParsedCommand {
|
||||
std::string name;
|
||||
CommandParams params; // first group
|
||||
std::vector<CommandParams> groups; // all '|'-separated groups
|
||||
};
|
||||
|
||||
// Serialize "name k=v k=v". Empty values are emitted as "k=".
|
||||
std::string buildCommand(const std::string& name,
|
||||
const CommandParams& params);
|
||||
|
||||
// Parse a raw command / notify line into name + params (+ pipe groups).
|
||||
ParsedCommand parseCommand(const std::string& raw);
|
||||
|
||||
} // namespace Echoion::Protocol
|
||||
Reference in new issue
Block a user