1 #ifndef ROSE_SourceLocation_H
2 #define ROSE_SourceLocation_H
4 #include <boost/filesystem.hpp>
5 #include <boost/serialization/access.hpp>
6 #include <boost/serialization/nvp.hpp>
7 #include <boost/shared_ptr.hpp>
8 #include <boost/unordered_set.hpp>
9 #include <Sawyer/Optional.h>
56 typedef boost::shared_ptr<boost::filesystem::path> NamePtr;
63 struct NameHasher {
size_t operator()(
const NamePtr&)
const; };
64 struct NameEquivalence {
bool operator()(
const NamePtr&,
const NamePtr&)
const; };
65 typedef boost::unordered_set<NamePtr, NameHasher, NameEquivalence> FileNames;
66 static SAWYER_THREAD_TRAITS::Mutex classMutex_;
67 static FileNames fileNames_;
70 #ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
71 friend class boost::serialization::access;
74 void serialize(S &s,
unsigned version) {
75 s & BOOST_SERIALIZATION_NVP(fileName_);
76 s & BOOST_SERIALIZATION_NVP(line_);
77 s & BOOST_SERIALIZATION_NVP(column_);
122 const boost::filesystem::path&
fileName()
const;
142 return !(*
this == other);
187 void print(std::ostream&)
const;
193 void this_type_does_not_support_comparisons()
const {}
199 operator unspecified_bool()
const {
200 return isEmpty() ? 0 : &SourceLocation::this_type_does_not_support_comparisons;;
206 void registerFileName();
209 std::ostream& operator<<(std::ostream&,
const SourceLocation&);
Information about a source location.
std::string printableName() const
Convert location to escaped string.
bool operator>=(const SourceLocation &other) const
Ordered comparison.
int compare(const SourceLocation &other) const
Ordered comparison.
Main namespace for the ROSE library.
static SourceLocation parse(const std::string &)
Construct a new source location by parsing a string.
SourceLocation()
Default constructor.
bool isEmpty() const
Test whether object is empty.
size_t line() const
Line number.
const boost::filesystem::path & fileName() const
File name associated with this location.
bool operator==(const SourceLocation &other) const
Equality and inequality.
const Sawyer::Optional< size_t > & column() const
Column number.
void print(std::ostream &) const
Output location to a stream.
bool operator<(const SourceLocation &other) const
Ordered comparison.
bool operator!=(const SourceLocation &other) const
Equality and inequality.
std::string toString() const
Convert location to string.
~SourceLocation()
Destructor.
bool operator>(const SourceLocation &other) const
Ordered comparison.
bool operator<=(const SourceLocation &other) const
Ordered comparison.