src/kdl/utils

Source   Edit  

Various utilities for internal use in the library.

Types

Coord = object
  line*, col*, idx*: int
Source   Edit  
KdlSome = (KdlDoc or KdlNode or KdlVal)
Source   Edit  
List = (array or seq)
Source   Edit  
Object = ((object or tuple) and not KdlSome and not SomeTable and not List and
    not Value and
    not SomeSet)
Source   Edit  
SomeTable[K; V] = (Table[K, V] or OrderedTable[K, V])
Source   Edit  
Value = (SomeNumber or string or bool)
Source   Edit  

Consts

escapeTable = (data: [(0, 0, ""), (0, 0, ""), (0, 0, ""), (0, 0, ""),
                      (0, 0, ""), (0, 0, ""), (0, 0, ""),
                      (-8648592263744955225, 92, "\\"),
                      (-4478592245859895240, 98, "\b"),
                      (4641731221724435865, 114, "\r"),
                      (-5340964688531826903, 47, "/"),
                      (-8804310308688710565, 34, "\""),
                      (8394969970134436156, 110, "\n"),
                      (517012403755787147, 102, "\f"), (0, 0, ""),
                      (-4708809695820797393, 116, "\t")], counter: 8)
Source   Edit  

Procs

proc eqIdent(v, a: openArray[char]; ignoreChars = {'_', '-'}): bool {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc errorAt(s: Stream; coord: Coord): string {....raises: [IOError, OSError],
    tags: [ReadIOEffect], forbids: [].}
Source   Edit  
proc errorAt(s: string; coord: Coord): string {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc getCoord(s: Stream; i: int): Coord {....raises: [IOError, OSError],
    tags: [ReadIOEffect], forbids: [].}
Source   Edit  
proc getCoord(s: string; at: int): Coord {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc peekLineFromStart(s: Stream): string {....raises: [IOError, OSError],
    tags: [ReadIOEffect], forbids: [].}
Source   Edit  
proc peekLineFromStart(s: string; at: int): string {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc peekRune(s: Stream): Rune {....raises: [IOError, OSError],
                                 tags: [ReadIOEffect], forbids: [].}
Source   Edit  
proc quoted(x: string): string {....raises: [], tags: [], forbids: [].}
Source   Edit  

Macros

macro getDiscriminants(a: typedesc): seq[string]
return the discriminant keys Source   Edit  
macro initCaseObject(T: typedesc; discriminatorSetter): untyped
Does the minimum to construct a valid case object T.
  • discriminatorSetter: called passing two arguments (key, typ) (key being the field name and typ the field type), last expression should be the value for the field. Only for discriminator fields.
Source   Edit  
macro isObjVariant(a: typedesc): bool
Source   Edit  

Templates

template check(cond: untyped; msg = "")
Source   Edit  
template fail(msg: string)
Source   Edit  
template typeofdesc[T](b: typedesc[T]): untyped
Source   Edit