Blang/src/lib/SourceLocation.cpp

62 lines
970 B
C++

#include <iostream>
#include "SourceLocation.hpp"
SourceLocation::SourceLocation(std::string file, int line, int column, int offset):
_file(file),
_line(line),
_column(column),
_offset(offset)
{
}
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;
}
int SourceLocation::offset() const
{
return _offset;
}
void SourceLocation::setOffset(int offset)
{
_offset = offset;
}