Chlumsky/json-cpp-gen

Custom number type

Chlumsky opened this issue · 0 comments

Add the possibility to define custom number types (integer or real), e.g. a dynamic-sized "big integer" type. The parser API could look like this:

  • clear - sets $S to zero
  • appendDigit - appends (decimal) digit $X to the whole part ot $S - equivalent to 10*$S+$X, $E is VALUE_OUT_OF_RANGE error statement
  • appendFractionalDigit - appends $I-th (decimal) fractional digit $X to $S, if left blank, the type is assumed to be integer-only
  • setExponent - multiplies $S by 10 to the power of $X
  • makeNegative - changes the value to negative, guaranteed to be called at the end

Or, instead of the last two, there could be finalize with arguments for sign and exponent.