1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2000-2014 Ericsson Telecom AB
3 // All rights reserved. This program and the accompanying materials
4 // are made available under the terms of the Eclipse Public License v1.0
5 // which accompanies this distribution, and is available at
6 // http://www.eclipse.org/legal/epl-v10.html
7 ///////////////////////////////////////////////////////////////////////////////
12 #include "Basetype.hh"
13 #include "Template.hh"
14 #include "Optional.hh"
20 class ASN_NULL : public Base_Type {
21 friend boolean operator==(asn_null_type par_value,
22 const ASN_NULL& other_value);
27 ASN_NULL(asn_null_type other_value);
28 ASN_NULL(const ASN_NULL& other_value);
30 ASN_NULL& operator=(asn_null_type other_value);
31 ASN_NULL& operator=(const ASN_NULL& other_value);
33 boolean operator==(asn_null_type other_value) const;
34 boolean operator==(const ASN_NULL& other_value) const;
35 inline boolean operator!=(asn_null_type other_value) const
36 { return !(*this == other_value); }
37 inline boolean operator!=(const ASN_NULL& other_value) const
38 { return !(*this == other_value); }
40 inline boolean is_bound() const { return bound_flag; }
41 inline boolean is_value() const { return bound_flag; }
42 inline void clean_up() { bound_flag = FALSE; }
46 #ifdef TITAN_RUNTIME_2
47 boolean is_equal(const Base_Type* other_value) const { return *this == *(static_cast<const ASN_NULL*>(other_value)); }
48 void set_value(const Base_Type* other_value) { *this = *(static_cast<const ASN_NULL*>(other_value)); }
49 Base_Type* clone() const { return new ASN_NULL(*this); }
50 const TTCN_Typedescriptor_t* get_descriptor() const { return &ASN_NULL_descr_; }
52 inline boolean is_present() const { return is_bound(); }
55 void set_param(Module_Param& param);
57 void encode_text(Text_Buf& text_buf) const;
58 void decode_text(Text_Buf& text_buf);
60 void encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf,
61 TTCN_EncDec::coding_t p_coding, ...) const;
63 void decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf,
64 TTCN_EncDec::coding_t p_coding, ...);
66 ASN_BER_TLV_t* BER_encode_TLV(const TTCN_Typedescriptor_t& p_td,
67 unsigned p_coding) const;
69 boolean BER_decode_TLV(const TTCN_Typedescriptor_t& p_td,
70 const ASN_BER_TLV_t& p_tlv, unsigned L_form);
71 int XER_encode(const XERdescriptor_t& p_td,
72 TTCN_Buffer& p_buf, unsigned int flavor, int indent, embed_values_enc_struct_t*) const;
73 int XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
74 unsigned int flavor, embed_values_dec_struct_t*);
76 /** Encodes accordingly to the JSON encoding rules.
77 * Returns the length of the encoded data. */
78 int JSON_encode(const TTCN_Typedescriptor_t&, JSON_Tokenizer&) const;
80 /** Decodes accordingly to the JSON decoding rules.
81 * Returns the length of the encoded data. */
82 int JSON_decode(const TTCN_Typedescriptor_t&, JSON_Tokenizer&, boolean);
85 extern boolean operator==(asn_null_type par_value, const ASN_NULL& other_value);
86 inline boolean operator!=(asn_null_type par_value, const ASN_NULL& other_value)
87 { return !(par_value == other_value); }
89 class ASN_NULL_template : public Base_Template {
91 unsigned int n_values;
92 ASN_NULL_template *list_value;
95 void copy_template(const ASN_NULL_template& other_value);
99 ASN_NULL_template(template_sel other_value);
100 ASN_NULL_template(asn_null_type other_value);
101 ASN_NULL_template(const ASN_NULL& other_value);
102 ASN_NULL_template(const OPTIONAL<ASN_NULL>& other_value);
103 ASN_NULL_template(const ASN_NULL_template& other_value);
105 ~ASN_NULL_template();
108 ASN_NULL_template& operator=(template_sel other_value);
109 ASN_NULL_template& operator=(asn_null_type other_value);
110 ASN_NULL_template& operator=(const ASN_NULL& other_value);
111 ASN_NULL_template& operator=(const OPTIONAL<ASN_NULL>& other_value);
112 ASN_NULL_template& operator=(const ASN_NULL_template& other_value);
114 boolean match(asn_null_type other_value) const;
115 boolean match(const ASN_NULL& other_value) const;
116 asn_null_type valueof() const;
118 void set_type(template_sel template_type, unsigned int list_length);
119 ASN_NULL_template& list_item(unsigned int list_index);
122 void log_match(const ASN_NULL& match_value) const;
124 void set_param(Module_Param& param);
126 void encode_text(Text_Buf& text_buf) const;
127 void decode_text(Text_Buf& text_buf);
129 boolean is_present() const;
130 boolean match_omit() const;
131 #ifdef TITAN_RUNTIME_2
132 void valueofv(Base_Type* value) const { *(static_cast<ASN_NULL*>(value)) = valueof(); }
133 void set_value(template_sel other_value) { *this = other_value; }
134 void copy_value(const Base_Type* other_value) { *this = *(static_cast<const ASN_NULL*>(other_value)); }
135 Base_Template* clone() const { return new ASN_NULL_template(*this); }
136 const TTCN_Typedescriptor_t* get_descriptor() const { return &ASN_NULL_descr_; }
137 boolean matchv(const Base_Type* other_value) const { return match(*(static_cast<const ASN_NULL*>(other_value))); }
138 void log_matchv(const Base_Type* match_value) const { log_match(*(static_cast<const ASN_NULL*>(match_value))); }
140 void check_restriction(template_res t_res, const char* t_name=NULL) const;
144 #endif // ASN_NULL_HH