ilang  1.1.4
ILAng: A Modeling and Verification Platform for SoCs
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros
symbol.h
Go to the documentation of this file.
1 
4 #ifndef ILANG_ILA_SYMBOL_H__
5 #define ILANG_ILA_SYMBOL_H__
6 
7 #include <fstream>
8 #include <ostream>
9 #include <string>
10 
12 namespace ilang {
13 
16 class Symbol {
17 public:
18  // ------------------------- CONSTRUCTOR/DESTRUCTOR ----------------------- //
20  Symbol();
22  Symbol(const char* str);
24  Symbol(const std::string& str);
26  Symbol(const Symbol& rhs);
28  ~Symbol();
29 
30  // ------------------------- ACCESSORS/MUTATORS --------------------------- //
32  const std::string& str() const;
34  const char* c_str() const;
36  const std::string format_str(const std::string& prefix = "",
37  const std::string& suffix = "") const;
39  int to_int() const;
41  const size_t& id() const;
42 
44  void set_name(const std::string& name);
45 
46  // ------------------------- METHODS -------------------------------------- //
48  std::ostream& Print(std::ostream& out) const;
50  friend std::ostream& operator<<(std::ostream& out, const Symbol& s);
51 
53  Symbol& operator=(const Symbol& rhs);
55  friend bool operator==(const Symbol& lhs, const Symbol& rhs);
57  friend bool operator<(const Symbol& lhs, const Symbol& rhs);
58 
59 private:
60  // ------------------------- MEMBERS -------------------------------------- //
62  std::string name_;
64  size_t id_;
66  static size_t counter_;
67 
68 }; // class Symbol
69 
70 } // namespace ilang
71 
72 #endif // ILANG_ILA_SYMBOL_H__
Symbol & operator=(const Symbol &rhs)
Overload assignment.
friend bool operator<(const Symbol &lhs, const Symbol &rhs)
Overload comparison &lt;.
~Symbol()
Default destructor.
const std::string & str() const
Get the name as basic string.
void set_name(const std::string &name)
Update the name (should not be initialized before).
int to_int() const
Convert the name to integer and return.
The symbol is the name and ID of an object. Every object has an unique symbol.
Definition: symbol.h:16
Symbol()
Default constructor (empty name).
const char * c_str() const
Get the name as c-type string.
std::ostream & Print(std::ostream &out) const
Output function.
friend std::ostream & operator<<(std::ostream &out, const Symbol &s)
Overload output stream.
const std::string format_str(const std::string &prefix="", const std::string &suffix="") const
Get the symbol as cpp string.
friend bool operator==(const Symbol &lhs, const Symbol &rhs)
Overload comparison ==.
const size_t & id() const
Get the id.