ICU 4.8.1.1  4.8.1.1
usearch.h
Go to the documentation of this file.
00001 /*
00002 **********************************************************************
00003 *   Copyright (C) 2001-2011 IBM and others. All rights reserved.
00004 **********************************************************************
00005 *   Date        Name        Description
00006 *  06/28/2001   synwee      Creation.
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 
00140 #define USEARCH_DONE -1
00141 
00146 struct UStringSearch;
00151 typedef struct UStringSearch UStringSearch;
00152 
00156 typedef enum {
00158     USEARCH_OVERLAP,
00163     USEARCH_CANONICAL_MATCH,
00169     USEARCH_ELEMENT_COMPARISON,
00170 
00171     USEARCH_ATTRIBUTE_COUNT
00172 } USearchAttribute;
00173 
00177 typedef enum {
00179     USEARCH_DEFAULT = -1,
00181     USEARCH_OFF, 
00183     USEARCH_ON,
00190     USEARCH_STANDARD_ELEMENT_COMPARISON,
00204     USEARCH_PATTERN_BASE_WEIGHT_IS_WILDCARD,
00218     USEARCH_ANY_BASE_WEIGHT_IS_WILDCARD,
00219 
00220     USEARCH_ATTRIBUTE_VALUE_COUNT
00221 } USearchAttributeValue;
00222 
00223 /* open and close ------------------------------------------------------ */
00224 
00247 U_STABLE UStringSearch * U_EXPORT2 usearch_open(const UChar          *pattern, 
00248                                               int32_t         patternlength, 
00249                                         const UChar          *text, 
00250                                               int32_t         textlength,
00251                                         const char           *locale,
00252                                               UBreakIterator *breakiter,
00253                                               UErrorCode     *status);
00254 
00279 U_STABLE UStringSearch * U_EXPORT2 usearch_openFromCollator(
00280                                          const UChar *pattern, 
00281                                                int32_t         patternlength,
00282                                          const UChar          *text, 
00283                                                int32_t         textlength,
00284                                          const UCollator      *collator,
00285                                                UBreakIterator *breakiter,
00286                                                UErrorCode     *status);
00287 
00294 U_STABLE void U_EXPORT2 usearch_close(UStringSearch *searchiter);
00295 
00296 #if U_SHOW_CPLUSPLUS_API
00297 
00298 U_NAMESPACE_BEGIN
00299 
00309 U_DEFINE_LOCAL_OPEN_POINTER(LocalUStringSearchPointer, UStringSearch, usearch_close);
00310 
00311 U_NAMESPACE_END
00312 
00313 #endif
00314 
00315 /* get and set methods -------------------------------------------------- */
00316 
00332 U_STABLE void U_EXPORT2 usearch_setOffset(UStringSearch *strsrch, 
00333                                         int32_t    position,
00334                                         UErrorCode    *status);
00335 
00344 U_STABLE int32_t U_EXPORT2 usearch_getOffset(const UStringSearch *strsrch);
00345     
00357 U_STABLE void U_EXPORT2 usearch_setAttribute(UStringSearch         *strsrch, 
00358                                            USearchAttribute       attribute,
00359                                            USearchAttributeValue  value,
00360                                            UErrorCode            *status);
00361 
00370 U_STABLE USearchAttributeValue U_EXPORT2 usearch_getAttribute(
00371                                          const UStringSearch    *strsrch,
00372                                                USearchAttribute  attribute);
00373 
00393 U_STABLE int32_t U_EXPORT2 usearch_getMatchedStart(
00394                                                const UStringSearch *strsrch);
00395     
00413 U_STABLE int32_t U_EXPORT2 usearch_getMatchedLength(
00414                                                const UStringSearch *strsrch);
00415 
00441 U_STABLE int32_t U_EXPORT2 usearch_getMatchedText(const UStringSearch *strsrch, 
00442                                             UChar         *result, 
00443                                             int32_t        resultCapacity, 
00444                                             UErrorCode    *status);
00445 
00446 #if !UCONFIG_NO_BREAK_ITERATION
00447 
00463 U_STABLE void U_EXPORT2 usearch_setBreakIterator(UStringSearch  *strsrch, 
00464                                                UBreakIterator *breakiter,
00465                                                UErrorCode     *status);
00466 
00478 U_STABLE const UBreakIterator * U_EXPORT2 usearch_getBreakIterator(
00479                                               const UStringSearch *strsrch);
00480     
00481 #endif
00482     
00496 U_STABLE void U_EXPORT2 usearch_setText(      UStringSearch *strsrch, 
00497                                       const UChar         *text,
00498                                             int32_t        textlength,
00499                                             UErrorCode    *status);
00500 
00509 U_STABLE const UChar * U_EXPORT2 usearch_getText(const UStringSearch *strsrch, 
00510                                                int32_t       *length);
00511 
00522 U_STABLE UCollator * U_EXPORT2 usearch_getCollator(
00523                                                const UStringSearch *strsrch);
00524 
00535 U_STABLE void U_EXPORT2 usearch_setCollator(      UStringSearch *strsrch, 
00536                                           const UCollator     *collator,
00537                                                 UErrorCode    *status);
00538 
00551 U_STABLE void U_EXPORT2 usearch_setPattern(      UStringSearch *strsrch, 
00552                                          const UChar         *pattern,
00553                                                int32_t        patternlength,
00554                                                UErrorCode    *status);
00555 
00564 U_STABLE const UChar * U_EXPORT2 usearch_getPattern(
00565                                                const UStringSearch *strsrch, 
00566                                                      int32_t       *length);
00567 
00568 /* methods ------------------------------------------------------------- */
00569 
00585 U_STABLE int32_t U_EXPORT2 usearch_first(UStringSearch *strsrch, 
00586                                            UErrorCode    *status);
00587 
00609 U_STABLE int32_t U_EXPORT2 usearch_following(UStringSearch *strsrch, 
00610                                                int32_t    position, 
00611                                                UErrorCode    *status);
00612     
00628 U_STABLE int32_t U_EXPORT2 usearch_last(UStringSearch *strsrch, 
00629                                           UErrorCode    *status);
00630 
00656 U_STABLE int32_t U_EXPORT2 usearch_preceding(UStringSearch *strsrch, 
00657                                                int32_t    position, 
00658                                                UErrorCode    *status);
00659     
00677 U_STABLE int32_t U_EXPORT2 usearch_next(UStringSearch *strsrch, 
00678                                           UErrorCode    *status);
00679 
00697 U_STABLE int32_t U_EXPORT2 usearch_previous(UStringSearch *strsrch, 
00698                                               UErrorCode    *status);
00699     
00710 U_STABLE void U_EXPORT2 usearch_reset(UStringSearch *strsrch);
00711 
00766 U_INTERNAL UBool U_EXPORT2 usearch_search(UStringSearch *strsrch,
00767                                           int32_t        startIdx,
00768                                           int32_t        *matchStart,
00769                                           int32_t        *matchLimit,
00770                                           UErrorCode     *status);
00771 
00826 U_INTERNAL UBool U_EXPORT2 usearch_searchBackwards(UStringSearch *strsrch,
00827                                                    int32_t        startIdx,
00828                                                    int32_t        *matchStart,
00829                                                    int32_t        *matchLimit,
00830                                                    UErrorCode     *status);
00831 
00832 #endif /* #if !UCONFIG_NO_COLLATION  && !UCONFIG_NO_BREAK_ITERATION */
00833 
00834 #endif
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines