📄 usearch.h
字号:
* @see #usearch_last* @see #USEARCH_DONE* @stable ICU 2.4*/U_STABLE int32_t U_EXPORT2 usearch_getMatchedStart( const UStringSearch *strsrch); /*** Returns the length of text in the string which matches the search pattern. * This call returns a valid result only after a successful call to * <tt>usearch_first</tt>, <tt>usearch_next</tt>, <tt>usearch_previous</tt>, * or <tt>usearch_last</tt>.* Just after construction, or after a searching method returns * <tt>USEARCH_DONE</tt>, this method will return 0.* @param strsrch search iterator data struct* @return The length of the match in the string text, or 0 if there is no * match currently.* @see #usearch_first* @see #usearch_next* @see #usearch_previous* @see #usearch_last* @see #USEARCH_DONE* @stable ICU 2.4*/U_STABLE int32_t U_EXPORT2 usearch_getMatchedLength( const UStringSearch *strsrch);/*** Returns the text that was matched by the most recent call to * <tt>usearch_first</tt>, <tt>usearch_next</tt>, <tt>usearch_previous</tt>, * or <tt>usearch_last</tt>.* If the iterator is not pointing at a valid match (e.g. just after * construction or after <tt>USEARCH_DONE</tt> has been returned, returns* an empty string. If result is not large enough to store the matched text,* result will be filled with the partial text and an U_BUFFER_OVERFLOW_ERROR * will be returned in status. result will be null-terminated whenever * possible. If the buffer fits the matched text exactly, a null-termination * is not possible, then a U_STRING_NOT_TERMINATED_ERROR set in status.* Pre-flighting can be either done with length = 0 or the API * <tt>usearch_getMatchLength</tt>.* @param strsrch search iterator data struct* @param result UChar buffer to store the matched string* @param resultCapacity length of the result buffer* @param status error returned if result is not large enough* @return exact length of the matched text, not counting the null-termination* @see #usearch_first* @see #usearch_next* @see #usearch_previous* @see #usearch_last* @see #USEARCH_DONE* @stable ICU 2.4*/U_STABLE int32_t U_EXPORT2 usearch_getMatchedText(const UStringSearch *strsrch, UChar *result, int32_t resultCapacity, UErrorCode *status);#if !UCONFIG_NO_BREAK_ITERATION/*** Set the BreakIterator that will be used to restrict the points at which * matches are detected.* @param strsrch search iterator data struct* @param breakiter A BreakIterator that will be used to restrict the points* at which matches are detected. If a match is found, but * the match's start or end index is not a boundary as * determined by the <tt>BreakIterator</tt>, the match will * be rejected and another will be searched for. * If this parameter is <tt>NULL</tt>, no break detection is * attempted.* @param status for errors if it occurs* @see #usearch_getBreakIterator* @stable ICU 2.4*/U_STABLE void U_EXPORT2 usearch_setBreakIterator(UStringSearch *strsrch, UBreakIterator *breakiter, UErrorCode *status);/*** Returns the BreakIterator that is used to restrict the points at which * matches are detected. This will be the same object that was passed to the * constructor or to <tt>usearch_setBreakIterator</tt>. Note that * <tt>NULL</tt> * is a legal value; it means that break detection should not be attempted.* @param strsrch search iterator data struct* @return break iterator used* @see #usearch_setBreakIterator* @stable ICU 2.4*/U_STABLE const UBreakIterator * U_EXPORT2 usearch_getBreakIterator( const UStringSearch *strsrch); #endif /*** Set the string text to be searched. Text iteration will hence begin at the * start of the text string. This method is useful if you want to re-use an * iterator to search for the same pattern within a different body of text.* @param strsrch search iterator data struct* @param text new string to look for match* @param textlength length of the new string, -1 for null-termination* @param status for errors if it occurs. If text is NULL, or textlength is 0 * then an U_ILLEGAL_ARGUMENT_ERROR is returned with no change* done to strsrch.* @see #usearch_getText* @stable ICU 2.4*/U_STABLE void U_EXPORT2 usearch_setText( UStringSearch *strsrch, const UChar *text, int32_t textlength, UErrorCode *status);/*** Return the string text to be searched.* @param strsrch search iterator data struct* @param length returned string text length* @return string text * @see #usearch_setText* @stable ICU 2.4*/U_STABLE const UChar * U_EXPORT2 usearch_getText(const UStringSearch *strsrch, int32_t *length);/*** Gets the collator used for the language rules. * <p>* Deleting the returned <tt>UCollator</tt> before calling * <tt>usearch_close</tt> would cause the string search to fail.* <tt>usearch_close</tt> will delete the collator if this search owns it.* @param strsrch search iterator data struct* @return collator* @stable ICU 2.4*/U_STABLE UCollator * U_EXPORT2 usearch_getCollator( const UStringSearch *strsrch);/*** Sets the collator used for the language rules. User retains the ownership * of this collator, thus the responsibility of deletion lies with the user.* This method causes internal data such as Boyer-Moore shift tables to * be recalculated, but the iterator's position is unchanged.* @param strsrch search iterator data struct* @param collator to be used* @param status for errors if it occurs* @stable ICU 2.4*/U_STABLE void U_EXPORT2 usearch_setCollator( UStringSearch *strsrch, const UCollator *collator, UErrorCode *status);/*** Sets the pattern used for matching.* Internal data like the Boyer Moore table will be recalculated, but the * iterator's position is unchanged.* @param strsrch search iterator data struct* @param pattern string* @param patternlength pattern length, -1 for null-terminated string* @param status for errors if it occurs. If text is NULL, or textlength is 0 * then an U_ILLEGAL_ARGUMENT_ERROR is returned with no change* done to strsrch.* @stable ICU 2.4*/U_STABLE void U_EXPORT2 usearch_setPattern( UStringSearch *strsrch, const UChar *pattern, int32_t patternlength, UErrorCode *status);/*** Gets the search pattern* @param strsrch search iterator data struct* @param length return length of the pattern, -1 indicates that the pattern * is null-terminated* @return pattern string* @stable ICU 2.4*/U_STABLE const UChar * U_EXPORT2 usearch_getPattern( const UStringSearch *strsrch, int32_t *length);/* methods ------------------------------------------------------------- *//*** Returns the first index at which the string text matches the search * pattern. * The iterator is adjusted so that its current index (as returned by * <tt>usearch_getOffset</tt>) is the match position if one was found.* If a match is not found, <tt>USEARCH_DONE</tt> will be returned and* the iterator will be adjusted to the index <tt>USEARCH_DONE</tt>.* @param strsrch search iterator data struct* @param status for errors if it occurs* @return The character index of the first match, or * <tt>USEARCH_DONE</tt> if there are no matches.* @see #usearch_getOffset* @see #USEARCH_DONE* @stable ICU 2.4*/U_STABLE int32_t U_EXPORT2 usearch_first(UStringSearch *strsrch, UErrorCode *status);/*** Returns the first index greater than <tt>position</tt> at which the string * text * matches the search pattern. The iterator is adjusted so that its current * index (as returned by <tt>usearch_getOffset</tt>) is the match position if * one was found.* If a match is not found, <tt>USEARCH_DONE</tt> will be returned and* the iterator will be adjusted to the index <tt>USEARCH_DONE</tt>* <p>* Search positions that may render incorrect results are highlighted in the* header comments. If position is less than or greater than the text range * for searching, an U_INDEX_OUTOFBOUNDS_ERROR will be returned* @param strsrch search iterator data struct* @param position to start the search at* @param status for errors if it occurs* @return The character index of the first match following <tt>pos</tt>,* or <tt>USEARCH_DONE</tt> if there are no matches.* @see #usearch_getOffset* @see #USEARCH_DONE* @stable ICU 2.4*/U_STABLE int32_t U_EXPORT2 usearch_following(UStringSearch *strsrch, int32_t position, UErrorCode *status); /*** Returns the last index in the target text at which it matches the search * pattern. The iterator is adjusted so that its current * index (as returned by <tt>usearch_getOffset</tt>) is the match position if * one was found.* If a match is not found, <tt>USEARCH_DONE</tt> will be returned and* the iterator will be adjusted to the index <tt>USEARCH_DONE</tt>.* @param strsrch search iterator data struct* @param status for errors if it occurs* @return The index of the first match, or <tt>USEARCH_DONE</tt> if there * are no matches.* @see #usearch_getOffset* @see #USEARCH_DONE* @stable ICU 2.4*/U_STABLE int32_t U_EXPORT2 usearch_last(UStringSearch *strsrch, UErrorCode *status);/*** Returns the first index less than <tt>position</tt> at which the string text * matches the search pattern. The iterator is adjusted so that its current * index (as returned by <tt>usearch_getOffset</tt>) is the match position if * one was found.* If a match is not found, <tt>USEARCH_DONE</tt> will be returned and* the iterator will be adjusted to the index <tt>USEARCH_DONE</tt>* <p>* Search positions that may render incorrect results are highlighted in the* header comments. If position is less than or greater than the text range * for searching, an U_INDEX_OUTOFBOUNDS_ERROR will be returned* @param strsrch search iterator data struct* @param position index position the search is to begin at* @param status for errors if it occurs* @return The character index of the first match preceding <tt>pos</tt>,* or <tt>USEARCH_DONE</tt> if there are no matches.* @see #usearch_getOffset* @see #USEARCH_DONE* @stable ICU 2.4*/U_STABLE int32_t U_EXPORT2 usearch_preceding(UStringSearch *strsrch, int32_t position, UErrorCode *status); /*** Returns the index of the next point at which the string text matches the* search pattern, starting from the current position.* The iterator is adjusted so that its current * index (as returned by <tt>usearch_getOffset</tt>) is the match position if * one was found.* If a match is not found, <tt>USEARCH_DONE</tt> will be returned and* the iterator will be adjusted to the index <tt>USEARCH_DONE</tt>* @param strsrch search iterator data struct* @param status for errors if it occurs* @return The index of the next match after the current position, or * <tt>USEARCH_DONE</tt> if there are no more matches.* @see #usearch_first* @see #usearch_getOffset* @see #USEARCH_DONE* @stable ICU 2.4*/U_STABLE int32_t U_EXPORT2 usearch_next(UStringSearch *strsrch, UErrorCode *status);/*** Returns the index of the previous point at which the string text matches* the search pattern, starting at the current position.* The iterator is adjusted so that its current * index (as returned by <tt>usearch_getOffset</tt>) is the match position if * one was found.* If a match is not found, <tt>USEARCH_DONE</tt> will be returned and* the iterator will be adjusted to the index <tt>USEARCH_DONE</tt>* @param strsrch search iterator data struct* @param status for errors if it occurs* @return The index of the previous match before the current position,* or <tt>USEARCH_DONE</tt> if there are no more matches.* @see #usearch_last* @see #usearch_getOffset* @see #USEARCH_DONE* @stable ICU 2.4*/U_STABLE int32_t U_EXPORT2 usearch_previous(UStringSearch *strsrch, UErrorCode *status); /** * Reset the iteration.* Search will begin at the start of the text string if a forward iteration * is initiated before a backwards iteration. Otherwise if a backwards * iteration is initiated before a forwards iteration, the search will begin* at the end of the text string.* @param strsrch search iterator data struct* @see #usearch_first* @stable ICU 2.4*/U_STABLE void U_EXPORT2 usearch_reset(UStringSearch *strsrch);#endif /* #if !UCONFIG_NO_COLLATION */#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -