grim/box

Types

Box = object
  case kind: BoxKind
  of bxInt:
    intVal: BiggestInt
  of bxStr:
    strVal: string
  of bxFloat:
    floatVal: float
  of bxBool:
    boolVal: bool
  of bxNull:
    nil
  
  Source Edit

Procs

proc `$`(b: Box): string {...}{.raises: [], tags: [].}
Stringify the value in the box.   Source Edit
proc describe(b: Box): string {...}{.raises: [], tags: [].}
Pretty-print the value and its kind in the box.   Source Edit
proc initBox(): Box {...}{.raises: [], tags: [].}
Init an empty Box   Source Edit
proc initBox(value: BiggestInt): Box {...}{.raises: [], tags: [].}
Init a new integer Box   Source Edit
proc initBox(value: string): Box {...}{.raises: [], tags: [].}
Init a new String Box   Source Edit
proc initBox(value: float): Box {...}{.raises: [], tags: [].}
Init a new float Box   Source Edit
proc initBox(value: bool): Box {...}{.raises: [], tags: [].}
Init a new boolean Box   Source Edit
proc guessBox(s: string): Box {...}{.raises: [ValueError], tags: [].}
Return Box corresponding to (guessed) type contained in string   Source Edit
proc getStr(b: Box): string {...}{.raises: [], tags: [].}
Get string value in the box.   Source Edit
proc getStr(b: Box; default: string): string {...}{.raises: [], tags: [].}
Return a default value for a string box.   Source Edit
proc getInt(b: Box): BiggestInt {...}{.raises: [], tags: [].}
Get integer value in the box.   Source Edit
proc getInt(b: Box; default: BiggestInt): BiggestInt {...}{.raises: [], tags: [].}
Return a default value for an integer box.   Source Edit
proc getFloat(b: Box): float {...}{.raises: [], tags: [].}
Get float value in the box.   Source Edit
proc getFloat(b: Box; default: float): float {...}{.raises: [], tags: [].}
Return a default value for a float box.   Source Edit
proc getBool(b: Box): bool {...}{.raises: [], tags: [].}
Get boolean value in the box.   Source Edit
proc getBool(b: Box; default: bool): bool {...}{.raises: [], tags: [].}
Return a default value for a boolean box.   Source Edit
proc isEmpty(b: Box): bool {...}{.raises: [], tags: [].}
Check if Box is empty   Source Edit
proc update(b: var Box; value: BiggestInt) {...}{.raises: [], tags: [].}
Update value in integer box   Source Edit
proc update(b: var Box; value: float) {...}{.raises: [], tags: [].}
Update value in float box   Source Edit
proc update(b: var Box; value: string) {...}{.raises: [], tags: [].}
Update value in string box   Source Edit
proc update(b: var Box; value: bool) {...}{.raises: [], tags: [].}
Update value in boolean box   Source Edit
proc `==`(self, other: Box): bool {...}{.raises: [], tags: [].}
Check if self.value == other.value for two boxes, different box kinds returns false.   Source Edit
proc `!=`(self, other: Box): bool {...}{.raises: [], tags: [].}
Check if self.value != other.value for two boxes, different box kinds returns false.   Source Edit
proc `<`(self, other: Box): bool {...}{.raises: [], tags: [].}
Check if self.value < other.value for two boxes, different box kinds returns false.   Source Edit
proc `<=`(self, other: Box): bool {...}{.raises: [], tags: [].}
Check if self.value <= other.value for two boxes, different box kinds returns false.   Source Edit
proc `>`(self, other: Box): bool {...}{.raises: [], tags: [].}
Check if self.value > other.value for two boxes, different box kinds returns false.   Source Edit
proc `>=`(self, other: Box): bool {...}{.raises: [], tags: [].}
Check if self.value >= other.value for two boxes, different box kinds returns false.   Source Edit
proc `==`[T](self: Box; value: T): bool
Check if the value of a box is == some value, value not of box kind returns false.   Source Edit
proc `!=`[T](self: Box; value: T): bool
Check if the value of a box is != some value, value not of box kind returns false.   Source Edit
proc `<`[T](self: Box; value: T): bool
Check if the value of a box is < some value, value not of box kind returns false.   Source Edit
proc `<=`[T](self: Box; value: T): bool
Check if the value of a box is <= some value, value not of box kind returns false.   Source Edit
proc `>`[T](self: Box; value: T): bool
Check if the value of a box is > some value, value not of box kind returns false.   Source Edit
proc `>=`[T](self: Box; value: T): bool
Check if the value of a box is >= some value, value not of box kind returns false.   Source Edit
proc `%`(t: tuple): Table[string, Box]
Convert tuple to Table[string, Box]   Source Edit
proc toTable(j: JsonNode): Table[string, Box] {...}{.raises: [ValueError], tags: [].}
Convert JsonNode with simple values to table with boxes.   Source Edit
proc `$`(t: Table[string, Box]): string {...}{.raises: [], tags: [].}
Pretty-print String table with Boxes   Source Edit