ICU 50.1.2  50.1.2
usearch.h
Go to the documentation of this file.
1 /*
2 **********************************************************************
3 * Copyright (C) 2001-2011 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 
140 #define USEARCH_DONE -1
141 
146 struct UStringSearch;
152 
156 typedef enum {
170 
171  USEARCH_ATTRIBUTE_COUNT
173 
177 typedef enum {
219 
220  USEARCH_ATTRIBUTE_VALUE_COUNT
222 
223 /* open and close ------------------------------------------------------ */
224 
247 U_STABLE UStringSearch * U_EXPORT2 usearch_open(const UChar *pattern,
248  int32_t patternlength,
249  const UChar *text,
250  int32_t textlength,
251  const char *locale,
252  UBreakIterator *breakiter,
253  UErrorCode *status);
254 
280  const UChar *pattern,
281  int32_t patternlength,
282  const UChar *text,
283  int32_t textlength,
284  const UCollator *collator,
285  UBreakIterator *breakiter,
286  UErrorCode *status);
287 
294 U_STABLE void U_EXPORT2 usearch_close(UStringSearch *searchiter);
295 
296 #if U_SHOW_CPLUSPLUS_API
297 
299 
310 
312 
313 #endif
314 
315 /* get and set methods -------------------------------------------------- */
316 
332 U_STABLE void U_EXPORT2 usearch_setOffset(UStringSearch *strsrch,
333  int32_t position,
334  UErrorCode *status);
335 
344 U_STABLE int32_t U_EXPORT2 usearch_getOffset(const UStringSearch *strsrch);
345 
357 U_STABLE void U_EXPORT2 usearch_setAttribute(UStringSearch *strsrch,
358  USearchAttribute attribute,
359  USearchAttributeValue value,
360  UErrorCode *status);
361 
371  const UStringSearch *strsrch,
372  USearchAttribute attribute);
373 
393 U_STABLE int32_t U_EXPORT2 usearch_getMatchedStart(
394  const UStringSearch *strsrch);
395 
413 U_STABLE int32_t U_EXPORT2 usearch_getMatchedLength(
414  const UStringSearch *strsrch);
415 
441 U_STABLE int32_t U_EXPORT2 usearch_getMatchedText(const UStringSearch *strsrch,
442  UChar *result,
443  int32_t resultCapacity,
444  UErrorCode *status);
445 
446 #if !UCONFIG_NO_BREAK_ITERATION
447 
463 U_STABLE void U_EXPORT2 usearch_setBreakIterator(UStringSearch *strsrch,
464  UBreakIterator *breakiter,
465  UErrorCode *status);
466 
479  const UStringSearch *strsrch);
480 
481 #endif
482 
496 U_STABLE void U_EXPORT2 usearch_setText( UStringSearch *strsrch,
497  const UChar *text,
498  int32_t textlength,
499  UErrorCode *status);
500 
509 U_STABLE const UChar * U_EXPORT2 usearch_getText(const UStringSearch *strsrch,
510  int32_t *length);
511 
523  const UStringSearch *strsrch);
524 
535 U_STABLE void U_EXPORT2 usearch_setCollator( UStringSearch *strsrch,
536  const UCollator *collator,
537  UErrorCode *status);
538 
551 U_STABLE void U_EXPORT2 usearch_setPattern( UStringSearch *strsrch,
552  const UChar *pattern,
553  int32_t patternlength,
554  UErrorCode *status);
555 
564 U_STABLE const UChar * U_EXPORT2 usearch_getPattern(
565  const UStringSearch *strsrch,
566  int32_t *length);
567 
568 /* methods ------------------------------------------------------------- */
569 
585 U_STABLE int32_t U_EXPORT2 usearch_first(UStringSearch *strsrch,
586  UErrorCode *status);
587 
609 U_STABLE int32_t U_EXPORT2 usearch_following(UStringSearch *strsrch,
610  int32_t position,
611  UErrorCode *status);
612 
628 U_STABLE int32_t U_EXPORT2 usearch_last(UStringSearch *strsrch,
629  UErrorCode *status);
630 
656 U_STABLE int32_t U_EXPORT2 usearch_preceding(UStringSearch *strsrch,
657  int32_t position,
658  UErrorCode *status);
659 
677 U_STABLE int32_t U_EXPORT2 usearch_next(UStringSearch *strsrch,
678  UErrorCode *status);
679 
697 U_STABLE int32_t U_EXPORT2 usearch_previous(UStringSearch *strsrch,
698  UErrorCode *status);
699 
710 U_STABLE void U_EXPORT2 usearch_reset(UStringSearch *strsrch);
711 
712 #ifndef U_HIDE_INTERNAL_API
713 
767 U_INTERNAL UBool U_EXPORT2 usearch_search(UStringSearch *strsrch,
768  int32_t startIdx,
769  int32_t *matchStart,
770  int32_t *matchLimit,
771  UErrorCode *status);
772 
828  int32_t startIdx,
829  int32_t *matchStart,
830  int32_t *matchLimit,
831  UErrorCode *status);
832 #endif /* U_HIDE_INTERNAL_API */
833 
834 #endif /* #if !UCONFIG_NO_COLLATION && !UCONFIG_NO_BREAK_ITERATION */
835 
836 #endif
struct UBreakIterator UBreakIterator
Opaque type representing an ICU Break iterator object.
Definition: ubrk.h:26
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...
Value for USEARCH_OVERLAP and USEARCH_CANONICAL_MATCH.
Definition: usearch.h:183
void usearch_close(UStringSearch *searchiter)
Destroying and cleaning up the search iterator data struct.
"Smart pointer" class, closes a UStringSearch via usearch_close().
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.
int32_t usearch_getMatchedStart(const UStringSearch *strsrch)
Returns the index to the match in the text string that was searched.
const UBreakIterator * usearch_getBreakIterator(const UStringSearch *strsrch)
Returns the BreakIterator that is used to restrict the points at which matches are detected...
void usearch_setCollator(UStringSearch *strsrch, const UCollator *collator, UErrorCode *status)
Sets the collator used for the language rules.
void usearch_reset(UStringSearch *strsrch)
Reset the iteration.
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...
int32_t usearch_first(UStringSearch *strsrch, UErrorCode *status)
Returns the first index at which the string text matches the search pattern.
#define U_INTERNAL
This is used to declare a function as an internal ICU C API.
Definition: umachine.h:117
USearchAttribute
Definition: usearch.h:156
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...
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...
UCollator * usearch_getCollator(const UStringSearch *strsrch)
Gets the collator used for the language rules.
Option for overlapping matches.
Definition: usearch.h:158
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...
Value for USEARCH_OVERLAP and USEARCH_CANONICAL_MATCH.
Definition: usearch.h:181
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_previous, or usearch_last.
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
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.
int32_t usearch_getMatchedLength(const UStringSearch *strsrch)
Returns the length of text in the string which matches the search pattern.
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
Definition: localpointer.h:290
Option for canonical matches.
Definition: usearch.h:163
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
Default value for any USearchAttribute.
Definition: usearch.h:179
C API: UCollationElements.
Value for USEARCH_ELEMENT_COMPARISON; collation element comparison is modified to effectively provide...
Definition: usearch.h:204
USearchAttributeValue
Definition: usearch.h:177
C API: Collator.
Value for USEARCH_ELEMENT_COMPARISON.
Definition: usearch.h:218
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:278
void usearch_setPattern(UStringSearch *strsrch, const UChar *pattern, int32_t patternlength, UErrorCode *status)
Sets the pattern used for matching.
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
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...
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:476
C API: BreakIterator.
Value (default) for USEARCH_ELEMENT_COMPARISON; standard collation element comparison at the specifie...
Definition: usearch.h:190
Option to control how collation elements are compared.
Definition: usearch.h:169
struct UCollator UCollator
structure representing a collator object instance
Definition: ucol.h:62
Basic definitions for ICU, for both C and C++ APIs.
const UChar * usearch_getText(const UStringSearch *strsrch, int32_t *length)
Return the string text to be searched.
int32_t usearch_getOffset(const UStringSearch *strsrch)
Return the current index in the string text being 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, starting from the current position.
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.
void usearch_setText(UStringSearch *strsrch, const UChar *text, int32_t textlength, UErrorCode *status)
Set the string text to be searched.
struct UStringSearch UStringSearch
Data structure for searching.
Definition: usearch.h:151
int32_t usearch_previous(UStringSearch *strsrch, UErrorCode *status)
Returns the index of the previous point at which the string text matches the search pattern...
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.
#define U_STABLE
This is used to declare a function as a stable public ICU C API.
Definition: umachine.h:109
int8_t UBool
The ICU boolean type.
Definition: umachine.h:200
int32_t usearch_last(UStringSearch *strsrch, UErrorCode *status)
Returns the last index in the target text at which it matches the search pattern. ...