next up previous contents index
次へ: Operations 上へ: Option Descriptor Type 戻る: Option Capabilities   目次   索引

Option Value Constraints

It is often useful to constrain the values that an option can take. For example, constraints can be used by a frontend to determine how to represent a given option. Member constraint_type indicates what constraint is in effect for the option. The constrained values that are allowed for the option are described by one of the union members of member constraint. The possible values of type SANE_Constraint_Type and the interpretation of the constraint union is described in Table 4.6.


表 4.6: Option Value Constraints
Symbol Code Description

SANE_CONSTRAINT_NONE

0 The value is unconstrained. The option can take any of the values possible for the option's type.
SANE_CONSTRAINT_RANGE 1 This constraint is applicable to integer and fixed-point valued options only. It constrains the option value to a possibly quantized range of numbers. Option descriptor member constraint.range points to a range of the type SANE_Range. This type is illustrated below:
typedef struct
  {
    SANE_Word min;
    SANE_Word max;
    SANE_Word quant;
  }
SANE_Range;
All three members in this structure are interpreted according to the option value type (SANE_TYPE_INT or SANE_TYPE_FIXED). Members min and max specify the minimum and maximum values, respectively. If member quant is non-zero, it specifies the quantization value. If $l$ is the minimum value, $u$ the maximum value and $q$ the (non-zero) quantization of a range, then the legal values are $v=k\cdot q+l$ for all non-negative integer values of $k$ such that $v<=u$.
SANE_CONSTRAINT_WORD_LIST 2 This constraint is applicable to integer and fixed-point valued options only. It constrains the option value to a list of numeric values. Option descriptor member constraint.word_list points to a list of words that enumerates the legal values. The first element in that list is an integer (SANE_Int) that specifies the length of the list (not counting the length itself). The remaining elements in the list are interpreted according to the type of the option value (SANE_TYPE_INT or SANE_TYPE_FIXED).
SANE_CONSTRAINT_STRING_LIST 3 This constraint is applicable to string-valued options only. It constrains the option value to a list of strings. The option descriptor member constraint.string_list points to a NULL terminated list of strings that enumerate the legal values for the option value.



next up previous contents index
次へ: Operations 上へ: Option Descriptor Type 戻る: Option Capabilities   目次   索引
MATSUBAYASHI 'Shaolin' Kohji 平成14年10月29日