ICU 4.2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
search.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 * 03/22/2000 helena Creation.
7 **********************************************************************
8 */
9 
10 #ifndef SEARCH_H
11 #define SEARCH_H
12 
13 #include "unicode/utypes.h"
14 
20 #if !UCONFIG_NO_COLLATION && !UCONFIG_NO_BREAK_ITERATION
21 
22 #include "unicode/uobject.h"
23 #include "unicode/unistr.h"
24 #include "unicode/chariter.h"
25 #include "unicode/brkiter.h"
26 #include "unicode/usearch.h"
27 
31 struct USearch;
35 typedef struct USearch USearch;
36 
38 
80 
81 public:
82 
83  // public constructors and destructors -------------------------------
84 
91  SearchIterator(const SearchIterator &other);
92 
97  virtual ~SearchIterator();
98 
99  // public get and set methods ----------------------------------------
100 
114  virtual void setOffset(int32_t position, UErrorCode &status) = 0;
115 
124  virtual int32_t getOffset(void) const = 0;
125 
135  void setAttribute(USearchAttribute attribute,
136  USearchAttributeValue value,
137  UErrorCode &status);
138 
145  USearchAttributeValue getAttribute(USearchAttribute attribute) const;
146 
163  int32_t getMatchedStart(void) const;
164 
179  int32_t getMatchedLength(void) const;
180 
195  void getMatchedText(UnicodeString &result) const;
196 
212  void setBreakIterator(BreakIterator *breakiter, UErrorCode &status);
213 
224  const BreakIterator * getBreakIterator(void) const;
225 
236  virtual void setText(const UnicodeString &text, UErrorCode &status);
237 
253  virtual void setText(CharacterIterator &text, UErrorCode &status);
254 
260  const UnicodeString & getText(void) const;
261 
262  // operator overloading ----------------------------------------------
263 
272  virtual UBool operator==(const SearchIterator &that) const;
273 
280  UBool operator!=(const SearchIterator &that) const;
281 
282  // public methods ----------------------------------------------------
283 
291  virtual SearchIterator* safeClone(void) const = 0;
292 
306  int32_t first(UErrorCode &status);
307 
325  int32_t following(int32_t position, UErrorCode &status);
326 
340  int32_t last(UErrorCode &status);
341 
359  int32_t preceding(int32_t position, UErrorCode &status);
360 
375  int32_t next(UErrorCode &status);
376 
390  int32_t previous(UErrorCode &status);
391 
400  virtual void reset();
401 
402 protected:
403  // protected data members ---------------------------------------------
404 
410 
420 
426 
427  // protected constructors and destructors -----------------------------
428 
434  SearchIterator();
435 
451  SearchIterator(const UnicodeString &text,
452  BreakIterator *breakiter = NULL);
453 
473  SearchIterator(CharacterIterator &text, BreakIterator *breakiter = NULL);
474 
475  // protected methods --------------------------------------------------
476 
483  SearchIterator & operator=(const SearchIterator &that);
484 
504  virtual int32_t handleNext(int32_t position, UErrorCode &status)
505  = 0;
506 
526  virtual int32_t handlePrev(int32_t position, UErrorCode &status)
527  = 0;
528 
539  virtual void setMatchLength(int32_t length);
540 
551  virtual void setMatchStart(int32_t position);
552 
557  void setMatchNotFound();
558 };
559 
561 {
562  return !operator==(that);
563 }
565 
566 #endif /* #if !UCONFIG_NO_COLLATION */
567 
568 #endif
569 
C++ API: Break Iterator.
The BreakIterator class implements methods for finding the location of boundaries in text...
Definition: brkiter.h:100
C++ API: Unicode String.
C API: StringSearch.
USearchAttribute
Definition: usearch.h:155
virtual UBool operator==(const SearchIterator &that) const
Equality operator.
UnicodeString m_text_
Unicode string version of the search text.
Definition: search.h:425
Abstract class that defines an API for iteration on text objects.
Definition: chariter.h:356
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:475
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:183
USearchAttributeValue
Definition: usearch.h:169
#define NULL
Define NULL if necessary, to 0 for C++ and to ((void *)0) for C.
Definition: utypes.h:266
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:187
UBool operator!=(const SearchIterator &that) const
Not-equal operator.
Definition: search.h:560
C++ API: Common ICU base class UObject.
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API If the compiler doesn't support namespaces...
Definition: uversion.h:184
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:212
BreakIterator * m_breakiterator_
Break iterator.
Definition: search.h:419
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:593
SearchIterator is an abstract base class that provides methods to search for a pattern within a text ...
Definition: search.h:79
Basic definitions for ICU, for both C and C++ APIs.
USearch * m_search_
C search data struct.
Definition: search.h:409
C++ API: Character Iterator.
struct USearch USearch
Definition: search.h:35
signed int int32_t
Define 64 bit limits.
Definition: pwin32.h:143
int8_t UBool
The ICU boolean type.
Definition: umachine.h:208