64 lines
988 B
C++
64 lines
988 B
C++
#include <iostream>
|
|
|
|
#include "SourceLocation.hpp"
|
|
|
|
SourceLocation::SourceLocation(std::string file, int line, int column):
|
|
_file(file),
|
|
_line(line),
|
|
_column(column)
|
|
{
|
|
|
|
}
|
|
|
|
SourceLocation::SourceLocation():
|
|
_file(""),
|
|
_line(0),
|
|
_column(0)
|
|
{
|
|
|
|
}
|
|
|
|
bool SourceLocation::isValid() const
|
|
{
|
|
return _line > 0 && _column > 0 && !_file.empty();
|
|
}
|
|
|
|
void SourceLocation::print() const
|
|
{
|
|
std::cout << printToString();
|
|
}
|
|
|
|
std::string SourceLocation::printToString() const
|
|
{
|
|
return file() + ":" + std::to_string(lineLocation()) +":" + std::to_string(columnLocation());
|
|
}
|
|
|
|
std::string SourceLocation::file() const
|
|
{
|
|
return _file;
|
|
}
|
|
|
|
void SourceLocation::setFile(std::string file)
|
|
{
|
|
_file = file;
|
|
}
|
|
|
|
int SourceLocation::lineLocation() const
|
|
{
|
|
return _line;
|
|
}
|
|
|
|
void SourceLocation::setLineLocation(int l)
|
|
{
|
|
_line = l;
|
|
}
|
|
|
|
int SourceLocation::columnLocation() const
|
|
{
|
|
return _column;
|
|
}
|
|
|
|
void SourceLocation::setColumnLocation(int c)
|
|
{
|
|
_column = c;
|
|
} |