ICU 4.2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
usearch.h
Go to the documentation of this file.
1 /*
2 **********************************************************************
3 * Copyright (C) 2001-2008 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/ucol.h"
17 #include "unicode/ucoleitr.h"
18 #include "unicode/ubrk.h"
19 
139 #define USEARCH_DONE -1
140 
145 struct UStringSearch;
151 
155 typedef enum {
163  USEARCH_ATTRIBUTE_COUNT
165 
169 typedef enum {
176  USEARCH_ATTRIBUTE_VALUE_COUNT
178 
179 /* open and close ------------------------------------------------------ */
180 
204  int32_t patternlength,
205  const UChar *text,
206  int32_t textlength,
207  const char *locale,
208  UBreakIterator *breakiter,
209  UErrorCode *status);
210 
236  const UChar *pattern,
237  int32_t patternlength,
238  const UChar *text,
239  int32_t textlength,
240  const UCollator *collator,
241  UBreakIterator *breakiter,
242  UErrorCode *status);
243 
251 
252 /* get and set methods -------------------------------------------------- */
253 
270  int32_t position,
271  UErrorCode *status);
272 
282 
295  USearchAttribute attribute,
296  USearchAttributeValue value,
297  UErrorCode *status);
298 
308  const UStringSearch *strsrch,
309  USearchAttribute attribute);
310 
331  const UStringSearch *strsrch);
332 
351  const UStringSearch *strsrch);
352 
379  UChar *result,
380  int32_t resultCapacity,
381  UErrorCode *status);
382 
383 #if !UCONFIG_NO_BREAK_ITERATION
384 
401  UBreakIterator *breakiter,
402  UErrorCode *status);
403 
416  const UStringSearch *strsrch);
417 
418 #endif
419 
434  const UChar *text,
435  int32_t textlength,
436  UErrorCode *status);
437 
446 U_STABLE const UChar * U_EXPORT2 usearch_getText(const UStringSearch *strsrch,
447  int32_t *length);
448 
460  const UStringSearch *strsrch);
461 
473  const UCollator *collator,
474  UErrorCode *status);
475 
489  const UChar *pattern,
490  int32_t patternlength,
491  UErrorCode *status);
492 
502  const UStringSearch *strsrch,
503  int32_t *length);
504 
505 /* methods ------------------------------------------------------------- */
506 
523  UErrorCode *status);
524 
547  int32_t position,
548  UErrorCode *status);
549 
566  UErrorCode *status);
567 
589  int32_t position,
590  UErrorCode *status);
591 
610  UErrorCode *status);
611 
630  UErrorCode *status);
631 
643 
699  int32_t startIdx,
700  int32_t *matchStart,
701  int32_t *matchLimit,
702  UErrorCode *status);
703 
759  int32_t startIdx,
760  int32_t *matchStart,
761  int32_t *matchLimit,
762  UErrorCode *status);
763 
764 #endif /* #if !UCONFIG_NO_COLLATION && !UCONFIG_NO_BREAK_ITERATION */
765 
766 #endif
int32_t usearch_following(UStringSearch *strsrch, int32_t position, UErrorCode *status)
Returns the first index greater than position at which the string text matches the search pattern...
value for USEARCH_OVERLAP and USEARCH_CANONICAL_MATCH
Definition: usearch.h:175
void usearch_close(UStringSearch *searchiter)
Destroying and cleaning up the search iterator data struct.
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.
void UBreakIterator
Opaque type representing an ICU Break iterator object.
Definition: ubrk.h:25
#define U_INTERNAL
This is used to declare a function as an internal ICU C API.
Definition: umachine.h:125
USearchAttribute
Definition: usearch.h:155
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:157
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:173
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.
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.
Option for canonical matches.
Definition: usearch.h:162
default value for any USearchAttribute
Definition: usearch.h:171
C API: UCollationElements.
USearchAttributeValue
Definition: usearch.h:169
C API: Collator.
#define U_EXPORT2
Definition: platform.h:338
uint16_t UChar
Define UChar to be wchar_t if that is 16 bits wide; always assumed to be unsigned.
Definition: umachine.h:299
void usearch_setPattern(UStringSearch *strsrch, const UChar *pattern, int32_t patternlength, UErrorCode *status)
Sets the pattern used for matching.
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:593
C API: BreakIterator.
struct UCollator UCollator
structure representing a collator object instance
Definition: ucol.h:60
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:150
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.
signed int int32_t
Define 64 bit limits.
Definition: pwin32.h:143
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:117
int8_t UBool
The ICU boolean type.
Definition: umachine.h:208
int32_t usearch_last(UStringSearch *strsrch, UErrorCode *status)
Returns the last index in the target text at which it matches the search pattern. ...