Clingo
|
Class representing a position in a file. More...
#include <core.hh>
Public Member Functions | |
Position (clingo_position_t const *pos) | |
Constructs a position from an existing C representation. | |
Position (Library const &lib, std::string_view file, size_t line, size_t column) | |
Constructs a position from a file, line, and column. | |
auto | file () const -> std::string_view |
Get the file name of the position. | |
auto | line () const -> size_t |
Get the line number of the position. | |
auto | column () const -> size_t |
Get the column number of the position. | |
auto | to_string () const -> std::string |
Convert the position to a string representation. | |
auto | hash () const noexcept -> size_t |
Compute the hash of the position. | |
Friends | |
auto | c_cast (Position const &x) -> clingo_position_t const * |
Cast a position to its C representation. | |
auto | operator== (Position const &a, Position const &b) noexcept -> bool |
Compare two positions for equality. | |
auto | operator<=> (Position const &a, Position const &b) noexcept -> std::strong_ordering |
Compare two positions. | |
Class representing a position in a file.
Positions implement value semantics supporting ordering and hashing.
|
inlineexplicit |
Constructs a position from an existing C representation.
For internal use.
pos | the C representation of the position |
|
inlineexplicit |
Constructs a position from a file, line, and column.
lib | the library to store symbols |
file | the file name |
line | the line number (1-based) |
column | the column number (1-based) |
Get the column number of the position.
|
inline |
Get the file name of the position.
Compute the hash of the position.
There is also a corresponding specialization of std::hash.
Get the line number of the position.
|
inline |
Convert the position to a string representation.
|
friend |
Cast a position to its C representation.
x | the position to cast |
Compare two positions.
a | the first position to compare |
b | the second position to compare |
Compare two positions for equality.
a | the first position to compare |
b | the second position to compare |