Sync with 5.4.0
[deliverable/titan.core.git] / core / ASN_Null.hh
CommitLineData
970ed795 1///////////////////////////////////////////////////////////////////////////////
3abe9331 2// Copyright (c) 2000-2015 Ericsson Telecom AB
970ed795
EL
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
18class Module_Param;
19
20class 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;
25public:
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
3abe9331 55 void set_param(Module_Param& param);
56 Module_Param* get_param(Module_Param_Name& param_name) const;
970ed795
EL
57
58 void encode_text(Text_Buf& text_buf) const;
59 void decode_text(Text_Buf& text_buf);
60
61 void encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf,
62 TTCN_EncDec::coding_t p_coding, ...) const;
63
64 void decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf,
65 TTCN_EncDec::coding_t p_coding, ...);
66
67 ASN_BER_TLV_t* BER_encode_TLV(const TTCN_Typedescriptor_t& p_td,
68 unsigned p_coding) const;
69
70 boolean BER_decode_TLV(const TTCN_Typedescriptor_t& p_td,
71 const ASN_BER_TLV_t& p_tlv, unsigned L_form);
72 int XER_encode(const XERdescriptor_t& p_td,
af710487 73 TTCN_Buffer& p_buf, unsigned int flavor, int indent, embed_values_enc_struct_t*) const;
970ed795 74 int XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
af710487 75 unsigned int flavor, embed_values_dec_struct_t*);
76
77 /** Encodes accordingly to the JSON encoding rules.
78 * Returns the length of the encoded data. */
79 int JSON_encode(const TTCN_Typedescriptor_t&, JSON_Tokenizer&) const;
80
81 /** Decodes accordingly to the JSON decoding rules.
82 * Returns the length of the encoded data. */
83 int JSON_decode(const TTCN_Typedescriptor_t&, JSON_Tokenizer&, boolean);
970ed795
EL
84};
85
86extern boolean operator==(asn_null_type par_value, const ASN_NULL& other_value);
87inline boolean operator!=(asn_null_type par_value, const ASN_NULL& other_value)
88 { return !(par_value == other_value); }
89
90class ASN_NULL_template : public Base_Template {
91 struct {
92 unsigned int n_values;
93 ASN_NULL_template *list_value;
94 } value_list;
95
96 void copy_template(const ASN_NULL_template& other_value);
97
98public:
99 ASN_NULL_template();
100 ASN_NULL_template(template_sel other_value);
101 ASN_NULL_template(asn_null_type other_value);
102 ASN_NULL_template(const ASN_NULL& other_value);
103 ASN_NULL_template(const OPTIONAL<ASN_NULL>& other_value);
104 ASN_NULL_template(const ASN_NULL_template& other_value);
105
106 ~ASN_NULL_template();
107 void clean_up();
108
109 ASN_NULL_template& operator=(template_sel other_value);
110 ASN_NULL_template& operator=(asn_null_type other_value);
111 ASN_NULL_template& operator=(const ASN_NULL& other_value);
112 ASN_NULL_template& operator=(const OPTIONAL<ASN_NULL>& other_value);
113 ASN_NULL_template& operator=(const ASN_NULL_template& other_value);
114
3abe9331 115 boolean match(asn_null_type other_value, boolean legacy = FALSE) const;
116 boolean match(const ASN_NULL& other_value, boolean legacy = FALSE) const;
970ed795
EL
117 asn_null_type valueof() const;
118
119 void set_type(template_sel template_type, unsigned int list_length);
120 ASN_NULL_template& list_item(unsigned int list_index);
121
122 void log() const;
3abe9331 123 void log_match(const ASN_NULL& match_value, boolean legacy = FALSE) const;
970ed795
EL
124
125 void set_param(Module_Param& param);
3abe9331 126 Module_Param* get_param(Module_Param_Name& param_name) const;
970ed795
EL
127
128 void encode_text(Text_Buf& text_buf) const;
129 void decode_text(Text_Buf& text_buf);
130
3abe9331 131 boolean is_present(boolean legacy = FALSE) const;
132 boolean match_omit(boolean legacy = FALSE) const;
970ed795
EL
133#ifdef TITAN_RUNTIME_2
134 void valueofv(Base_Type* value) const { *(static_cast<ASN_NULL*>(value)) = valueof(); }
135 void set_value(template_sel other_value) { *this = other_value; }
136 void copy_value(const Base_Type* other_value) { *this = *(static_cast<const ASN_NULL*>(other_value)); }
137 Base_Template* clone() const { return new ASN_NULL_template(*this); }
138 const TTCN_Typedescriptor_t* get_descriptor() const { return &ASN_NULL_descr_; }
3abe9331 139 boolean matchv(const Base_Type* other_value, boolean legacy) const { return match(*(static_cast<const ASN_NULL*>(other_value)), legacy); }
140 void log_matchv(const Base_Type* match_value, boolean legacy) const { log_match(*(static_cast<const ASN_NULL*>(match_value)), legacy); }
970ed795 141#else
3abe9331 142 void check_restriction(template_res t_res, const char* t_name=NULL, boolean legacy = FALSE) const;
970ed795
EL
143#endif
144};
145
146#endif // ASN_NULL_HH
This page took 0.029901 seconds and 5 git commands to generate.