ROSE  0.11.96.11
Location.h
1 #ifndef ROSE_Location_H
2 #define ROSE_Location_H
3 
4 #include <ostream>
5 #include <string>
6 
7 namespace Rose {
8 
23 class Location {
24 public:
25  // NOTICE: Subclasses must implemented a static "parse" method
26 
27 
28  virtual ~Location() = default;
29 
35  virtual std::string toString() const = 0;
36 
42  virtual void print(std::ostream&) const = 0;
43 
50  virtual std::string printableName() const = 0;
51 
64  virtual bool isEqual(const Location &other) const = 0;
65  virtual bool operator==(const Location &other) const final {
66  return isEqual(other) && other.isEqual(*this);
67  }
68  virtual bool operator!=(const Location &other) const final {
69  return !(*this == other);
70  }
74  virtual bool operator<(const Location&) const = 0;
75  virtual bool operator<=(const Location&) const = 0;
76  virtual bool operator>(const Location&) const = 0;
77  virtual bool operator>=(const Location&) const = 0;
78 
82 #ifdef _MSC_VER
83  // buggy compiler unable to compile this declaration; error is "C2216: 'explicit' cannot be used with 'sealed'". So we'll
84  // rely on the non-Microsoft compilers to enforce the "final".
85  virtual explicit operator bool() const {
86  return isValid();
87  }
88 #else
89  virtual explicit operator bool() const final {
90  return isValid();
91  }
92 #endif
93  virtual bool isValid() const = 0;
101  virtual bool operator!() const final {
102  return isEmpty();
103  }
104  virtual bool isEmpty() const final {
105  return *this ? false : true;
106  }
108 };
109 
110 inline std::ostream& operator<<(std::ostream &out, const Location &x) {
111  x.print(out);
112  return out;
113 }
114 
115 
116 } // namespace
117 #endif
Rose::Location::toString
virtual std::string toString() const =0
Convert location to string.
Rose::Location::operator!=
virtual bool operator!=(const Location &other) const final
Equality and inequality.
Definition: Location.h:68
Rose::Location::print
virtual void print(std::ostream &) const =0
Output location to a stream.
Rose::Location::operator!
virtual bool operator!() const final
Test whether this object is empty.
Definition: Location.h:101
Rose::Location::operator==
virtual bool operator==(const Location &other) const final
Equality and inequality.
Definition: Location.h:65
Rose::Location::isEqual
virtual bool isEqual(const Location &other) const =0
Equality and inequality.
Rose::Location
Base class for location types.
Definition: Location.h:23
Rose::Location::isEmpty
virtual bool isEmpty() const final
Test whether this object is empty.
Definition: Location.h:104
Rose
Main namespace for the ROSE library.
Definition: BinaryTutorial.dox:3
Rose::Location::isValid
virtual bool isValid() const =0
Test whether this object is valid.
Rose::Location::printableName
virtual std::string printableName() const =0
Convert location to escaped, parsable string.