ROSE 0.11.145.147
SourceLister.h
1#ifndef ROSE_BinaryAnalysis_ModelChecker_SourceLister_H
2#define ROSE_BinaryAnalysis_ModelChecker_SourceLister_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_MODEL_CHECKER
5
6#include <Rose/BinaryAnalysis/ModelChecker/BasicTypes.h>
7#include <Rose/SourceLocation.h>
8
9#include <Sawyer/LineVector.h>
10
11#include <boost/filesystem.hpp>
12#include <boost/format.hpp>
13
14namespace Rose {
15namespace BinaryAnalysis {
16namespace ModelChecker {
17
21class SourceLister {
22public:
23 using Ptr = SourceListerPtr;
24
25 struct Settings {
26 std::vector<boost::filesystem::path> directories;
27 boost::format currentLineFormat{"| ==> %06d %s"};
28 boost::format contextLineFormat{"| %06d %s"};
29 size_t leadingContext = 3;
30 size_t trailingContext = 3;
31 };
32
33private:
34 mutable SAWYER_THREAD_TRAITS::Mutex mutex_; // protects the following data members
36 Settings settings_;
37
38protected:
39 SourceLister();
40 explicit SourceLister(const Settings&);
41
42public:
51 static Ptr instance();
52 static Ptr instance(const Settings&);
63 boost::format currentLineFormat() const;
64 void currentLineFormat(const boost::format&);
75 boost::format contextLineFormat() const;
76 void contextLineFormat(const boost::format&);
87 size_t leadingContext() const;
88 void leadingContext(size_t);
99 size_t trailingContext() const;
100 void trailingContext(size_t);
111 std::vector<boost::filesystem::path> directories() const;
112 void directories(const std::vector<boost::filesystem::path>&);
121 void appendDirectory(const boost::filesystem::path&);
122
130 bool list(std::ostream&, const SourceLocation&, const std::string &prefix);
131
132private:
133 // Decompose a path into search components. For instance, the path "/foo/bar/baz.c" will return
134 // /foo/bar/baz.c
135 // foo/bar/baz.c
136 // bar/baz.c
137 // baz.c
138 static std::vector<boost::filesystem::path> decompose(const boost::filesystem::path&);
139
140 // Find a readable file by searching in the specified directory for each of the file names. Returns
141 // the path found, or empty.
142 static boost::filesystem::path findFile(const boost::filesystem::path &dir, const std::vector<boost::filesystem::path> &names);
143};
144
145} // namespace
146} // namespace
147} // namespace
148
149#endif
150#endif
Container associating values with keys.
Definition Sawyer/Map.h:72
Sawyer::SharedPointer< Node > Ptr
Reference counting pointer.
The ROSE library.