asn1,rrc_nr: implement to_json in setup_release_c

master
Francisco 3 years ago committed by Francisco Paisana
parent 9df6c6b936
commit ed2e88524f

@ -599,7 +599,7 @@ public:
IntType value; IntType value;
integer() = default; integer() = default;
integer(IntType value_) : value(value_) {} integer(IntType value_) : value(value_) {}
operator IntType() { return value; } operator IntType() const { return value; }
SRSASN_CODE pack(bit_ref& bref) const { return pack_integer(bref, value, lb, ub, has_ext, is_aligned); } SRSASN_CODE pack(bit_ref& bref) const { return pack_integer(bref, value, lb, ub, has_ext, is_aligned); }
SRSASN_CODE unpack(cbit_ref& bref) { return unpack_integer(value, bref, lb, ub, has_ext, is_aligned); } SRSASN_CODE unpack(cbit_ref& bref) { return unpack_integer(value, bref, lb, ub, has_ext, is_aligned); }
}; };
@ -1359,6 +1359,33 @@ private:
separator_t sep; separator_t sep;
}; };
template <typename T>
inline auto to_json(json_writer& j, const T& obj) -> decltype(obj.to_json(j))
{
obj.to_json(j);
}
template <typename T>
inline void to_json(json_writer& j, const asn1::enumerated<T>& obj)
{
j.write_str(obj.to_string());
}
template <typename T>
inline void to_json(json_writer& j, const asn1::dyn_array<T>& lst)
{
j.start_array();
for (const auto& o : lst) {
to_json(j, o);
}
j.end_array();
}
inline void to_json(json_writer& j, int64_t number)
{
j.write_int(number);
}
/******************* /*******************
Test pack/unpack Test pack/unpack
*******************/ *******************/

@ -2276,8 +2276,11 @@ struct setup_release_c {
j.start_obj(); j.start_obj();
switch (type_) { switch (type_) {
case types::release: case types::release:
j.write_null("release");
break; break;
case types::setup: case types::setup:
j.write_fieldname("setup");
asn1::to_json(j, setup());
break; break;
default: default:
log_invalid_choice_id(type_, "setup_release_c"); log_invalid_choice_id(type_, "setup_release_c");

Loading…
Cancel
Save