2 * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>.
4 * Redistribution and modifications are permitted subject to BSD license.
6 #include <asn_internal.h>
7 #include <NativeReal.h>
11 * Decode the chunk of XML text encoding REAL.
14 NativeReal_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
15 const asn_TYPE_descriptor_t *td, void **sptr,
16 const char *opt_mname, const void *buf_ptr, size_t size) {
21 rval = REAL_decode_xer(opt_codec_ctx, td, (void **)&stp, opt_mname,
23 if(rval.code == RC_OK) {
25 if(asn_REAL2double(&st, &d) || NativeReal__set(td, sptr, d) < 0) {
30 /* Convert all errors into RC_FAIL */
33 ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_REAL, &st);
38 NativeReal_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
39 int ilevel, enum xer_encoder_flags_e flags,
40 asn_app_consume_bytes_f *cb, void *app_key) {
41 double d = NativeReal__get_double(td, sptr);
42 asn_enc_rval_t er = {0,0,0};
46 er.encoded = REAL__dump(d, flags & XER_F_CANONICAL, cb, app_key);
47 if(er.encoded < 0) ASN__ENCODE_FAILED;