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_ENABLE_BOOST_SERIALIZATION
14#include <boost/serialization/access.hpp>
15#include <boost/serialization/nvp.hpp>
18#include <boost/shared_ptr.hpp>
19#include <boost/unordered_set.hpp>
21#ifdef ROSE_HAVE_CEREAL
22#include <cereal/access.hpp>
23#include <cereal/cereal.hpp>
71 using NamePtr = std::shared_ptr<boost::filesystem::path>;
77 struct NameHasher {
size_t operator()(
const NamePtr&)
const; };
78 struct NameEquivalence {
bool operator()(
const NamePtr&,
const NamePtr&)
const; };
79 using FileNames = boost::unordered_set<NamePtr, NameHasher, NameEquivalence>;
80 static SAWYER_THREAD_TRAITS::Mutex classMutex_;
81 static FileNames fileNames_;
83#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
85 friend class boost::serialization::access;
88 void serialize(S &s,
const unsigned ) {
89 s & BOOST_SERIALIZATION_NVP(fileName_);
90 s & BOOST_SERIALIZATION_NVP(line_);
91 s & BOOST_SERIALIZATION_NVP(column_);
96#ifdef ROSE_HAVE_CEREAL
98 friend class cereal::access;
100 template<
class Archive>
101 void CEREAL_SERIALIZE_FUNCTION_NAME(Archive &archive) {
102 archive(cereal::make_nvp(
"fileName", fileName_));
103 archive(cereal::make_nvp(
"line", line_));
104 archive(cereal::make_nvp(
"column", column_));
145 virtual void print(std::ostream&)
const override;
183 virtual const boost::filesystem::path&
fileName()
const;
201 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.