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
13 ******************************************************************************/
18 #include "Identifier.hh"
23 * Class to represent an Enumeration item. Is like a NamedValue, but
24 * the value can be NULL, and a(n integer) value can be assigned
27 class EnumItem : public Node, public Location {
31 string text; ///< for TEXT encoding instruction
32 /** Copy constructor not implemented */
33 EnumItem(const EnumItem&);
34 /** Assignment disabled */
35 EnumItem& operator=(const EnumItem&);
37 EnumItem(Identifier *p_name, Value *p_value);
39 virtual EnumItem *clone() const;
40 virtual void set_fullname(const string& p_fullname);
41 const Identifier& get_name() const { return *name; }
42 Value *get_value() const { return value; }
43 void set_value(Value *p_value);
44 const string& get_text() const { return text; }
45 void set_text(const string& p_text);
46 virtual void set_my_scope(Scope *p_scope);
47 virtual void dump(unsigned level) const;
51 * Class to represent a collection of enumerated items.
53 class EnumItems : public Node {
56 vector<EnumItem> eis_v;
57 /** Stores the first occurrence of EnumItem with id. The string key
58 * refers to the id of the ei, the value is the ei itself. */
59 map<string, EnumItem> eis_m;
60 /** Copy constructor not implemented */
61 EnumItems(const EnumItems& p);
62 /** Assignment disabled */
63 EnumItems& operator=(const EnumItems& p);
65 EnumItems() : Node(), my_scope(0), eis_v(), eis_m() { }
67 /** Clears the vector and the map, but does not delete the items */
69 virtual EnumItems *clone() const;
70 virtual void set_fullname(const string& p_fullname);
71 void set_my_scope(Scope *p_scope);
72 void add_ei(EnumItem *p_nv);
73 size_t get_nof_eis() const { return eis_v.size(); }
74 EnumItem* get_ei_byIndex(const size_t p_i) { return eis_v[p_i]; }
75 bool has_ei_withName(const Identifier& p_name) const
76 { return eis_m.has_key(p_name.get_name()); }
77 EnumItem* get_ei_byName(const Identifier& p_name) const
78 { return eis_m[p_name.get_name()]; }
79 virtual void dump(unsigned level) const;