1#ifndef ROSE_SourceLocation_H
2#define ROSE_SourceLocation_H
4#include <Rose/Location.h>
6#include <boost/filesystem.hpp>
7#include <Sawyer/Optional.h>
8#include <Sawyer/Synchronization.h>
11#include <rose_serialize_path.h>
13#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
14#include <boost/serialization/access.hpp>
15#include <boost/serialization/nvp.hpp>
16#include <boost/shared_ptr.hpp>
17#include <boost/unordered_set.hpp>
20#ifdef ROSE_HAVE_CEREAL
21#include <cereal/access.hpp>
22#include <cereal/cereal.hpp>
70 using NamePtr = std::shared_ptr<boost::filesystem::path>;
76 struct NameHasher {
size_t operator()(
const NamePtr&)
const; };
77 struct NameEquivalence {
bool operator()(
const NamePtr&,
const NamePtr&)
const; };
78 using FileNames = boost::unordered_set<NamePtr, NameHasher, NameEquivalence>;
79 static SAWYER_THREAD_TRAITS::Mutex classMutex_;
80 static FileNames fileNames_;
82#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
84 friend class boost::serialization::access;
87 void serialize(S &s,
const unsigned ) {
88 s & BOOST_SERIALIZATION_NVP(fileName_);
89 s & BOOST_SERIALIZATION_NVP(line_);
90 s & BOOST_SERIALIZATION_NVP(column_);
95#ifdef ROSE_HAVE_CEREAL
97 friend class cereal::access;
99 template<
class Archive>
100 void CEREAL_SERIALIZE_FUNCTION_NAME(Archive &archive) {
101 archive(cereal::make_nvp(
"fileName", fileName_));
102 archive(cereal::make_nvp(
"line", line_));
103 archive(cereal::make_nvp(
"column", column_));
144 virtual void print(std::ostream&)
const override;
182 virtual const boost::filesystem::path&
fileName()
const;
200 void registerFileName();
Base class for location types.
Information about a source location.
virtual bool operator<(const Location &) const override
Ordered comparison.
virtual ~SourceLocation()
Destructor.
virtual bool isValid() const override
Test whether this object is valid.
SourceLocation()
Default constructor.
virtual size_t line() const
Line number.
virtual bool operator>(const Location &) const override
Ordered comparison.
virtual std::string printableName() const override
Convert location to escaped string.
virtual bool isEqual(const Location &) const override
Equality and inequality.
static SourceLocation parse(const std::string &)
Construct a new source location by parsing a string.
virtual bool operator>=(const Location &) const override
Ordered comparison.
virtual const boost::filesystem::path & fileName() const
File name associated with this location.
virtual std::string toString() const override
Convert location to string.
virtual void print(std::ostream &) const override
Output location to a stream.
SourceLocation(const boost::filesystem::path &fileName, size_t line, const Sawyer::Optional< size_t > &column=Sawyer::Nothing())
Construct a new source location.
virtual bool operator<=(const Location &) const override
Ordered comparison.
virtual const Sawyer::Optional< size_t > & column() const
Column number.
Holds a value or nothing.