Next: units_cvt, Previous: Setting up the structures, Up: Units
parse a string composed of a floating point number and a units specification.
#include <suplib/units.h>int units_parse( const char *spec, UnitVal *uv, const UnitsList *list );
const char *spec
- the specification to parse
UnitVal *uv
- the resultant number and unit id
const UnitsList *list
- the list of units
This routine parses a string composed of a floating point number and a units specification (e.g. ‘1mm’, ‘23 arcsec’). White space between the number and the unit is ignored. The caller must ensure that there is no white space following the unit specification.
The parsed number and the unit id are written into the passed
UnitVal
structure. The unit
element is only changed
if a valid unit was found. units_parse
returns a
UNITS_ParseErr
consistent with the results of the parse:
UNITS_OK
UNITS_BADNUM
UNITS_NOSPEC
UNITS_BADSPEC
Diab Jerius