commore  1.0.6-SNAPSHOT
All Classes Namespaces Functions Variables Typedefs Enumerations Pages
Symbol.h
1 //
2 // Copyright (c) 2006-2014 Raphael David / CANTOR
3 //
4 
5 #ifndef CMR_SYMBOL_INCLUDED
6 #define CMR_SYMBOL_INCLUDED
7 
8 #include "Commore.h"
9 #include "AString.h"
10 
11 
12 namespace commore
13 {
14  struct SymbolItem;
18  class CMREXD Symbol
19  {
20  friend class Tuple;
21  public:
22  Symbol();
26  Symbol(const AChar* name);
30  Symbol(const AString& name);
31  Symbol(const Symbol& name);
35  Symbol(size_t num);
36  Symbol& operator = (const Symbol&);
40  operator const AString& () const { return get_name(); }
44  operator const AChar* () const { return get_name(); }
48  operator size_t () const { return get_num(); }
49  ~Symbol();
50 
51  public:
55  const AString& get_name() const;
59  size_t get_num() const;
60 
64  bool operator == (const AChar* name) const { return get_name() == name; }
65  bool operator == (const AString& name) const { return get_name() == name; }
69  bool operator == (size_t num) const { return get_num() == num; }
73  bool operator != (const AChar* name) const { return get_name() != name; }
74  bool operator != (const AString& name) const { return get_name() != name; }
78  bool operator != (size_t num) const { return get_num() != num; }
82  bool operator == (const Symbol& symbol) const { return symb_ == symbol.symb_; }
86  bool operator != (const Symbol& symbol) const { return symb_ != symbol.symb_; }
90  bool operator < (const Symbol& symbol) const { return get_name() < symbol.get_name(); }
91  bool operator > (const Symbol& symbol) const { return get_name() > symbol.get_name(); }
92  int compare(const Symbol& s) const { return get_name().compare(s.get_name()); }
96  bool is_ident() const;
100  long read_xml(IBStream& i);
104  long write_xml(OBStream& o) const;
105 
106  private:
107  SymbolItem* symb_;
108  };
109 };
110 
111 CMREXD commore::OBStream& operator << (commore::OBStream& o, const commore::Symbol& s);
112 
113 #endif
Definition: Tuple.h:29
Definition: AString.h:39
Definition: Symbol.h:18
const AString & get_name() const
int compare(const AString &str) const
Compare string.
Definition: AString.h:739
Definition: IOBStream.h:166