Sync with 5.3.0
[deliverable/titan.core.git] / core / ASN_Null.hh
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 ///////////////////////////////////////////////////////////////////////////////
8 #ifndef ASN_NULL_HH
9 #define ASN_NULL_HH
10
11 #include "Types.h"
12 #include "Basetype.hh"
13 #include "Template.hh"
14 #include "Optional.hh"
15 #include "Encdec.hh"
16 #include "BER.hh"
17
18 class Module_Param;
19
20 class ASN_NULL : public Base_Type {
21 friend boolean operator==(asn_null_type par_value,
22 const ASN_NULL& other_value);
23
24 boolean bound_flag;
25 public:
26 ASN_NULL();
27 ASN_NULL(asn_null_type other_value);
28 ASN_NULL(const ASN_NULL& other_value);
29
30 ASN_NULL& operator=(asn_null_type other_value);
31 ASN_NULL& operator=(const ASN_NULL& other_value);
32
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); }
39
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; }
43
44 void log() const;
45
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_; }
51 #else
52 inline boolean is_present() const { return is_bound(); }
53 #endif
54
55 void set_param(Module_Param& param);
56
57 void encode_text(Text_Buf& text_buf) const;
58 void decode_text(Text_Buf& text_buf);
59
60 void encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf,
61 TTCN_EncDec::coding_t p_coding, ...) const;
62
63 void decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf,
64 TTCN_EncDec::coding_t p_coding, ...);
65
66 ASN_BER_TLV_t* BER_encode_TLV(const TTCN_Typedescriptor_t& p_td,
67 unsigned p_coding) const;
68
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*);
75
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;
79
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);
83 };
84
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); }
88
89 class ASN_NULL_template : public Base_Template {
90 struct {
91 unsigned int n_values;
92 ASN_NULL_template *list_value;
93 } value_list;
94
95 void copy_template(const ASN_NULL_template& other_value);
96
97 public:
98 ASN_NULL_template();
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);
104
105 ~ASN_NULL_template();
106 void clean_up();
107
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);
113
114 boolean match(asn_null_type other_value) const;
115 boolean match(const ASN_NULL& other_value) const;
116 asn_null_type valueof() const;
117
118 void set_type(template_sel template_type, unsigned int list_length);
119 ASN_NULL_template& list_item(unsigned int list_index);
120
121 void log() const;
122 void log_match(const ASN_NULL& match_value) const;
123
124 void set_param(Module_Param& param);
125
126 void encode_text(Text_Buf& text_buf) const;
127 void decode_text(Text_Buf& text_buf);
128
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))); }
139 #else
140 void check_restriction(template_res t_res, const char* t_name=NULL) const;
141 #endif
142 };
143
144 #endif // ASN_NULL_HH
This page took 0.034432 seconds and 5 git commands to generate.