1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2000-2014 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 ///////////////////////////////////////////////////////////////////////////////
12 #include "AST_asn1.hh"
17 using namespace Common;
20 * Class to represent ASN tag.
22 class Tag : public Node, public Location {
24 enum tagplicit_t {TAG_DEFPLICIT, TAG_EXPLICIT, TAG_IMPLICIT};
41 Tag(tagplicit_t p_plicit, tagclass_t p_tagclass, Value *p_tagvalue);
42 Tag(tagplicit_t p_plicit, tagclass_t p_tagclass, Int p_tagval);
45 virtual Tag* clone() const
46 {return new Tag(*this);}
47 Tag& operator=(const Tag& p);
48 bool operator==(const Tag& p) const;
49 bool operator<(const Tag& p) const;
50 tagplicit_t get_plicit() const {return plicit;}
51 void set_plicit(tagplicit_t p_plicit) {plicit=p_plicit;}
52 tagclass_t get_tagclass() const {return tagclass;}
53 const char *get_tagclass_str() const;
54 void set_tagclass(tagclass_t p_tagclass) {tagclass=p_tagclass;}
55 bool is_automatic() const { return is_auto; }
56 void set_automatic() {is_auto = true;}
58 void set_tagvalue(const Int& p_tagval);
59 void set_my_scope(Scope *p_scope);
61 virtual void dump(unsigned level) const;
65 * Class to represent a series of tags applied to a type. Index 0 is
68 class Tags : public Node {
78 virtual Tags* clone() const
79 {return new Tags(*this);}
80 virtual void set_fullname(const string& p_fullname);
81 void set_my_scope(Scope *p_scope);
82 void add_tag(Tag *p_tag);
83 size_t get_nof_tags() const
85 Tag* get_tag_byIndex(const size_t p_i)
88 void set_plicit(Type *p_type);
90 virtual void dump(unsigned level) const;
94 * Class to represent a collection of tags. This can be used to
95 * check tag clashes, "monoton increment"-requirements of tags etc.
97 class TagCollection : public Node, public Location {
99 map<Tag, void> tag_map;
103 TagCollection(const TagCollection& p);
106 virtual ~TagCollection();
107 virtual TagCollection* clone() const
108 {return new TagCollection(*this);}
109 /** Adds the tag to the collection. p_tag is copied; the
110 * tagcollection does not become the owner of p_tag. */
111 void addTag(const Tag *p_tag);
112 bool hasTag(const Tag *p_tag) const;
113 /** Adds (copies) every tag of p_tags to this. */
114 void addTags(const TagCollection *p_tags);
115 bool hasTags(const TagCollection *p_tags) const;
116 /** Return true if all the tags of p_tags are greater than all the
118 bool greaterTags(const TagCollection *p_tags) const;
119 /** Returns the smallest or largest tag of the collection.
120 * Applicable only of the collection is not empty. */
121 const Tag *getSmallestTag() const;
122 const Tag *getGreatestTag() const;
123 bool isExtensible() const { return is_extensible; }
124 void setExtensible();
125 bool isEmpty() const;
126 /** Makes it empty. */
132 #endif // _Asn_Tag_HH