You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
776 B
C++
39 lines
776 B
C++
#pragma once
|
|
|
|
#include <vector>
|
|
|
|
// Простейшее type-erased значение для RPC.
|
|
// PoC: поддерживаем только int, но интерфейс позволяет в будущем
|
|
// добавить другие типы (string, bool, и т.д.).
|
|
|
|
enum class RpcType {
|
|
Int,
|
|
};
|
|
|
|
class RpcValue {
|
|
public:
|
|
RpcValue() : type_(RpcType::Int), i_(0) {}
|
|
|
|
static RpcValue fromInt(int v) {
|
|
RpcValue r;
|
|
r.type_ = RpcType::Int;
|
|
r.i_ = v;
|
|
return r;
|
|
}
|
|
|
|
RpcType type() const { return type_; }
|
|
|
|
int asInt() const {
|
|
// PoC: единственный поддерживаемый тип.
|
|
return i_;
|
|
}
|
|
|
|
private:
|
|
RpcType type_;
|
|
int i_;
|
|
};
|
|
|
|
using RpcArgs = std::vector<RpcValue>;
|
|
|
|
|