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
14 * Szabo, Janos Zoltan – initial implementation
15 * Zalanyi, Balazs Andor
17 ******************************************************************************/
18 #ifndef _Ttcn_PatternString_HH
19 #define _Ttcn_PatternString_HH
21 #include "../vector.hh"
22 #include "../Setting.hh"
23 #include "AST_ttcn3.hh"
25 #include "../Value.hh"
30 using namespace Common;
33 * The instances of this class can represent a TTCN pattern
34 * string. It can built up from different kinds of elements:
35 * "regular" RE-elements and "reference" elements ({reference} and
38 class PatternString : public Node {
47 vector<ps_elem_t> elems;
48 PatternString(const PatternString& p);
49 /** returns the last element if it contains a regular string or NULL
51 ps_elem_t *get_last_elem() const;
55 pstr_type_t pattern_type;
58 PatternString(): Node(), my_scope(0), cstr_value(0),
59 pattern_type(CSTR_PATTERN) { }
60 virtual ~PatternString();
61 virtual PatternString* clone() const;
62 virtual void set_fullname(const string& p_fullname);
63 virtual void set_my_scope(Scope *p_scope);
64 void set_code_section(GovernedSimple::code_section_t p_code_section);
66 void addString(const char *p_str);
67 void addString(const string& p_str);
68 void addRef(Ttcn::Reference *p_ref);
69 void addRefdCharSet(Ttcn::Reference *p_ref);
70 string get_full_str() const;
72 void set_pattern_type(pstr_type_t p_type);
73 pstr_type_t get_pattern_type() const;
75 /** Returns whether the pattern contains embedded references */
76 bool has_refs() const;
77 /** Checks the embedded referenced values */
78 void chk_refs(Type::expected_value_t expected_value=Type::EXPECTED_DYNAMIC_VALUE);
79 void chk_recursions(ReferenceChain& refch);
80 /** Checks the pattern by translating it to POSIX regexp */
82 bool chk_self_ref(Common::Assignment *lhs);
83 /** Joins adjacent string components into one for more efficient code
86 /** Temporary hack... */
87 string create_charstring_literals(Common::Module *p_mod);
88 virtual void dump(unsigned level) const;
90 /** Called by Value::get_value_refd_last() */
93 /** Converts this string pattern into a JSON schema string pattern. */
94 char* convert_to_json();
99 #endif // _Ttcn_PatternString_HH