ICU 57.1  57.1
usearch.h
Go to the documentation of this file.
1 /*
2 **********************************************************************
3 * Copyright (C) 2001-2011,2014 IBM and others. All rights reserved.
4 **********************************************************************
5 * Date Name Description
6 * 06/28/2001 synwee Creation.
7 **********************************************************************
8 */
9 #ifndef USEARCH_H
10 #define USEARCH_H
11 
12 #include "unicode/utypes.h"
13 
14 #if !UCONFIG_NO_COLLATION && !UCONFIG_NO_BREAK_ITERATION
15 
16 #include "unicode/localpointer.h"
17 #include "unicode/ucol.h"
18 #include "unicode/ucoleitr.h"
19 #include "unicode/ubrk.h"
20 
145 #define USEARCH_DONE -1
146 
151 struct UStringSearch;
156 typedef struct UStringSearch UStringSearch;
157 
161 typedef enum {
167 #ifndef U_HIDE_DEPRECATED_API
183 #endif /* U_HIDE_DEPRECATED_API */
190 
197 
201 typedef enum {
264 
271 
272 /* open and close ------------------------------------------------------ */
273 
296 U_STABLE UStringSearch * U_EXPORT2 usearch_open(const UChar *pattern,
297  int32_t patternlength,
298  const UChar *text,
299  int32_t textlength,
300  const char *locale,
301  UBreakIterator *breakiter,
302  UErrorCode *status);
303 
329  const UChar *pattern,
330  int32_t patternlength,
331  const UChar *text,
332  int32_t textlength,
333  const UCollator *collator,
334  UBreakIterator *breakiter,
335  UErrorCode *status);
336 
343 U_STABLE void U_EXPORT2 usearch_close(UStringSearch *searchiter);
344 
345 #if U_SHOW_CPLUSPLUS_API
346 
348 
359 
361 
362 #endif
363 
364 /* get and set methods -------------------------------------------------- */
365 
381 U_STABLE void U_EXPORT2 usearch_setOffset(UStringSearch *strsrch,
382  int32_t position,
383  UErrorCode *status);
384 
393 U_STABLE int32_t U_EXPORT2 usearch_getOffset(const UStringSearch *strsrch);
394 
406 U_STABLE void U_EXPORT2 usearch_setAttribute(UStringSearch *strsrch,
407  USearchAttribute attribute,
408  USearchAttributeValue value,
409  UErrorCode *status);
410 
420  const UStringSearch *strsrch,
421  USearchAttribute attribute);
422 
443  const UStringSearch *strsrch);
444 
463  const UStringSearch *strsrch);
464 
490 U_STABLE int32_t U_EXPORT2 usearch_getMatchedText(const UStringSearch *strsrch,
491  UChar *result,
492  int32_t resultCapacity,
493  UErrorCode *status);
494 
495 #if !UCONFIG_NO_BREAK_ITERATION
496 
513  UBreakIterator *breakiter,
514  UErrorCode *status);
515 
528  const UStringSearch *strsrch);
529 
530 #endif
531 
545 U_STABLE void U_EXPORT2 usearch_setText( UStringSearch *strsrch,
546  const UChar *text,
547  int32_t textlength,
548  UErrorCode *status);
549 
558 U_STABLE const UChar * U_EXPORT2 usearch_getText(const UStringSearch *strsrch,
559  int32_t *length);
560 
572  const UStringSearch *strsrch);
573 
584 U_STABLE void U_EXPORT2 usearch_setCollator( UStringSearch *strsrch,
585  const UCollator *collator,
586  UErrorCode *status);
587 
600 U_STABLE void U_EXPORT2 usearch_setPattern( UStringSearch *strsrch,
601  const UChar *pattern,
602  int32_t patternlength,
603  UErrorCode *status);
604 
614  const UStringSearch *strsrch,
615  int32_t *length);
616 
617 /* methods ------------------------------------------------------------- */
618 
634 U_STABLE int32_t U_EXPORT2 usearch_first(UStringSearch *strsrch,
635  UErrorCode *status);
636 
658 U_STABLE int32_t U_EXPORT2 usearch_following(UStringSearch *strsrch,
659  int32_t position,
660  UErrorCode *status);
661 
677 U_STABLE int32_t U_EXPORT2 usearch_last(UStringSearch *strsrch,
678  UErrorCode *status);
679 
705 U_STABLE int32_t U_EXPORT2 usearch_preceding(UStringSearch *strsrch,
706  int32_t position,
707  UErrorCode *status);
708 
726 U_STABLE int32_t U_EXPORT2 usearch_next(UStringSearch *strsrch,
727  UErrorCode *status);
728 
746 U_STABLE int32_t U_EXPORT2 usearch_previous(UStringSearch *strsrch,
747  UErrorCode *status);
748 
759 U_STABLE void U_EXPORT2 usearch_reset(UStringSearch *strsrch);
760 
761 #ifndef U_HIDE_INTERNAL_API
817  int32_t startIdx,
818  int32_t *matchStart,
819  int32_t *matchLimit,
820  UErrorCode *status);
821 
877  int32_t startIdx,
878  int32_t *matchStart,
879  int32_t *matchLimit,
880  UErrorCode *status);
881 #endif /* U_HIDE_INTERNAL_API */
882 
883 #endif /* #if !UCONFIG_NO_COLLATION && !UCONFIG_NO_BREAK_ITERATION */
884 
885 #endif
"Smart pointer" class, closes a UStringSearch via usearch_close().
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
Definition: localpointer.h:539
C API: BreakIterator.
struct UBreakIterator UBreakIterator
Opaque type representing an ICU Break iterator object.
Definition: ubrk.h:26
C API: Collator.
struct UCollator UCollator
structure representing a collator object instance
Definition: ucol.h:56
C API: UCollationElements.
#define U_INTERNAL
This is used to declare a function as an internal ICU C API
Definition: umachine.h:117
int8_t UBool
The ICU boolean type.
Definition: umachine.h:234
uint16_t UChar
Define UChar to be UCHAR_TYPE, if that is #defined (for example, to char16_t), or wchar_t if that is ...
Definition: umachine.h:312
#define U_STABLE
This is used to declare a function as a stable public ICU C API.
Definition: umachine.h:109
void usearch_setText(UStringSearch *strsrch, const UChar *text, int32_t textlength, UErrorCode *status)
Set the string text to be searched.
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.
const UBreakIterator * usearch_getBreakIterator(const UStringSearch *strsrch)
Returns the BreakIterator that is used to restrict the points at which matches are detected.
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,...
const UChar * usearch_getPattern(const UStringSearch *strsrch, int32_t *length)
Gets the search pattern.
USearchAttributeValue usearch_getAttribute(const UStringSearch *strsrch, USearchAttribute attribute)
Gets the text searching attributes.
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.
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...
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...
int32_t usearch_getMatchedLength(const UStringSearch *strsrch)
Returns the length of text in the string which matches the search pattern.
const UChar * usearch_getText(const UStringSearch *strsrch, int32_t *length)
Return the string text to be searched.
int32_t usearch_next(UStringSearch *strsrch, UErrorCode *status)
Returns the index of the next point at which the string text matches the search pattern,...
void usearch_reset(UStringSearch *strsrch)
Reset the iteration.
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.
void usearch_close(UStringSearch *searchiter)
Destroying and cleaning up the search iterator data struct.
int32_t usearch_previous(UStringSearch *strsrch, UErrorCode *status)
Returns the index of the previous point at which the string text matches the search pattern,...
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.
int32_t usearch_getMatchedStart(const UStringSearch *strsrch)
Returns the index to the match in the text string that was searched.
void usearch_setPattern(UStringSearch *strsrch, const UChar *pattern, int32_t patternlength, UErrorCode *status)
Sets the pattern used for matching.
USearchAttribute
Definition: usearch.h:161
@ USEARCH_CANONICAL_MATCH
Option for canonical matches; option 1 in header documentation.
Definition: usearch.h:182
@ USEARCH_ELEMENT_COMPARISON
Option to control how collation elements are compared.
Definition: usearch.h:189
@ USEARCH_OVERLAP
Option for overlapping matches.
Definition: usearch.h:166
@ USEARCH_ATTRIBUTE_COUNT
Count of attribute types.
Definition: usearch.h:195
int32_t usearch_last(UStringSearch *strsrch, UErrorCode *status)
Returns the last index in the target text at which it matches the search pattern.
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...
struct UStringSearch UStringSearch
Data structure for searching.
Definition: usearch.h:156
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.
void usearch_setCollator(UStringSearch *strsrch, const UCollator *collator, UErrorCode *status)
Sets the collator used for the language rules.
UCollator * usearch_getCollator(const UStringSearch *strsrch)
Gets the collator used for the language rules.
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...
int32_t usearch_getOffset(const UStringSearch *strsrch)
Return the current index in the string text being searched.
int32_t usearch_first(UStringSearch *strsrch, UErrorCode *status)
Returns the first index at which the string text matches the search pattern.
USearchAttributeValue
Definition: usearch.h:201
@ USEARCH_ATTRIBUTE_VALUE_COUNT
Count of attribute values.
Definition: usearch.h:269
@ USEARCH_DEFAULT
Default value for any USearchAttribute.
Definition: usearch.h:206
@ USEARCH_OFF
Value for USEARCH_OVERLAP and USEARCH_CANONICAL_MATCH.
Definition: usearch.h:211
@ USEARCH_ON
Value for USEARCH_OVERLAP and USEARCH_CANONICAL_MATCH.
Definition: usearch.h:216
@ USEARCH_STANDARD_ELEMENT_COMPARISON
Value (default) for USEARCH_ELEMENT_COMPARISON; standard collation element comparison at the specifie...
Definition: usearch.h:223
@ USEARCH_PATTERN_BASE_WEIGHT_IS_WILDCARD
Value for USEARCH_ELEMENT_COMPARISON; collation element comparison is modified to effectively provide...
Definition: usearch.h:242
@ USEARCH_ANY_BASE_WEIGHT_IS_WILDCARD
Value for USEARCH_ELEMENT_COMPARISON.
Definition: usearch.h:263
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition: utypes.h:476
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129