20 const auto schemaEncoding =
21 j.find(
"schemaEncoding") == j.end()
22 ? std::optional<std::string>(std::nullopt)
23 : std::optional<std::string>(j[
"schemaEncoding"].get<std::string>());
25 ChannelWithoutId channelWithoutId{j[
"topic"].get<std::string>(), j[
"encoding"].get<std::string>(),
26 j[
"schemaName"].get<std::string>(),
27 j[
"schema"].get<std::string>(), schemaEncoding};
28 c =
Channel(j[
"id"].get<ChannelId>(), channelWithoutId);
32 const auto paramType = p.
getType();
42 const auto& paramValue = p.
getValue<std::vector<unsigned char>>();
43 const std::string_view strValue(reinterpret_cast<const char*>(paramValue.data()),
47 j = p.
getValue<std::unordered_map<std::string, ParameterValue>>();
49 j = p.
getValue<std::vector<ParameterValue>>();
56 const auto jsonType = j.type();
58 if (jsonType == nlohmann::detail::value_t::string) {
60 }
else if (jsonType == nlohmann::detail::value_t::boolean) {
62 }
else if (jsonType == nlohmann::detail::value_t::number_integer) {
64 }
else if (jsonType == nlohmann::detail::value_t::number_unsigned) {
66 }
else if (jsonType == nlohmann::detail::value_t::number_float) {
68 }
else if (jsonType == nlohmann::detail::value_t::object) {
69 p =
ParameterValue(j.get<std::unordered_map<std::string, ParameterValue>>());
70 }
else if (jsonType == nlohmann::detail::value_t::array) {
79 j[
"type"] =
"byte_array";
84 const auto name = j[
"name"].get<std::string>();
86 if (j.find(
"value") == j.end()) {
94 if (j.find(
"type") != j.end() && j[
"type"] ==
"byte_array" &&
105 {
"name", service.
name},
106 {
"type", service.
type},
114 p.
name = j[
"name"].get<std::string>();
115 p.
type = j[
"type"].get<std::string>();
126 const size_t encondingLength =
static_cast<size_t>(
ReadUint32LE(data + offset));
128 this->
encoding = std::string(reinterpret_cast<const char*>(data + offset), encondingLength);
129 offset += encondingLength;
130 const auto payloadLength = dataLength - offset;
131 this->data.resize(payloadLength);
132 std::memcpy(this->data.data(), data + offset, payloadLength);
145 std::memcpy(data + offset, this->data.data(), this->data.size());
const ParameterValue & getValue() const
std::optional< std::string > schemaEncoding
ParameterType getType() const
void write(uint8_t *data) const
void read(const uint8_t *data, size_t size)
void to_json(nlohmann::json &j, const Channel &c)
std::string responseSchema
std::vector< uint8_t > data
void from_json(const nlohmann::json &j, Channel &c)
const std::string & getName() const
uint32_t ReadUint32LE(const uint8_t *buf)
std::string base64Encode(const std::string_view &input)
std::string requestSchema
const T & getValue() const
ParameterType getType() const
std::vector< unsigned char > base64Decode(const std::string &input)
void WriteUint32LE(uint8_t *buf, uint32_t val)