X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=core%2FOptional.hh;h=c640b0099d27c4140a8e5ad6b3a59c5a85181d24;hb=3f84031e48520efb2cbc931692210e5de7fa5919;hp=8e1dc2bd94b9dd64b981ea5ad653a652e2b4bc7e;hpb=51fa56b97ff178aa82497de54a5945698517e55d;p=deliverable%2Ftitan.core.git diff --git a/core/Optional.hh b/core/Optional.hh index 8e1dc2b..c640b00 100644 --- a/core/Optional.hh +++ b/core/Optional.hh @@ -309,6 +309,8 @@ public: const TTCN_Typedescriptor_t&, TTCN_Buffer&) const; int TEXT_decode(const TTCN_Typedescriptor_t&, TTCN_Buffer&, Limit_Token_List&, boolean no_err=FALSE, boolean first_call=TRUE); + int JSON_encode_negtest(const Erroneous_descriptor_t*, + const TTCN_Typedescriptor_t&, JSON_Tokenizer&) const; #endif /** Encodes accordingly to the JSON encoding rules. @@ -808,6 +810,25 @@ int OPTIONAL::JSON_encode(const TTCN_Typedescriptor_t& p_td, JSON_Tokeni } } +#ifdef TITAN_RUNTIME_2 +template +int OPTIONAL::JSON_encode_negtest(const Erroneous_descriptor_t* p_err_descr, + const TTCN_Typedescriptor_t& p_td, + JSON_Tokenizer& p_tok) const +{ + switch (get_selection()) { + case OPTIONAL_PRESENT: + return optional_value->JSON_encode_negtest(p_err_descr, p_td, p_tok); + case OPTIONAL_OMIT: + return p_tok.put_next_token(JSON_TOKEN_LITERAL_NULL, NULL); + default: + TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_UNBOUND, + "Encoding an unbound optional value."); + return -1; + } +} +#endif + template int OPTIONAL::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_tok, boolean p_silent) {