Fast printer engine with helper functions.

IContainerPrinterMachine

Available since version 1.0 (view source)

not referred automatically

extensions of this protocol on existing types are forbidden (performance and/or backwards compatibility reasons).

A protocol for container printer machine. Is used in the printer engine to process potentionally nested data containers.

-children

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (-children this parents)

Type signature:
  • (Any ⨯ IPersistentList) → []

Returns the collection of child items which should be printed before this printer machine can complete. parents contains list of parent machines, including this and top container.

-print-before!

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (-print-before! this bm batch parents)

Type signature:
  • (Any ⨯ BatchManager ⨯ AnyBatch ⨯ IPersistentList) → (Maybe AnyBatch)

Returns the batch of printed values which should be put before child items. Returns nil if printed values were instead put into batch or if no prefix was needed. parents contains list of parent machines, including this and top container. Batch manager bm should be used for all batch related things.

-print-after!

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (-print-after! this bm batch parents)

Type signature:
  • (Any ⨯ BatchManager ⨯ AnyBatch ⨯ IPersistentList) → (Maybe AnyBatch)

Returns the batch of printed values which should be put after child items. Returns nil if printed values were instead put into batch or if no postfix was needed. parents contains list of parent machines, including this and top container. Batch manager bm should be used for all batch related things.

-print-between!

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (-print-between! this bm batch parents)

Type signature:
  • (Any ⨯ BatchManager ⨯ AnyBatch ⨯ IPersistentList) → (Maybe AnyBatch)

Returns the separator which should be added between two child items. As the printer machine may keep an internal state, the result from this method is not cached but is called repeatedly between child items.

Returns nil if printed values were put into batch instead or if no separator was needed. parents contains list of parent machines, including this and top container. Batch manager bm should be used for all batch related things.

IIndentedMachine

Available since version 1.0 (view source)

not referred automatically

PROTOCOL with method -indent

A protocol for basic indentation mechanism in printer machines.

-indent

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (-indent this)

Type signature:
  • (Any) → Integer+

Returns indent amount for this machine.

See also: IIndentedMachine

IPrinterMachineFactory

Available since version 1.0 (view source)

not referred automatically

A factory protocol for the execution of a printer engine.

-printer-config

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (-printer-config this)

Type signature:
  • (Any) → {}

Returns a configuration map that is passed into machines created directly or indirectly with this printer machine factory. Passing of configuration map is done by convention as a first argument of machine constructor, with folowing keys recognized by the printer engine and its helper fns:

  • :invalid-item - Controls how machine should behave if unprintable items is passed into the printer. Valid values are nil (throws), :ignore (behave as if there was no such item) or a function which is called with the current config, invalid item, parents and result of which is used for printing instead.

  • :initial-state - specifies an initial state of a printer machine. Can be nil or map

  • :indent-offset - number representing indent offset

  • :indent-size - number representing indent size

  • :color? - boolean flag whether output should be in color

  • :color-fn - fn taking key and returning colorizer batch

  • :string-limit - number representing string character limit

  • :item-limit - number representing item limit

  • :item-limit-batch - batch which should be printed if item limit is reached

  • :level-limit-pred - fn taking list of parents and returns true if level limit has been reached.

  • :level-limit-print-fn - fn taking batch, bm and state, and prints limit batch to batch or returns limit batch.

-printer-from-type

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (-printer-from-type this)

Type signature:
  • (Any) → (U nil Class+ Type)

Returns type of items which are to be printed.

-printer-to-type

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (-printer-to-type this)

Type signature:
  • (Any) → (U nil Class+ Type)

Returns type of printed values.

-top-container

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (-top-container this config state coll)

Type signature:
  • (Any ⨯ {} ⨯ IReference ⨯ (Maybe IRed)) → IContainerPrinterMachine

Returns the top level container printing machine used in the printing engine to process top level items. coll may be nil.

-dispatch-printer

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (-dispatch-printer this config state item bm batch parents)

Type signature:
  • (Any ⨯ {} ⨯ IReference ⨯ Any ⨯ BatchManager ⨯ AnyBatch ⨯ IReference) → Any

Returns a batch of printed values or a container printer machine for printing nested data containers, as a result of printing on a given input item according to the config configuration. parents contains list of parent machines, including top container. Returns nil if printed values were put into batch instead. Dispatcher should use given bm batch manager for all batch related things.