NimYAML Home Testing Ground Docs: Overview Serialization Modules NimYAML 2.x Source on GitHub

Module yaml/hints

Group by:

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




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.

See also:

yTypeInteger[-+]? [0-9]+
yTypeFloat[-+]? ( \. [0-9]+ | [0-9]+ ( \. [0-9]* )? ) ( [eE] [-+]? [0-9]+ )?
yTypeFloatInf[-+]? ( \.inf | \.Inf | \.INF )
yTypeFloatNaN\.nan | \.NaN | \.NAN
yTypeBoolTruetrue | True | TRUE
yTypeBoolFalsefalse | False | FALSE
yTypeNullnull | Null | NULL | ~
yTypeTimestampsee here.


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