All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TextSearch.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------------------
2 // Copyright (c) 2001-2018 by PDFTron Systems Inc. All Rights Reserved.
3 // Consult legal.txt regarding legal and license information.
4 //---------------------------------------------------------------------------------------
5 #ifndef PDFTRON_H_CPPPDFTextSearch
6 #define PDFTRON_H_CPPPDFTextSearch
7 
8 #include <PDF/PDFDoc.h>
9 #include <Common/UString.h>
10 #include <PDF/Highlights.h>
11 #include <C/PDF/TRN_TextSearch.h>
12 
13 namespace pdftron {
14  namespace PDF {
15 
20 {
21 public:
22 
26  operator bool () { return IsFound(); }
27 
31  bool IsFound() const;
32 
36  bool IsDocEnd() const;
37 
41  bool IsPageEnd() const;
42 
46  int GetPageNumber() const;
47 
51  UString GetMatch() const;
52 
57  UString GetAmbientString() const;
58 
63  Highlights GetHighlights() const;
64 
65 
67 #ifndef SWIGHIDDEN
68  SearchResult();
69  SearchResult(const SearchResult& b);
70  SearchResult(int, TRN_TextSearchResultCode rc, UString r, UString a, Highlights h);
71 #endif
72 private:
74  int page_num;
75  TRN_TextSearchResultCode resCode;
76  UString result;
77  UString ambient;
78  Highlights hlts;
79 };
80 
81 
171 {
172 public:
173 
177  TextSearch();
178  ~TextSearch();
179 
183  typedef TRN_UInt32 Mode;
184 
189  {
190  //use regular expressions
192 
193  //match case-sensitively
195 
196  //match the entire word
198 
199  //search upward (from the end of the file and from the bottom of a page)
201 
202  //tells the search process to return when each page is finished; this is
203  //useful when a user needs Run() to return periodically so that certain
204  //things (e.g., UI) can be updated from time to time.
206 
207  //tells the search process to compute Highlight information.
209 
210  //tells the search process to compute the ambient string of the found pattern.
211  //This is useful if a user wants to examine or display what surrounds the
212  //found pattern.
214  };
215 
230  bool Begin(PDFDoc& doc, const UString& pattern, Mode mode, int start_page = -1, int end_page = -1);
231 
241  SearchResult Run();
242 
251  bool SetPattern(const UString& pattern);
252 
257  Mode GetMode() const;
258 
272  void SetMode( Mode mode );
273 
278  void SetRightToLeftLanguage(bool flag);
279 
287  int GetCurrentPage() const;
288 
292  void Destroy();
293 
295 private:
296  TRN_TextSearch mp_textsearch;
297  TextSearch(const TextSearch&);
298  TextSearch& operator= (const TextSearch&);
300 };
301 
302 
303 #include <Impl/TextSearch.inl>
304 
305  }; // namespace PDF
306 }; // namespace pdftron
307 
308 #endif // PDFTRON_H_CPPPDFTextSearch
bool SetPattern(const UString &pattern)
UString GetMatch() const
UString GetAmbientString() const
Highlights GetHighlights() const
int GetCurrentPage() const
void SetRightToLeftLanguage(bool flag)
bool Begin(PDFDoc &doc, const UString &pattern, Mode mode, int start_page=-1, int end_page=-1)
void SetMode(Mode mode)

© 2002-2014 PDFTron Systems Inc.