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
12 * Szabo, Janos Zoltan – initial implementation
14 ******************************************************************************/
15 #ifndef _Common_Identifier_HH
16 #define _Common_Identifier_HH
30 * This is a universal identifier class which can handle all
31 * reserved keywords. It contains also the name mappings. It is
32 * effective because of using reference counter.
37 ID_NAME, /**< internal name == C++ (generated) name */
38 ID_ASN, /**< ASN.1 display name */
39 ID_TTCN /**< TTCN-3 display name */
42 /** Returns whether \a p_name is a reserved word in the language
43 * identified by \a p_id_t */
44 static bool is_reserved_word(const string& p_name, id_t p_id_t);
45 /** Converts ASN.1 name \a p_name to internal (C++) name */
46 static string asn_2_name(const string& p_name);
47 /** Converts internal (C++) name \a p_name to ASN.1 name */
48 static string name_2_asn(const string& p_name);
49 /** Converts TTCN-3 name \a p_from to internal (C++) name */
50 static string ttcn_2_name(const string& p_name);
51 /** Converts internal (C++) name \a p_from to TTCN-3 name */
52 static string name_2_ttcn(const string& p_name);
57 /** Creates a new identifier with origin \a p_id_t and name \a
58 * p_name. If \a dontreg is true, then this new identifier will
59 * not be registered in the mapping tables. */
60 Identifier(id_t p_id_t, const string& p_name, bool dontreg=false);
61 Identifier(const Identifier& p);
64 Identifier *clone() const { return new Identifier(*this); }
65 Identifier& operator=(const Identifier& p);
66 bool operator==(const Identifier& p) const;
67 inline bool operator!=(const Identifier& p) const
68 { return !(*this == p); }
69 bool operator<(const Identifier& p) const;
71 /** Gets the origin. */
72 id_t get_origin() const { return origin; }
73 /** Gets the internal (and C++) name. */
74 const string& get_name() const;
75 /** Gets the display name according to its origin. */
76 const string& get_dispname() const;
77 /** Gets the ASN display name. */
78 const string& get_asnname() const;
79 /** Gets the TTCN display name. */
80 const string& get_ttcnname() const;
81 /** Returns false if this identifier does not have a valid name
82 * for the requested purpose. */
83 bool get_has_valid(id_t p_id_t) const;
84 /** Gets each valid/set name. */
85 string get_names() const;
87 /** True if it is a valid ASN modulereference. */
88 bool isvalid_asn_modref() const;
89 /** True if it is a valid ASN typereference. */
90 bool isvalid_asn_typeref() const;
91 /** True if it is a valid ASN valuereference. */
92 bool isvalid_asn_valref() const;
93 /** True if it is a valid ASN valuesetreference. */
94 bool isvalid_asn_valsetref() const;
95 /** True if it is a valid ASN objectclassreference. */
96 bool isvalid_asn_objclassref() const;
97 /** True if it is a valid ASN objectreference. */
98 bool isvalid_asn_objref() const;
99 /** True if it is a valid ASN objectsetreference. */
100 bool isvalid_asn_objsetref() const;
101 /** True if it is a valid ASN typefieldreference. */
102 bool isvalid_asn_typefieldref() const;
103 /** True if it is a valid ASN valuefieldreference. */
104 bool isvalid_asn_valfieldref() const;
105 /** True if it is a valid ASN valuesetfieldreference. */
106 bool isvalid_asn_valsetfieldref() const;
107 /** True if it is a valid ASN objectfieldreference. */
108 bool isvalid_asn_objfieldref() const;
109 /** True if it is a valid ASN objectsetfieldreference. */
110 bool isvalid_asn_objsetfieldref() const;
111 /** True if it is a valid ASN "word". */
112 bool isvalid_asn_word() const;
114 void dump(unsigned level) const;
117 /// Identifier to represent the contained type of a record-of
118 /// as a pseudo-component when checking attribute qualifiers.
119 extern const Identifier underscore_zero;
121 /** @} end of AST group */
123 } // namespace Common
125 #endif // _Common_Identifier_HH