ICU 62.1  62.1
usearch.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 **********************************************************************
5 * Copyright (C) 2001-2011,2014 IBM and others. All rights reserved.
6 **********************************************************************
7 * Date Name Description
8 * 06/28/2001 synwee Creation.
9 **********************************************************************
10 */
11 #ifndef USEARCH_H
12 #define USEARCH_H
13 
14 #include "unicode/utypes.h"
15 
16 #if !UCONFIG_NO_COLLATION && !UCONFIG_NO_BREAK_ITERATION
17 
18 #include "unicode/localpointer.h"
19 #include "unicode/ucol.h"
20 #include "unicode/ucoleitr.h"
21 #include "unicode/ubrk.h"
22 
147 #define USEARCH_DONE -1
148 
153 struct UStringSearch;
159 
163 typedef enum {
169 #ifndef U_HIDE_DEPRECATED_API
170 
185 #endif /* U_HIDE_DEPRECATED_API */
186 
192 
193 #ifndef U_HIDE_DEPRECATED_API
194 
199 #endif /* U_HIDE_DEPRECATED_API */
201 
205 typedef enum {
268 
269 #ifndef U_HIDE_DEPRECATED_API
270 
275 #endif /* U_HIDE_DEPRECATED_API */
277 
278 /* open and close ------------------------------------------------------ */
279 
302 U_STABLE UStringSearch * U_EXPORT2 usearch_open(const UChar *pattern,
303  int32_t patternlength,
304  const UChar *text,
305  int32_t textlength,
306  const char *locale,
307  UBreakIterator *breakiter,
308  UErrorCode *status);
309 
335  const UChar *pattern,
336  int32_t patternlength,
337  const UChar *text,
338  int32_t textlength,
339  const UCollator *collator,
340  UBreakIterator *breakiter,
341  UErrorCode *status);
342 
349 U_STABLE void U_EXPORT2 usearch_close(UStringSearch *searchiter);
350 
351 #if U_SHOW_CPLUSPLUS_API
352 
354 
365 
367 
368 #endif
369 
370 /* get and set methods -------------------------------------------------- */
371 
387 U_STABLE void U_EXPORT2 usearch_setOffset(UStringSearch *strsrch,
388  int32_t position,
389  UErrorCode *status);
390 
399 U_STABLE int32_t U_EXPORT2 usearch_getOffset(const UStringSearch *strsrch);
400 
412 U_STABLE void U_EXPORT2 usearch_setAttribute(UStringSearch *strsrch,
413  USearchAttribute attribute,
414  USearchAttributeValue value,
415  UErrorCode *status);
416 
426  const UStringSearch *strsrch,
427  USearchAttribute attribute);
428 
448 U_STABLE int32_t U_EXPORT2 usearch_getMatchedStart(
449  const UStringSearch *strsrch);
450 
468 U_STABLE int32_t U_EXPORT2 usearch_getMatchedLength(
469  const UStringSearch *strsrch);
470 
496 U_STABLE int32_t U_EXPORT2 usearch_getMatchedText(const UStringSearch *strsrch,
497  UChar *result,
498  int32_t resultCapacity,
499  UErrorCode *status);
500 
501 #if !UCONFIG_NO_BREAK_ITERATION
502 
518 U_STABLE void U_EXPORT2 usearch_setBreakIterator(UStringSearch *strsrch,
519  UBreakIterator *breakiter,
520  UErrorCode *status);
521 
534  const UStringSearch *strsrch);
535 
536 #endif
537 
551 U_STABLE void U_EXPORT2 usearch_setText( UStringSearch *strsrch,
552  const UChar *text,
553  int32_t textlength,
554  UErrorCode *status);
555 
564 U_STABLE const UChar * U_EXPORT2 usearch_getText(const UStringSearch *strsrch,
565  int32_t *length);
566 
578  const UStringSearch *strsrch);
579 
590 U_STABLE void U_EXPORT2 usearch_setCollator( UStringSearch *strsrch,
591  const UCollator *collator,
592  UErrorCode *status);
593 
606 U_STABLE void U_EXPORT2 usearch_setPattern( UStringSearch *strsrch,
607  const UChar *pattern,
608  int32_t patternlength,
609  UErrorCode *status);
610 
619 U_STABLE const UChar * U_EXPORT2 usearch_getPattern(
620  const UStringSearch *strsrch,
621  int32_t *length);
622 
623 /* methods ------------------------------------------------------------- */
624 
640 U_STABLE int32_t U_EXPORT2 usearch_first(UStringSearch *strsrch,
641  UErrorCode *status);
642 
664 U_STABLE int32_t U_EXPORT2 usearch_following(UStringSearch *strsrch,
665  int32_t position,
666  UErrorCode *status);
667 
683 U_STABLE int32_t U_EXPORT2 usearch_last(UStringSearch *strsrch,
684  UErrorCode *status);
685 
711 U_STABLE int32_t U_EXPORT2 usearch_preceding(UStringSearch *strsrch,
712  int32_t position,
713  UErrorCode *status);
714 
732 U_STABLE int32_t U_EXPORT2 usearch_next(UStringSearch *strsrch,
733  UErrorCode *status);
734 
752 U_STABLE int32_t U_EXPORT2 usearch_previous(UStringSearch *strsrch,
753  UErrorCode *status);
754 
765 U_STABLE void U_EXPORT2 usearch_reset(UStringSearch *strsrch);
766 
767 #ifndef U_HIDE_INTERNAL_API
768 
822 U_INTERNAL UBool U_EXPORT2 usearch_search(UStringSearch *strsrch,
823  int32_t startIdx,
824  int32_t *matchStart,
825  int32_t *matchLimit,
826  UErrorCode *status);
827 
883  int32_t startIdx,
884  int32_t *matchStart,
885  int32_t *matchLimit,
886  UErrorCode *status);
887 #endif /* U_HIDE_INTERNAL_API */
888 
889 #endif /* #if !UCONFIG_NO_COLLATION && !UCONFIG_NO_BREAK_ITERATION */
890 
891 #endif
usearch_last
int32_t usearch_last(UStringSearch *strsrch, UErrorCode *status)
Returns the last index in the target text at which it matches the search pattern.
usearch_getOffset
int32_t usearch_getOffset(const UStringSearch *strsrch)
Return the current index in the string text being searched.
USEARCH_ANY_BASE_WEIGHT_IS_WILDCARD
@ USEARCH_ANY_BASE_WEIGHT_IS_WILDCARD
Value for USEARCH_ELEMENT_COMPARISON.
Definition: usearch.h:267
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
usearch_setCollator
void usearch_setCollator(UStringSearch *strsrch, const UCollator *collator, UErrorCode *status)
Sets the collator used for the language rules.
usearch_getAttribute
USearchAttributeValue usearch_getAttribute(const UStringSearch *strsrch, USearchAttribute attribute)
Gets the text searching attributes.
ucoleitr.h
C API: UCollationElements.
USEARCH_ELEMENT_COMPARISON
@ USEARCH_ELEMENT_COMPARISON
Option to control how collation elements are compared.
Definition: usearch.h:191
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:236
ubrk.h
C API: BreakIterator.
usearch_getBreakIterator
const UBreakIterator * usearch_getBreakIterator(const UStringSearch *strsrch)
Returns the BreakIterator that is used to restrict the points at which matches are detected.
usearch_reset
void usearch_reset(UStringSearch *strsrch)
Reset the iteration.
LocalUStringSearchPointer
usearch_setAttribute
void usearch_setAttribute(UStringSearch *strsrch, USearchAttribute attribute, USearchAttributeValue value, UErrorCode *status)
Sets the text searching attributes located in the enum USearchAttribute with values from the enum USe...
USEARCH_PATTERN_BASE_WEIGHT_IS_WILDCARD
@ USEARCH_PATTERN_BASE_WEIGHT_IS_WILDCARD
Value for USEARCH_ELEMENT_COMPARISON; collation element comparison is modified to effectively provide...
Definition: usearch.h:246
usearch_setOffset
void usearch_setOffset(UStringSearch *strsrch, int32_t position, UErrorCode *status)
Sets the current position in the text string which the next search will start from.
usearch_search
UBool usearch_search(UStringSearch *strsrch, int32_t startIdx, int32_t *matchStart, int32_t *matchLimit, UErrorCode *status)
Simple forward search for the pattern, starting at a specified index, and using using a default set s...
USEARCH_OFF
@ USEARCH_OFF
Value for USEARCH_OVERLAP and USEARCH_CANONICAL_MATCH.
Definition: usearch.h:215
usearch_getMatchedStart
int32_t usearch_getMatchedStart(const UStringSearch *strsrch)
Returns the index to the match in the text string that was searched.
usearch_preceding
int32_t usearch_preceding(UStringSearch *strsrch, int32_t position, UErrorCode *status)
Returns the first index less than position at which the string text matches the search pattern.
usearch_getMatchedText
int32_t usearch_getMatchedText(const UStringSearch *strsrch, UChar *result, int32_t resultCapacity, UErrorCode *status)
Returns the text that was matched by the most recent call to usearch_first, usearch_next,...
usearch_first
int32_t usearch_first(UStringSearch *strsrch, UErrorCode *status)
Returns the first index at which the string text matches the search pattern.
usearch_getCollator
UCollator * usearch_getCollator(const UStringSearch *strsrch)
Gets the collator used for the language rules.
USEARCH_ON
@ USEARCH_ON
Value for USEARCH_OVERLAP and USEARCH_CANONICAL_MATCH.
Definition: usearch.h:220
usearch_searchBackwards
UBool usearch_searchBackwards(UStringSearch *strsrch, int32_t startIdx, int32_t *matchStart, int32_t *matchLimit, UErrorCode *status)
Simple backwards search for the pattern, starting at a specified index, and using using a default set...
USearchAttributeValue
USearchAttributeValue
Definition: usearch.h:205
USearchAttribute
USearchAttribute
Definition: usearch.h:163
usearch_getMatchedLength
int32_t usearch_getMatchedLength(const UStringSearch *strsrch)
Returns the length of text in the string which matches the search pattern.
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition: utypes.h:396
U_INTERNAL
#define U_INTERNAL
This is used to declare a function as an internal ICU C API
Definition: umachine.h:119
UCollator
struct UCollator UCollator
structure representing a collator object instance
Definition: ucol.h:58
usearch_setBreakIterator
void usearch_setBreakIterator(UStringSearch *strsrch, UBreakIterator *breakiter, UErrorCode *status)
Set the BreakIterator that will be used to restrict the points at which matches are detected.
USEARCH_CANONICAL_MATCH
@ USEARCH_CANONICAL_MATCH
Option for canonical matches; option 1 in header documentation.
Definition: usearch.h:184
usearch_setPattern
void usearch_setPattern(UStringSearch *strsrch, const UChar *pattern, int32_t patternlength, UErrorCode *status)
Sets the pattern used for matching.
U_DEFINE_LOCAL_OPEN_POINTER
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
Definition: localpointer.h:487
localpointer.h
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
usearch_next
int32_t usearch_next(UStringSearch *strsrch, UErrorCode *status)
Returns the index of the next point at which the string text matches the search pattern,...
U_STABLE
#define U_STABLE
This is used to declare a function as a stable public ICU C API.
Definition: umachine.h:111
usearch_getPattern
const UChar * usearch_getPattern(const UStringSearch *strsrch, int32_t *length)
Gets the search pattern.
UStringSearch
struct UStringSearch UStringSearch
Data structure for searching.
Definition: usearch.h:158
UChar
uint16_t UChar
Definition: umachine.h:353
UBreakIterator
struct UBreakIterator UBreakIterator
Opaque type representing an ICU Break iterator object.
Definition: ubrk.h:28
USEARCH_STANDARD_ELEMENT_COMPARISON
@ USEARCH_STANDARD_ELEMENT_COMPARISON
Value (default) for USEARCH_ELEMENT_COMPARISON; standard collation element comparison at the specifie...
Definition: usearch.h:227
usearch_following
int32_t usearch_following(UStringSearch *strsrch, int32_t position, UErrorCode *status)
Returns the first index equal or greater than position at which the string text matches the search pa...
usearch_open
UStringSearch * usearch_open(const UChar *pattern, int32_t patternlength, const UChar *text, int32_t textlength, const char *locale, UBreakIterator *breakiter, UErrorCode *status)
Creating a search iterator data struct using the argument locale language rule set.
USEARCH_OVERLAP
@ USEARCH_OVERLAP
Option for overlapping matches.
Definition: usearch.h:168
U_NAMESPACE_END
#define U_NAMESPACE_END
Definition: uversion.h:138
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
Definition: uversion.h:137
usearch_setText
void usearch_setText(UStringSearch *strsrch, const UChar *text, int32_t textlength, UErrorCode *status)
Set the string text to be searched.
usearch_previous
int32_t usearch_previous(UStringSearch *strsrch, UErrorCode *status)
Returns the index of the previous point at which the string text matches the search pattern,...
USEARCH_ATTRIBUTE_COUNT
@ USEARCH_ATTRIBUTE_COUNT
One more than the highest normal USearchAttribute value.
Definition: usearch.h:198
usearch_getText
const UChar * usearch_getText(const UStringSearch *strsrch, int32_t *length)
Return the string text to be searched.
usearch_close
void usearch_close(UStringSearch *searchiter)
Destroying and cleaning up the search iterator data struct.
ucol.h
C API: Collator.
USEARCH_ATTRIBUTE_VALUE_COUNT
@ USEARCH_ATTRIBUTE_VALUE_COUNT
One more than the highest normal USearchAttributeValue value.
Definition: usearch.h:274
usearch_openFromCollator
UStringSearch * usearch_openFromCollator(const UChar *pattern, int32_t patternlength, const UChar *text, int32_t textlength, const UCollator *collator, UBreakIterator *breakiter, UErrorCode *status)
Creating a search iterator data struct using the argument collator language rule set.
USEARCH_DEFAULT
@ USEARCH_DEFAULT
Default value for any USearchAttribute.
Definition: usearch.h:210