25 bool operator==(
const Stdin & rhs)
const
26 {
return *source == *rhs.source; }
27 bool operator!=(
const Stdin & rhs)
const
28 {
return *source != *rhs.source; }
29 bool operator<(
const Stdin & rhs)
const
30 {
return *source < *rhs.source; }
34 bool operator==(
const String & rhs)
const
35 {
return *source == *rhs.source; }
36 bool operator!=(
const String & rhs)
const
37 {
return *source != *rhs.source; }
38 bool operator<(
const String & rhs)
const
39 {
return *source < *rhs.source; }
42 auto operator<=>(
const Hidden &)
const =
default;
45 typedef std::variant<std::monostate, Stdin, String, CheckedSourcePath, Hidden> Origin;
47 Origin origin = std::monostate();
50 Pos(uint32_t line, uint32_t column, Origin origin)
51 : line(line), column(column), origin(origin) { }
52 Pos(Pos & other) =
default;
53 Pos(
const Pos & other) =
default;
54 Pos(Pos && other) =
default;
55 Pos(
const Pos * other);
57 explicit operator bool()
const {
return line > 0; }
59 operator std::shared_ptr<Pos>()
const;
64 std::optional<std::string>
getSource()
const;
66 void print(std::ostream & out,
bool showOrigin)
const;
68 std::optional<LinesOfCode> getCodeLines()
const;
70 bool operator==(
const Pos & rhs)
const =
default;
71 bool operator!=(
const Pos & rhs)
const =
default;
72 bool operator<(
const Pos & rhs)
const;
75 using difference_type = size_t;
76 using value_type = std::string_view;
77 using reference =
const std::string_view &;
78 using pointer =
const std::string_view *;
79 using iterator_category = std::input_iterator_tag;
82 explicit LinesIterator(std::string_view input): input(input), pastEnd(input.empty()) {
97 reference operator*()
const {
return curLine; }
98 pointer operator->()
const {
return &curLine; }
101 return !(*
this == other);
104 return (pastEnd && other.pastEnd)
105 || (std::forward_as_tuple(input.size(), input.data())
106 == std::forward_as_tuple(other.input.size(), other.input.data()));
110 std::string_view input, curLine;
111 bool pastEnd =
false;
113 void bump(
bool atFirst);