Took so much time to figure the problem, that I thought it can be solved with tuples -) But still I wonder if there is a template/macro that can do something like that, or any suggestions?
type
TMyDataSet = object
id: int64
a, b: int
name: string
com: TDescription
# parses string and sets variable i according to its string representation
proc fromString(i: var int64, s: string)
proc fromString(i: var int, s: string)
proc fromString(i: var string, s: string)
proc fromString(i: var TDescription, s: string)
var
rows: seq[string] = ... some array of strings ...
myDataSet: TMyDataSet
# here myDataSet fields become initialized from array of strings, converting each string using one of fromString overloaded proc on corresponding field
# rows index for the field is taken from the position of the field in the supplied "array"
# some pseudo call code, should associate rows[position of field name in the provided sequence] to TMyDataSet field and call fromString on it.
myDataSet.fromStrings([name, id, a, com, b], rows)
proc fromString(d: var TMyDataSet, rows: seq[string]) =
var k = 0
for f in fields(d):
fromString(f, rows[k])
inc(k)
assert k == rows.len