00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef USEARCH_H
00010 #define USEARCH_H
00011
00012 #include "unicode/utypes.h"
00013
00014 #if !UCONFIG_NO_COLLATION && !UCONFIG_NO_BREAK_ITERATION
00015
00016 #include "unicode/localpointer.h"
00017 #include "unicode/ucol.h"
00018 #include "unicode/ucoleitr.h"
00019 #include "unicode/ubrk.h"
00020
00145 #define USEARCH_DONE -1
00146
00151 struct UStringSearch;
00156 typedef struct UStringSearch UStringSearch;
00157
00161 typedef enum {
00166 USEARCH_OVERLAP = 0,
00167 #ifndef U_HIDE_DEPRECATED_API
00168
00182 USEARCH_CANONICAL_MATCH = 1,
00183 #endif
00184
00189 USEARCH_ELEMENT_COMPARISON = 2,
00190
00195 USEARCH_ATTRIBUTE_COUNT = 3
00196 } USearchAttribute;
00197
00201 typedef enum {
00206 USEARCH_DEFAULT = -1,
00211 USEARCH_OFF,
00216 USEARCH_ON,
00223 USEARCH_STANDARD_ELEMENT_COMPARISON,
00242 USEARCH_PATTERN_BASE_WEIGHT_IS_WILDCARD,
00263 USEARCH_ANY_BASE_WEIGHT_IS_WILDCARD,
00264
00269 USEARCH_ATTRIBUTE_VALUE_COUNT
00270 } USearchAttributeValue;
00271
00272
00273
00296 U_STABLE UStringSearch * U_EXPORT2 usearch_open(const UChar *pattern,
00297 int32_t patternlength,
00298 const UChar *text,
00299 int32_t textlength,
00300 const char *locale,
00301 UBreakIterator *breakiter,
00302 UErrorCode *status);
00303
00328 U_STABLE UStringSearch * U_EXPORT2 usearch_openFromCollator(
00329 const UChar *pattern,
00330 int32_t patternlength,
00331 const UChar *text,
00332 int32_t textlength,
00333 const UCollator *collator,
00334 UBreakIterator *breakiter,
00335 UErrorCode *status);
00336
00343 U_STABLE void U_EXPORT2 usearch_close(UStringSearch *searchiter);
00344
00345 #if U_SHOW_CPLUSPLUS_API
00346
00347 U_NAMESPACE_BEGIN
00348
00358 U_DEFINE_LOCAL_OPEN_POINTER(LocalUStringSearchPointer, UStringSearch, usearch_close);
00359
00360 U_NAMESPACE_END
00361
00362 #endif
00363
00364
00365
00381 U_STABLE void U_EXPORT2 usearch_setOffset(UStringSearch *strsrch,
00382 int32_t position,
00383 UErrorCode *status);
00384
00393 U_STABLE int32_t U_EXPORT2 usearch_getOffset(const UStringSearch *strsrch);
00394
00406 U_STABLE void U_EXPORT2 usearch_setAttribute(UStringSearch *strsrch,
00407 USearchAttribute attribute,
00408 USearchAttributeValue value,
00409 UErrorCode *status);
00410
00419 U_STABLE USearchAttributeValue U_EXPORT2 usearch_getAttribute(
00420 const UStringSearch *strsrch,
00421 USearchAttribute attribute);
00422
00442 U_STABLE int32_t U_EXPORT2 usearch_getMatchedStart(
00443 const UStringSearch *strsrch);
00444
00462 U_STABLE int32_t U_EXPORT2 usearch_getMatchedLength(
00463 const UStringSearch *strsrch);
00464
00490 U_STABLE int32_t U_EXPORT2 usearch_getMatchedText(const UStringSearch *strsrch,
00491 UChar *result,
00492 int32_t resultCapacity,
00493 UErrorCode *status);
00494
00495 #if !UCONFIG_NO_BREAK_ITERATION
00496
00512 U_STABLE void U_EXPORT2 usearch_setBreakIterator(UStringSearch *strsrch,
00513 UBreakIterator *breakiter,
00514 UErrorCode *status);
00515
00527 U_STABLE const UBreakIterator * U_EXPORT2 usearch_getBreakIterator(
00528 const UStringSearch *strsrch);
00529
00530 #endif
00531
00545 U_STABLE void U_EXPORT2 usearch_setText( UStringSearch *strsrch,
00546 const UChar *text,
00547 int32_t textlength,
00548 UErrorCode *status);
00549
00558 U_STABLE const UChar * U_EXPORT2 usearch_getText(const UStringSearch *strsrch,
00559 int32_t *length);
00560
00571 U_STABLE UCollator * U_EXPORT2 usearch_getCollator(
00572 const UStringSearch *strsrch);
00573
00584 U_STABLE void U_EXPORT2 usearch_setCollator( UStringSearch *strsrch,
00585 const UCollator *collator,
00586 UErrorCode *status);
00587
00600 U_STABLE void U_EXPORT2 usearch_setPattern( UStringSearch *strsrch,
00601 const UChar *pattern,
00602 int32_t patternlength,
00603 UErrorCode *status);
00604
00613 U_STABLE const UChar * U_EXPORT2 usearch_getPattern(
00614 const UStringSearch *strsrch,
00615 int32_t *length);
00616
00617
00618
00634 U_STABLE int32_t U_EXPORT2 usearch_first(UStringSearch *strsrch,
00635 UErrorCode *status);
00636
00658 U_STABLE int32_t U_EXPORT2 usearch_following(UStringSearch *strsrch,
00659 int32_t position,
00660 UErrorCode *status);
00661
00677 U_STABLE int32_t U_EXPORT2 usearch_last(UStringSearch *strsrch,
00678 UErrorCode *status);
00679
00705 U_STABLE int32_t U_EXPORT2 usearch_preceding(UStringSearch *strsrch,
00706 int32_t position,
00707 UErrorCode *status);
00708
00726 U_STABLE int32_t U_EXPORT2 usearch_next(UStringSearch *strsrch,
00727 UErrorCode *status);
00728
00746 U_STABLE int32_t U_EXPORT2 usearch_previous(UStringSearch *strsrch,
00747 UErrorCode *status);
00748
00759 U_STABLE void U_EXPORT2 usearch_reset(UStringSearch *strsrch);
00760
00761 #ifndef U_HIDE_INTERNAL_API
00762
00816 U_INTERNAL UBool U_EXPORT2 usearch_search(UStringSearch *strsrch,
00817 int32_t startIdx,
00818 int32_t *matchStart,
00819 int32_t *matchLimit,
00820 UErrorCode *status);
00821
00876 U_INTERNAL UBool U_EXPORT2 usearch_searchBackwards(UStringSearch *strsrch,
00877 int32_t startIdx,
00878 int32_t *matchStart,
00879 int32_t *matchLimit,
00880 UErrorCode *status);
00881 #endif
00882
00883 #endif
00884
00885 #endif