Error context for a failed parse, such as the error reason, line, and character offset.
More...
#include "donner/base/FileOffset.h"
|
| struct | LineInfo |
| | Represents line information within a file, including the line number and the character offset on that line. More...
|
|
| FileOffset | resolveOffset (std::string_view sourceString) const |
| | Return the actual offset of the error in the string, resolving the character offset to a location inside the source string.
|
| FileOffset | addParentOffset (FileOffset parentOffset) const |
| | Assuming this FileOffset is from a subparser that ran on a substring of the original string, take the resulting FileOffset and convert it back to absolute coordinates.
|
|
bool | operator== (const FileOffset &other) const |
| | Equality operator.
|
|
|
std::optional< size_t > | offset |
| | Character offset of the error in the string, if known.
|
|
std::optional< LineInfo > | lineInfo |
| | Line information for multi-line strings, if known.
|
|
|
std::ostream & | operator<< (std::ostream &os, const FileOffset &value) |
| | Print the offset to an ostream.
|
Error context for a failed parse, such as the error reason, line, and character offset.
◆ addParentOffset()
| FileOffset donner::FileOffset::addParentOffset |
( |
FileOffset | parentOffset | ) |
const |
|
inlinenodiscard |
Assuming this FileOffset is from a subparser that ran on a substring of the original string, take the resulting FileOffset and convert it back to absolute coordinates.
- Parameters
-
| parentOffset | Offset of the current string in the parent parser. |
◆ Offset()
| FileOffset donner::FileOffset::Offset |
( |
size_t | offset | ) |
|
|
inlinestatic |
Create a FileOffset for a single-line string.
- Parameters
-
| offset | Character offset of the error in the string. |
◆ OffsetWithLineInfo()
| FileOffset donner::FileOffset::OffsetWithLineInfo |
( |
size_t | offset, |
|
|
LineInfo | lineInfo ) |
|
inlinestatic |
Create a FileOffset for a multi-line string.
- Parameters
-
| line | Line number of the error. |
| offset | Character offset of the error in the string. |
◆ resolveOffset()
| FileOffset donner::FileOffset::resolveOffset |
( |
std::string_view | sourceString | ) |
const |
|
inline |
Return the actual offset of the error in the string, resolving the character offset to a location inside the source string.
- Parameters
-
| sourceString | Corresponding string containing the file source, used to resolve the string offset. |
- Returns
- Resolved offset with EndOfString() converted to the length of the source string.
The documentation for this struct was generated from the following file: