sisi4s
Loading...
Searching...
No Matches
SourceLocation.hpp
Go to the documentation of this file.
1#ifndef SOURCE_LOCATION_DEFINED
2#define SOURCE_LOCATION_DEFINED
3
4#include <string>
5#include <sstream>
6#include <ostream>
7
8namespace sisi4s {
9class SourceLocation;
10std::ostream &operator<<(std::ostream &stream, SourceLocation const &l);
11
13public:
15 : file("<unknown>")
16 , line(0) {}
18 : file(l.file)
19 , line(l.line) {}
20 SourceLocation(std::string const &file_, int line_)
21 : file(file_)
22 , line(line_) {}
23 std::string getLocation() const {
24 std::stringstream stream;
25 stream << *this;
26 return stream.str();
27 }
28 std::string getFile() const { return file; }
29 int getLine() const { return line; }
30
31protected:
32 std::string file;
33 int line;
34};
35
36inline std::ostream &operator<<(std::ostream &stream,
37 SourceLocation const &location) {
38 return stream << location.getFile() << "(" << location.getLine() << ")";
39}
40} // namespace sisi4s
41
42#define SOURCE_LOCATION SourceLocation(__FILE__, __LINE__)
43
44#endif
std::ostream & operator<<(std::ostream &s, const FcidumpReader::FcidumpHeader &h)
Definition FcidumpWriter.cxx:25
Definition SourceLocation.hpp:12
int line
Definition SourceLocation.hpp:33
SourceLocation(std::string const &file_, int line_)
Definition SourceLocation.hpp:20
std::string getFile() const
Definition SourceLocation.hpp:28
SourceLocation()
Definition SourceLocation.hpp:14
std::string file
Definition SourceLocation.hpp:32
SourceLocation(SourceLocation const &l)
Definition SourceLocation.hpp:17
std::string getLocation() const
Definition SourceLocation.hpp:23
int getLine() const
Definition SourceLocation.hpp:29
Definition Algorithm.hpp:10