Fork me on GitHub
NimYAML Home Testing Ground Docs: Overview Serialization Modules

Module yaml.hints

Search:
Group by:

The hints API enables you to guess the type of YAML scalars.

Imports

macros, private/internal

Types

TypeHint = enum
  yTypeInteger, yTypeFloat, yTypeFloatInf, yTypeFloatNaN, yTypeBoolTrue,
  yTypeBoolFalse, yTypeNull, yTypeUnknown, yTypeTimestamp

A type hint can be computed from scalar content and tells you what NimYAML thinks the scalar's type is. It is generated by guessType The first matching RegEx in the following table will be the type hint of a scalar string.

You can use it to determine the type of YAML scalars that have a '?' non-specific tag, but using this feature is completely optional.

NameRegEx
yTypeInteger0 | -? [1-9] [0-9]*
yTypeFloat-? [1-9] ( \. [0-9]* [1-9] )? ( e [-+] [1-9] [0-9]* )?
yTypeFloatInf-? \. (inf | Inf | INF)
yTypeFloatNaN-? \. (nan | NaN | NAN)
yTypeBoolTruey|Y|yes|Yes|YES|true|True|TRUE|on|On|ON
yTypeBoolFalsen|N|no|No|NO|false|False|FALSE|off|Off|OFF
yTypeNull~ | null | Null | NULL
yTypeTimestampsee here.
yTypeUnknown*
  Source

Procs

proc guessType(scalar: string): TypeHint {.
raises: [], tags: []
.}
Parse scalar string according to the RegEx table documented at TypeHint.   Source