mirror of
https://github.com/NixOS/nix.git
synced 2025-11-13 22:12:43 +01:00
libutil: Document hacks and problems around Pos class
This should provide context for follow-up commits in
the patch series.
(cherry picked from commit bf12aedf2e)
This commit is contained in:
parent
6384a65baf
commit
5a3b0d9c7a
3 changed files with 20 additions and 0 deletions
|
|
@ -76,6 +76,17 @@ public:
|
|||
return PosIdx(1 + origin.offset + offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a byte-offset PosIdx into a Pos with line/column information.
|
||||
*
|
||||
* @param p Byte offset into the virtual concatenation of all parsed contents
|
||||
* @return Position
|
||||
*
|
||||
* @warning Very expensive to call, as this has to read the entire source
|
||||
* into memory each time. Call this only if absolutely necessary. Prefer
|
||||
* to keep PosIdx around instead of needlessly converting it into Pos by
|
||||
* using this lookup method.
|
||||
*/
|
||||
Pos operator[](PosIdx p) const;
|
||||
|
||||
Pos::Origin originOf(PosIdx p) const
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue