ASN_Null.hh 6.49 KB
Newer Older
Elemer Lelik's avatar
Elemer Lelik committed
1
/******************************************************************************
Adam Knapp's avatar
Adam Knapp committed
2
 * Copyright (c) 2000-2021 Ericsson Telecom AB
Elemer Lelik's avatar
Elemer Lelik committed
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v2.0
Elemer Lelik's avatar
Elemer Lelik committed
5
 * which accompanies this distribution, and is available at
6
 * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
Elemer Lelik's avatar
Elemer Lelik committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 *
 * Contributors:
 *   Balasko, Jeno
 *   Baranyi, Botond
 *   Beres, Szabolcs
 *   Delic, Adam
 *   Forstner, Matyas
 *   Raduly, Csaba
 *   Szabados, Kristof
 *   Szabo, Bence Janos
 *   Szabo, Janos Zoltan – initial implementation
 *   Tatarka, Gabor
 *
 ******************************************************************************/
Elemer Lelik's avatar
Elemer Lelik committed
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef ASN_NULL_HH
#define ASN_NULL_HH

#include "Types.h"
#include "Basetype.hh"
#include "Template.hh"
#include "Optional.hh"
#include "Encdec.hh"
#include "BER.hh"

class Module_Param;

class ASN_NULL : public Base_Type {
  friend boolean operator==(asn_null_type par_value,
    const ASN_NULL& other_value);

  boolean bound_flag;
public:
  ASN_NULL();
  ASN_NULL(asn_null_type other_value);
  ASN_NULL(const ASN_NULL& other_value);

  ASN_NULL& operator=(asn_null_type other_value);
  ASN_NULL& operator=(const ASN_NULL& other_value);

  boolean operator==(asn_null_type other_value) const;
  boolean operator==(const ASN_NULL& other_value) const;
  inline boolean operator!=(asn_null_type other_value) const
    { return !(*this == other_value); }
  inline boolean operator!=(const ASN_NULL& other_value) const
    { return !(*this == other_value); }

  inline boolean is_bound() const { return bound_flag; }
  inline boolean is_value() const { return bound_flag; }
  inline void clean_up() { bound_flag = FALSE; }

  void log() const;

#ifdef TITAN_RUNTIME_2
  boolean is_equal(const Base_Type* other_value) const { return *this == *(static_cast<const ASN_NULL*>(other_value)); }
  void set_value(const Base_Type* other_value) { *this = *(static_cast<const ASN_NULL*>(other_value)); }
  Base_Type* clone() const { return new ASN_NULL(*this); }
  const TTCN_Typedescriptor_t* get_descriptor() const { return &ASN_NULL_descr_; }
64
  Module_Param* get_param(Module_Param_Name& param_name) const;
Elemer Lelik's avatar
Elemer Lelik committed
65
66
67
68
#else
  inline boolean is_present() const { return is_bound(); }
#endif

Elemer Lelik's avatar
Elemer Lelik committed
69
  void set_param(Module_Param& param);
Elemer Lelik's avatar
Elemer Lelik committed
70
71
72
73
74

  void encode_text(Text_Buf& text_buf) const;
  void decode_text(Text_Buf& text_buf);

  void encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf,
75
              int p_coding, ...) const;
Elemer Lelik's avatar
Elemer Lelik committed
76
77

  void decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf,
78
              int p_coding, ...);
Elemer Lelik's avatar
Elemer Lelik committed
79
80
81
82
83
84
85

  ASN_BER_TLV_t* BER_encode_TLV(const TTCN_Typedescriptor_t& p_td,
                                unsigned p_coding) const;

  boolean BER_decode_TLV(const TTCN_Typedescriptor_t& p_td,
                         const ASN_BER_TLV_t& p_tlv, unsigned L_form);
  int XER_encode(const XERdescriptor_t& p_td,
86
                 TTCN_Buffer& p_buf, unsigned int flavor, unsigned int flavor2, int indent, embed_values_enc_struct_t*) const;
Elemer Lelik's avatar
Elemer Lelik committed
87
  int XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
Elemer Lelik's avatar
Elemer Lelik committed
88
                 unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*);
Elemer Lelik's avatar
Elemer Lelik committed
89
90
91
  
  /** Encodes accordingly to the JSON encoding rules.
    * Returns the length of the encoded data. */
92
  int JSON_encode(const TTCN_Typedescriptor_t&, JSON_Tokenizer&, boolean) const;
Elemer Lelik's avatar
Elemer Lelik committed
93
94
95
  
  /** Decodes accordingly to the JSON decoding rules.
    * Returns the length of the encoded data. */
96
  int JSON_decode(const TTCN_Typedescriptor_t&, JSON_Tokenizer&, boolean, boolean, int p_chosen_field = CHOSEN_FIELD_UNSET);
97
98
99
100
101
102
103
104
  
  /** Encodes accordingly to the OER encoding rules.
    * Returns the length of the encoded data. */
  int OER_encode(const TTCN_Typedescriptor_t&, TTCN_Buffer&) const;
  
  /** Decodes accordingly to the OER decoding rules.
    * Returns the length of the encoded data. */
  int OER_decode(const TTCN_Typedescriptor_t&, TTCN_Buffer&, OER_struct&);
Elemer Lelik's avatar
Elemer Lelik committed
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
};

extern boolean operator==(asn_null_type par_value, const ASN_NULL& other_value);
inline boolean operator!=(asn_null_type par_value, const ASN_NULL& other_value)
  { return !(par_value == other_value); }

class ASN_NULL_template : public Base_Template {
  struct {
    unsigned int n_values;
    ASN_NULL_template *list_value;
  } value_list;

  void copy_template(const ASN_NULL_template& other_value);

public:
  ASN_NULL_template();
  ASN_NULL_template(template_sel other_value);
  ASN_NULL_template(asn_null_type other_value);
  ASN_NULL_template(const ASN_NULL& other_value);
  ASN_NULL_template(const OPTIONAL<ASN_NULL>& other_value);
  ASN_NULL_template(const ASN_NULL_template& other_value);

  ~ASN_NULL_template();
  void clean_up();

  ASN_NULL_template& operator=(template_sel other_value);
  ASN_NULL_template& operator=(asn_null_type other_value);
  ASN_NULL_template& operator=(const ASN_NULL& other_value);
  ASN_NULL_template& operator=(const OPTIONAL<ASN_NULL>& other_value);
  ASN_NULL_template& operator=(const ASN_NULL_template& other_value);

Elemer Lelik's avatar
Elemer Lelik committed
136
137
  boolean match(asn_null_type other_value, boolean legacy = FALSE) const;
  boolean match(const ASN_NULL& other_value, boolean legacy = FALSE) const;
Elemer Lelik's avatar
Elemer Lelik committed
138
139
140
141
142
143
  asn_null_type valueof() const;

  void set_type(template_sel template_type, unsigned int list_length);
  ASN_NULL_template& list_item(unsigned int list_index);

  void log() const;
Elemer Lelik's avatar
Elemer Lelik committed
144
  void log_match(const ASN_NULL& match_value, boolean legacy = FALSE) const;
Elemer Lelik's avatar
Elemer Lelik committed
145
146
147
148
149
150

  void set_param(Module_Param& param);

  void encode_text(Text_Buf& text_buf) const;
  void decode_text(Text_Buf& text_buf);

Elemer Lelik's avatar
Elemer Lelik committed
151
152
  boolean is_present(boolean legacy = FALSE) const;
  boolean match_omit(boolean legacy = FALSE) const;
Elemer Lelik's avatar
Elemer Lelik committed
153
#ifdef TITAN_RUNTIME_2
154
  Module_Param* get_param(Module_Param_Name& param_name) const;
Elemer Lelik's avatar
Elemer Lelik committed
155
156
157
158
159
  void valueofv(Base_Type* value) const { *(static_cast<ASN_NULL*>(value)) = valueof(); }
  void set_value(template_sel other_value) { *this = other_value; }
  void copy_value(const Base_Type* other_value) { *this = *(static_cast<const ASN_NULL*>(other_value)); }
  Base_Template* clone() const { return new ASN_NULL_template(*this); }
  const TTCN_Typedescriptor_t* get_descriptor() const { return &ASN_NULL_descr_; }
Elemer Lelik's avatar
Elemer Lelik committed
160
161
  boolean matchv(const Base_Type* other_value, boolean legacy) const { return match(*(static_cast<const ASN_NULL*>(other_value)), legacy); }
  void log_matchv(const Base_Type* match_value, boolean legacy) const  { log_match(*(static_cast<const ASN_NULL*>(match_value)), legacy); }
Elemer Lelik's avatar
Elemer Lelik committed
162
#else
Elemer Lelik's avatar
Elemer Lelik committed
163
  void check_restriction(template_res t_res, const char* t_name=NULL, boolean legacy = FALSE) const;
Elemer Lelik's avatar
Elemer Lelik committed
164
165
166
167
#endif
};

#endif // ASN_NULL_HH