Next: , Previous: Ranges, Up: Ranges   [Contents]


3.1 rangef_parse

parse a list of floating point ranges

Synopsis

#include <suplib/range.h>

RangeErr rangef_parse(
  RangeFList **rfl,
  char *range_spec,
  RangeOpts opts,
  double minval,
  double maxval,
  long *where
);

Parameters

RangeFList **rfl

returned list of ranges

char *range_spec

string containing range to parse

RangeOpts opts

range options


Possible values for a RangeOpts are as follows: Range_SORT, Range_MERGE, Range_INCOMPLETE, Range_UNSIGNED

double minval

replacement value for incomplete start

double maxval

replacement value for incomplete end

long *where

position in string where error occurred

Description

rangef_parse translate a list of ranges of the form "r1,r2,r3,r4" into start-end pairs. a range has the format:

[start]{ `:' | `(' | `)' | `~' }[end]

where start and end are optional limits on the range.

Returns

It returns a code indicating whether an error ocurred. (See suplib/range.h for the possible errors, and codes. It also returns the location of the error in the range specification via the passed where variable.


Possible values for a RangeErr are as follows:

RangeErr_OK

no error

RangeErr_NOMEM

out of memory

RangeErr_INCOMPLETE

incomplete range

RangeErr_ERANGE

number out of bounds

RangeErr_ILLNUM

not a number

RangeErr_NEGNUM

negative number

RangeErr_OFLOWSTART

overflow of start value

RangeErr_NONPOSCOUNT

non-positive count

RangeErr_OFLOWEND

overflow of end value

RangeErr_INTERNAL

internal error

RangeErr_ORDER

start greater than end

RangeErr_EMPTY

float range is empty set

RangeErr_MAXERR

The Range Operators Are As Follows

:

range from start to end, inclusive of both.

(

range from start to end, exclusive of end.

)

range from start to end, exclusive of start.

~

range from start to end, exclusive of both.

The handling of the ranges depends upon the flags set in the opts arguement. opts is set to the logical OR of zero or more of the following values

Range_SORT

The resultant ranges will be sorted in ascending order by their lower bound

Range_MERGE

Adjacent ranges will be merged, if possible. This implies Range_SORT.

Range_INCOMPLETE

If set, incomplete ranges, i.e., those without an explicit start or end value, are accepted. In this case, implied starts are set to the value of the passed minval argument, while implied ends are set to the value of the maxval argument.

rangef_parse creates a RangeFList object and returns it via the rfl parameter.

Author

Diab Jerius


Next: , Previous: Ranges, Up: Ranges   [Contents]