Types
FieldedType = (object | ref object | tuple)
- Source Edit
FieldMapping = object input*: InputFieldMapping output*: OutputFieldMapping
- mapping options for a type field Source Edit
FieldMappingArg = concept proc toFieldMapping(self: Self): FieldMapping
- argument allowed for mapping pragma Source Edit
FieldMappingPairs = seq[(string, FieldMapping)]
- Source Edit
InputFieldMapping = object names*: seq[NamePattern] ## names that are accepted for this field when encountered in input ## if none are given, a default set of names can be used instead ignore*: bool ## whether or not to ignore a field when encountered in input
- mapped values for input of a field Source Edit
NamePattern = object case kind*: NamePatternKind of NoName: nil of NameOriginal: nil of NameString: str*: string of NameSnakeCase: nil of NameConcat: concat*: seq[NamePattern]
- string pattern to apply to a given field name to use in mapping Source Edit
NamePatternKind = enum NoName, NameOriginal, ## uses the field name NameString, ## uses custom string and ignores field name NameSnakeCase, ## converts field name to snake case NameConcat
- Source Edit
OutputFieldMapping = object name*: NamePattern ## name for this field in output ## if not given or set to `NoName`, a default name can be used instead ignore*: bool ## whether or not to ignore a field when generating output
- Source Edit
Procs
proc apply(pattern: NamePattern; name: string): string {....raises: [], tags: [], forbids: [].}
- applies a name pattern to a given name Source Edit
proc getInputNames(fieldName: string; options: FieldMapping; default: seq[NamePattern]): seq[string] {....raises: [], tags: [], forbids: [].}
- gives the names accepted for this field when encountered in input if none are given, this defaults to the patterns in default Source Edit
proc getOutputName(fieldName: string; options: FieldMapping; default: NamePattern): string {....raises: [], tags: [], forbids: [].}
- gives the name for this field in output if not given, this defaults to the pattern in default Source Edit
proc hasInputNames(options: FieldMapping): bool {....raises: [], tags: [], forbids: [].}
- Source Edit
proc hasOutputName(options: FieldMapping): bool {....raises: [], tags: [], forbids: [].}
- Source Edit
proc ignore(): FieldMapping {....raises: [], tags: [], forbids: [].}
- creates a field option object that ignores this field in both serialization and deserialization Source Edit
proc snakeCase(): NamePattern {....raises: [], tags: [], forbids: [].}
- creates a name pattern that just converts a field name to snake case Source Edit
proc toFieldMapping(enabled: bool): FieldMapping {....raises: [], tags: [], forbids: [].}
- hook called on the argument to the mapping pragma to convert it to a full field option object, for a bool this sets whether or not to enable serialization and deserialization for this field Source Edit
proc toFieldMapping(input: InputFieldMapping): FieldMapping {.inline, ...raises: [], tags: [], forbids: [].}
- hook called on the argument to the mapping pragma to convert it to a full field option object Source Edit
proc toFieldMapping(name: NamePattern): FieldMapping {....raises: [], tags: [], forbids: [].}
- hook called on the argument to the mapping pragma to convert it to a full field option object, for a name pattern this sets both the serialization and deserialization name of the field to it Source Edit
proc toFieldMapping(name: string): FieldMapping {....raises: [], tags: [], forbids: [].}
- hook called on the argument to the mapping pragma to convert it to a full field option object, for a string this sets both the serialization and deserialization name of the field to it Source Edit
proc toFieldMapping(options: FieldMapping): FieldMapping {.inline, ...raises: [], tags: [], forbids: [].}
- hook called on the argument to the mapping pragma to convert it to a full field option object Source Edit
proc toFieldMapping(output: OutputFieldMapping): FieldMapping {.inline, ...raises: [], tags: [], forbids: [].}
- hook called on the argument to the mapping pragma to convert it to a full field option object Source Edit
proc toName(str: string): NamePattern {....raises: [], tags: [], forbids: [].}
- creates a name pattern that uses a specific string instead of the field name Source Edit
proc verbatim(): NamePattern {....raises: [], tags: [], forbids: [].}
- Source Edit
Templates
template mapping(group: static MappingGroup; options: FieldMapping) {.pragma.}
- sets the mapping options for a field filtered to formats encompassed by the given mapping group Source Edit
template mapping(group: static MappingGroup; options: FieldMappingArg) {.pragma.}
- convenience wrapper that calls toFieldMapping on the given argument filtered to formats encompassed by the given mapping group Source Edit
template mapping(options: FieldMapping) {.pragma.}
- sets the mapping options for a field Source Edit
template mapping(options: FieldMappingArg) {.pragma.}
- convenience wrapper that calls toFieldMapping on the given argument Source Edit