ROSE 0.11.145.147
Location.h
1#ifndef ROSE_Location_H
2#define ROSE_Location_H
3#include <RoseFirst.h>
4#include <ostream>
5#include <string>
6
7namespace Rose {
8
23class Location {
24public:
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
48 virtual std::string printableName() const = 0;
49
62 virtual bool isEqual(const Location &other) const = 0;
63 virtual bool operator==(const Location &other) const final {
64 return isEqual(other) && other.isEqual(*this);
65 }
66 virtual bool operator!=(const Location &other) const final {
67 return !(*this == other);
68 }
72 virtual bool operator<(const Location&) const = 0;
73 virtual bool operator<=(const Location&) const = 0;
74 virtual bool operator>(const Location&) const = 0;
75 virtual bool operator>=(const Location&) const = 0;
76
80#ifdef _MSC_VER
81 // buggy compiler unable to compile this declaration; error is "C2216: 'explicit' cannot be used with 'sealed'". So we'll
82 // rely on the non-Microsoft compilers to enforce the "final".
83 virtual explicit operator bool() const {
84 return isValid();
85 }
86#else
87 virtual explicit operator bool() const final {
88 return isValid();
89 }
90#endif
91 virtual bool isValid() const = 0;
99 virtual bool operator!() const final {
100 return isEmpty();
101 }
102 virtual bool isEmpty() const final {
103 return *this ? false : true;
104 }
106};
107
108inline std::ostream& operator<<(std::ostream &out, const Location &x) {
109 x.print(out);
110 return out;
111}
112
113
114} // namespace
115#endif
Base class for location types.
Definition Location.h:23
virtual bool operator!=(const Location &other) const final
Equality and inequality.
Definition Location.h:66
virtual bool isValid() const =0
Test whether this object is valid.
virtual bool isEmpty() const final
Test whether this object is empty.
Definition Location.h:102
virtual bool operator!() const final
Test whether this object is empty.
Definition Location.h:99
virtual void print(std::ostream &) const =0
Output location to a stream.
virtual bool operator==(const Location &other) const final
Equality and inequality.
Definition Location.h:63
virtual bool isEqual(const Location &other) const =0
Equality and inequality.
virtual std::string printableName() const =0
Convert location to escaped, parsable string.
virtual std::string toString() const =0
Convert location to string.
The ROSE library.