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;
integer() = default;
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 unpack(cbit_ref& bref) { return unpack_integer(value, bref, lb, ub, has_ext, is_aligned); }
};
@ -1359,6 +1359,33 @@ private:
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
*******************/

@ -2254,7 +2254,7 @@ struct setup_release_c {
// choice methods
setup_release_c() = default;
types type() const { return type_; }
types type() const { return type_; }
// getters
elem_type_paramT_& setup()
@ -2267,7 +2267,7 @@ struct setup_release_c {
assert_choice_type(types::setup, type_, "SetupRelease");
return c;
}
void set_release() { set(types::release); }
void set_release() { set(types::release); }
void set(typename types::options e) { type_ = e; }
@ -2276,8 +2276,11 @@ struct setup_release_c {
j.start_obj();
switch (type_) {
case types::release:
j.write_null("release");
break;
case types::setup:
j.write_fieldname("setup");
asn1::to_json(j, setup());
break;
default:
log_invalid_choice_id(type_, "setup_release_c");

Loading…
Cancel
Save