scala.io
object Position

[source: `scala/io/Position.scala`]

`` `object` Position
  `extends` AnyRef

  The object `Position` provides convenience methods to encode line and column number in one single integer. The encode line (column) numbers range from 0 to `LINE_MASK` (`COLUMN_MASK`), where 0 indicates that the line (column) is the undefined and 1 represents the first line (column). Line (Column) numbers greater than `LINE_MASK` (`COLUMN_MASK`) are replaced by `LINE_MASK` (`COLUMN_MASK`). Furthermore, if the encoded line number is `LINE_MASK`, the column number is always set to 0.

  The following properties hold:

  - the undefined position is 0: `encode(0,0) == 0`
  - encodings are non-negative : `encode(line,column) >= 0`
  - position order is preserved: `(line1 < line2) || (line1 == line2 && column1 < column2)`
    implies
    `encode(line1,column1) <= encode(line2,column2)`

Author
  Burak Emir (translated from work by Matthias Zenger and others)

Value Summary
`final val` | COLUMN_BITS : Int = 11 Number of bits used to encode the column number
`final val` | COLUMN_MASK : Int = 2047 Mask to decode the column number
`final val` | FIRSTPOS : Int The first position in a source file
`final val` | LINE_BITS : Int = 20 Number of bits used to encode the line number
`final val` | LINE_MASK : Int = 1048575 Mask to decode the line number
`final val` | NOPOS : Int = 0 The undefined position

Method Summary
`final def` | column (pos : Int) : Int Returns the column number of the encoded position.
`final def` | encode (line : Int, column : Int) : Int Encodes a position into a single integer.
`final def` | line (pos : Int) : Int Returns the line number of the encoded position.
`def` | toString (pos : Int) : String Returns a string representation of the encoded position.

Methods inherited from AnyRef
getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized

Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf

Value Details

`final` `val` LINE_BITS : Int

  Number of bits used to encode the line number

`final` `val` COLUMN_BITS : Int

  Number of bits used to encode the column number

`final` `val` LINE_MASK : Int

  Mask to decode the line number

`final` `val` COLUMN_MASK : Int

  Mask to decode the column number

`final` `val` NOPOS : Int

  The undefined position

`final` `val` FIRSTPOS : Int

  The first position in a source file

Method Details

`final` `def` encode(line : Int, column : Int) : Int

  Encodes a position into a single integer.

`final` `def` line(pos : Int) : Int

  Returns the line number of the encoded position.

`final` `def` column(pos : Int) : Int

  Returns the column number of the encoded position.

`` `def` toString(pos : Int) : String

  Returns a string representation of the encoded position.