Proposal: RBBI, support multiple rule status values

Andy Heninger <[email protected]> Mon, 01 Mar 2004 13:05:58 -0800
Newsgroups gmane.comp.lib.icu.general
Message-ID <[email protected]>
This is a proposal to extend RBBI to allow finding out the full set of 
break rules that matched for a given boundary position.

 From Jitterbug #3043,

> RFE, RBBI, provide for multiple rule status returns.
> 
> More than one rule may yield a given text boundary.  When this happens,
> getRuleStatus()  can currently only return one value, and it will choose the
> largest value from the available rules.  We could have an alternative
> getRuleStatus() API that made the values for all matching rules available.

Here is a proposal for the new API

class RulesBasedBreakIterator {
    ...
public:
    // Existing API
    virtual int32_t getRuleStatus() const;

    // new API
    virtual int32_t getRuleStatusVec(
         int32_t * vec,                 // Array to fill in with
                                        // status values.
         int32_t   capacity) const      // capacity of vec array.


The return value from the new function would be the number of available 
status values (which might be larger than the capacity of the 
destination array.)

The vector of status values would not be zero terminated.  A termination 
  doesn't make sense, because zero is a very common status value, and 
because there is no reserved status value.

A capacity of zero, or a NULL pointer for the vec parameter would cause 
the function to return the number of matching rules (the number of 
available status values), without returning the status values themselves.



The plain C API would be similar:

int32_t ubrk_getRuleStatusVec (
         UBreakIterator *bi, int32_t *vec, int32_t capacity);


-- 
   -- Andy Heninger
      [email protected]