clang specific define in Runtime.cc
[deliverable/titan.core.git] / core / Boolean.hh
CommitLineData
d44e3c4f 1/******************************************************************************
2 * Copyright (c) 2000-2016 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 * Contributors:
9 * Balasko, Jeno
10 * Baranyi, Botond
11 * Beres, Szabolcs
12 * Delic, Adam
13 * Forstner, Matyas
14 * Raduly, Csaba
15 * Szabados, Kristof
16 * Szabo, Bence Janos
17 * Szabo, Janos Zoltan – initial implementation
18 * Szalai, Gabor
19 * Tatarka, Gabor
20 *
21 ******************************************************************************/
970ed795
EL
22#ifndef BOOLEAN_HH
23#define BOOLEAN_HH
24
25#include "Types.h"
26#include "Basetype.hh"
27#include "Template.hh"
28#include "Optional.hh"
29#include "Error.hh"
30
31class Module_Param;
32
33class BOOLEAN : public Base_Type {
34 friend class BOOLEAN_template;
35
36 friend boolean operator&&(boolean bool_value, const BOOLEAN& other_value);
37 friend boolean operator^(boolean bool_value, const BOOLEAN& other_value);
38 friend boolean operator||(boolean bool_value, const BOOLEAN& other_value);
39 friend boolean operator==(boolean bool_value, const BOOLEAN& other_value);
40
41 boolean bound_flag;
42 boolean boolean_value;
43
44public:
45 BOOLEAN();
46 BOOLEAN(boolean other_value);
47 BOOLEAN(const BOOLEAN& other_value);
48
49 BOOLEAN& operator=(boolean other_value);
50 BOOLEAN& operator=(const BOOLEAN& other_value);
51
52 boolean operator!() const;
53 boolean operator&&(boolean other_value) const;
54 boolean operator&&(const BOOLEAN& other_value) const;
55 boolean operator^(boolean other_value) const;
56 boolean operator^(const BOOLEAN& other_value) const;
57 boolean operator||(const BOOLEAN& other_value) const;
58 boolean operator||(boolean other_value) const;
59
60 boolean operator==(boolean other_value) const;
61 boolean operator==(const BOOLEAN& other_value) const;
62
63 inline boolean operator!=(boolean other_value) const
64 { return !(*this == other_value); }
65 inline boolean operator!=(const BOOLEAN& other_value) const
66 { return !(*this == other_value); }
67
68 operator boolean() const;
69
70 inline boolean is_bound() const { return bound_flag; }
71 inline boolean is_value() const { return bound_flag; }
72 void clean_up();
73 inline void must_bound(const char *err_msg) const
74 { if (!bound_flag) TTCN_error("%s", err_msg); }
75
76#ifdef TITAN_RUNTIME_2
77 boolean is_equal(const Base_Type* other_value) const { return *this == *(static_cast<const BOOLEAN*>(other_value)); }
78 void set_value(const Base_Type* other_value) { *this = *(static_cast<const BOOLEAN*>(other_value)); }
79 Base_Type* clone() const { return new BOOLEAN(*this); }
80 const TTCN_Typedescriptor_t* get_descriptor() const { return &BOOLEAN_descr_; }
81#else
82 inline boolean is_present() const { return is_bound(); }
83#endif
84
85 void log() const;
86
87 void set_param(Module_Param& param);
3abe9331 88 Module_Param* get_param(Module_Param_Name& param_name) const;
970ed795
EL
89
90 void encode_text(Text_Buf& text_buf) const;
91 void decode_text(Text_Buf& text_buf);
92
93 void encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf,
94 TTCN_EncDec::coding_t p_coding, ...) const;
95
96 void decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf,
97 TTCN_EncDec::coding_t p_coding, ...);
98
99 ASN_BER_TLV_t* BER_encode_TLV(const TTCN_Typedescriptor_t& p_td,
100 unsigned p_coding) const;
101
102 boolean BER_decode_TLV(const TTCN_Typedescriptor_t& p_td,
103 const ASN_BER_TLV_t& p_tlv, unsigned L_form);
104
105 /** Encodes the value of the variable according to the
106 * TTCN_Typedescriptor_t. It must be public because called by
107 * another types during encoding. Returns the length of encoded data*/
108 int RAW_encode(const TTCN_Typedescriptor_t&, RAW_enc_tree&) const;
109
110 /** Decodes the value of the variable according to the
111 * TTCN_Typedescriptor_t. It must be public because called by
112 * another types during encoding. Returns the number of decoded bits*/
113 int RAW_decode(const TTCN_Typedescriptor_t&, TTCN_Buffer&, int, raw_order_t,
114 boolean no_err=FALSE, int sel_field=-1, boolean first_call=TRUE);
115 int TEXT_encode(const TTCN_Typedescriptor_t&,
116 TTCN_Buffer&) const;
117 int TEXT_decode(const TTCN_Typedescriptor_t&, TTCN_Buffer&, Limit_Token_List&,
118 boolean no_err=FALSE, boolean first_call=TRUE);
119 int XER_encode(const XERdescriptor_t& p_td,
af710487 120 TTCN_Buffer& p_buf, unsigned int flavor, int indent, embed_values_enc_struct_t*) const;
970ed795 121 int XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
feade998 122 unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*);
970ed795
EL
123
124 /** Encodes accordingly to the JSON encoding rules.
125 * Returns the length of the encoded data. */
126 int JSON_encode(const TTCN_Typedescriptor_t&, JSON_Tokenizer&) const;
127
128 /** Decodes accordingly to the JSON encoding rules.
129 * Returns the length of the decoded data. */
130 int JSON_decode(const TTCN_Typedescriptor_t&, JSON_Tokenizer&, boolean);
131};
132
133extern boolean operator&&(boolean bool_value, const BOOLEAN& other_value);
134extern boolean operator^(boolean bool_value, const BOOLEAN& other_value);
135extern boolean operator||(boolean bool_value, const BOOLEAN& other_value);
136
137extern boolean operator==(boolean bool_value, const BOOLEAN& other_value);
138inline boolean operator!=(boolean bool_value, const BOOLEAN& other_value)
139 { return !(bool_value == other_value); }
140
141
142// boolean template class
143
144
145class BOOLEAN_template : public Base_Template {
146 union {
147 boolean single_value;
148 struct {
149 unsigned int n_values;
150 BOOLEAN_template *list_value;
151 } value_list;
152 };
153
154 void copy_template(const BOOLEAN_template& other_value);
155
156public:
157
158 BOOLEAN_template();
159 BOOLEAN_template(template_sel other_value);
160 BOOLEAN_template(boolean other_value);
161 BOOLEAN_template(const BOOLEAN& other_value);
162 BOOLEAN_template(const OPTIONAL<BOOLEAN>& other_value);
163 BOOLEAN_template(const BOOLEAN_template& other_value);
164
165 ~BOOLEAN_template();
166 void clean_up();
167
168 BOOLEAN_template& operator=(template_sel other_value);
169 BOOLEAN_template& operator=(boolean other_value);
170 BOOLEAN_template& operator=(const BOOLEAN& other_value);
171 BOOLEAN_template& operator=(const OPTIONAL<BOOLEAN>& other_value);
172 BOOLEAN_template& operator=(const BOOLEAN_template& other_value);
173
3abe9331 174 boolean match(boolean other_value, boolean legacy = FALSE) const;
175 boolean match(const BOOLEAN& other_value, boolean legacy = FALSE) const;
970ed795
EL
176 boolean valueof() const;
177
178 void set_type(template_sel template_type, unsigned int list_length);
179 BOOLEAN_template& list_item(unsigned int list_index);
180
181 void log() const;
3abe9331 182 void log_match(const BOOLEAN& match_value, boolean legacy = FALSE) const;
970ed795
EL
183
184 void set_param(Module_Param& param);
3abe9331 185 Module_Param* get_param(Module_Param_Name& param_name) const;
970ed795
EL
186
187 void encode_text(Text_Buf& text_buf) const;
188 void decode_text(Text_Buf& text_buf);
189
3abe9331 190 boolean is_present(boolean legacy = FALSE) const;
191 boolean match_omit(boolean legacy = FALSE) const;
970ed795
EL
192#ifdef TITAN_RUNTIME_2
193 void valueofv(Base_Type* value) const { *(static_cast<BOOLEAN*>(value)) = valueof(); }
194 void set_value(template_sel other_value) { *this = other_value; }
195 void copy_value(const Base_Type* other_value) { *this = *(static_cast<const BOOLEAN*>(other_value)); }
196 Base_Template* clone() const { return new BOOLEAN_template(*this); }
197 const TTCN_Typedescriptor_t* get_descriptor() const { return &BOOLEAN_descr_; }
3abe9331 198 boolean matchv(const Base_Type* other_value, boolean legacy) const { return match(*(static_cast<const BOOLEAN*>(other_value)), legacy); }
199 void log_matchv(const Base_Type* match_value, boolean legacy) const { log_match(*(static_cast<const BOOLEAN*>(match_value)), legacy); }
970ed795 200#else
3abe9331 201 void check_restriction(template_res t_res, const char* t_name=NULL, boolean legacy = FALSE) const;
970ed795
EL
202#endif
203};
204
205#endif
This page took 0.03242 seconds and 5 git commands to generate.