Add column to source_location
This commit is contained in:
parent
3ae969aaae
commit
35293edc24
2 changed files with 27 additions and 15 deletions
|
|
@ -17,30 +17,33 @@ namespace cppast
|
|||
{
|
||||
type_safe::optional<std::string> entity;
|
||||
type_safe::optional<std::string> file;
|
||||
type_safe::optional<unsigned> line;
|
||||
type_safe::optional<unsigned> line, column;
|
||||
|
||||
/// \returns A source location where all information is available.
|
||||
static source_location make(std::string entity, std::string file, unsigned line)
|
||||
static source_location make(std::string entity, std::string file, unsigned line,
|
||||
unsigned column)
|
||||
{
|
||||
return {std::move(entity), std::move(file), line};
|
||||
return {std::move(entity), std::move(file), line, column};
|
||||
}
|
||||
|
||||
/// \returns A source location where only file and line information is available.
|
||||
static source_location make_file(std::string file, unsigned line)
|
||||
/// \returns A source location where only file information is available.
|
||||
static source_location make_file(std::string file,
|
||||
type_safe::optional<unsigned> line = type_safe::nullopt,
|
||||
type_safe::optional<unsigned> column = type_safe::nullopt)
|
||||
{
|
||||
return {type_safe::nullopt, std::move(file), line};
|
||||
}
|
||||
|
||||
/// \returns A source location where only the file is available.
|
||||
static source_location make_file(std::string file)
|
||||
{
|
||||
return {type_safe::nullopt, std::move(file), type_safe::nullopt};
|
||||
return {type_safe::nullopt, std::move(file), line, column};
|
||||
}
|
||||
|
||||
/// \returns A source location where only the entity name is available.
|
||||
static source_location make_entity(std::string entity)
|
||||
{
|
||||
return {std::move(entity), type_safe::nullopt, type_safe::nullopt};
|
||||
return {std::move(entity), type_safe::nullopt, type_safe::nullopt, type_safe::nullopt};
|
||||
}
|
||||
|
||||
/// \returns A source location where no information is avilable.
|
||||
static source_location make_unknown()
|
||||
{
|
||||
return {type_safe::nullopt, type_safe::nullopt, type_safe::nullopt, type_safe::nullopt};
|
||||
}
|
||||
|
||||
/// \returns A possible string representation of the source location.
|
||||
|
|
@ -51,8 +54,17 @@ namespace cppast
|
|||
if (file)
|
||||
{
|
||||
result += file.value() + ":";
|
||||
|
||||
if (line)
|
||||
result += std::to_string(line.value()) + ":";
|
||||
{
|
||||
result += std::to_string(line.value());
|
||||
|
||||
if (column)
|
||||
result += "," + std::to_string(column.value());
|
||||
|
||||
result += ":";
|
||||
}
|
||||
|
||||
if (entity)
|
||||
result += " (" + entity.value() + "):";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ namespace
|
|||
DEBUG_ASSERT(*ptr == ':', detail::assert_handler{});
|
||||
++ptr;
|
||||
|
||||
return {type_safe::nullopt, std::move(filename), std::move(line)};
|
||||
return {type_safe::nullopt, std::move(filename), std::move(line), type_safe::nullopt};
|
||||
}
|
||||
|
||||
severity parse_severity(const char*& ptr)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue