1// Position support for go-toml
2
3package toml
4
5import (
6	"fmt"
7)
8
9// Position of a document element within a TOML document.
10//
11// Line and Col are both 1-indexed positions for the element's line number and
12// column number, respectively.  Values of zero or less will cause Invalid(),
13// to return true.
14type Position struct {
15	Line int // line within the document
16	Col  int // column within the line
17}
18
19// String representation of the position.
20// Displays 1-indexed line and column numbers.
21func (p Position) String() string {
22	return fmt.Sprintf("(%d, %d)", p.Line, p.Col)
23}
24
25// Invalid returns whether or not the position is valid (i.e. with negative or
26// null values)
27func (p Position) Invalid() bool {
28	return p.Line <= 0 || p.Col <= 0
29}
30