Main Page
Namespaces
Classes
Files
File List
File Members
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
19
class
SearchResult
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
170
class
TextSearch
171
{
172
public
:
173
177
TextSearch
();
178
~TextSearch
();
179
183
typedef
TRN_UInt32
Mode
;
184
188
enum
TextSearchModes
189
{
190
//use regular expressions
191
e_reg_expression
= 0x0001,
192
193
//match case-sensitively
194
e_case_sensitive
=
e_reg_expression
<< 1,
195
196
//match the entire word
197
e_whole_word
=
e_case_sensitive
<< 1,
198
199
//search upward (from the end of the file and from the bottom of a page)
200
e_search_up
=
e_whole_word
<< 1,
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.
205
e_page_stop
=
e_search_up
<< 1,
206
207
//tells the search process to compute Highlight information.
208
e_highlight
=
e_page_stop
<< 1,
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.
213
e_ambient_string
=
e_highlight
<< 1
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
pdftron::PDF::TextSearch::SetPattern
bool SetPattern(const UString &pattern)
pdftron::PDF::TextSearch::Run
SearchResult Run()
pdftron::PDF::TextSearch
Definition:
TextSearch.h:170
pdftron::PDF::TextSearch::e_page_stop
Definition:
TextSearch.h:205
pdftron::PDF::TextSearch::Destroy
void Destroy()
UString.h
pdftron::PDF::Highlights
Definition:
Highlights.h:48
pdftron::PDF::SearchResult::IsFound
bool IsFound() const
pdftron::PDF::TextSearch::e_reg_expression
Definition:
TextSearch.h:191
pdftron::PDF::SearchResult::IsPageEnd
bool IsPageEnd() const
pdftron::PDF::SearchResult
Definition:
TextSearch.h:19
pdftron::PDF::TextSearch::GetMode
Mode GetMode() const
pdftron::PDF::SearchResult::GetMatch
UString GetMatch() const
pdftron::PDF::TextSearch::e_highlight
Definition:
TextSearch.h:208
Highlights.h
pdftron::PDF::PDFDoc
Definition:
PDFDoc.h:57
pdftron::PDF::TextSearch::e_search_up
Definition:
TextSearch.h:200
pdftron::PDF::SearchResult::GetPageNumber
int GetPageNumber() const
pdftron::PDF::SearchResult::GetAmbientString
UString GetAmbientString() const
pdftron::PDF::TextSearch::e_ambient_string
Definition:
TextSearch.h:213
pdftron::PDF::SearchResult::GetHighlights
Highlights GetHighlights() const
PDFDoc.h
pdftron::PDF::TextSearch::GetCurrentPage
int GetCurrentPage() const
pdftron::PDF::TextSearch::e_whole_word
Definition:
TextSearch.h:197
pdftron::PDF::TextSearch::TextSearch
TextSearch()
pdftron::PDF::TextSearch::~TextSearch
~TextSearch()
pdftron::PDF::TextSearch::e_case_sensitive
Definition:
TextSearch.h:194
pdftron::PDF::TextSearch::SetRightToLeftLanguage
void SetRightToLeftLanguage(bool flag)
pdftron::PDF::TextSearch::Mode
TRN_UInt32 Mode
Definition:
TextSearch.h:183
pdftron::PDF::SearchResult::IsDocEnd
bool IsDocEnd() const
pdftron::PDF::TextSearch::Begin
bool Begin(PDFDoc &doc, const UString &pattern, Mode mode, int start_page=-1, int end_page=-1)
pdftron::PDF::TextSearch::TextSearchModes
TextSearchModes
Definition:
TextSearch.h:188
pdftron::PDF::TextSearch::SetMode
void SetMode(Mode mode)
pdftron::UString
Definition:
UString.h:26
© 2002-2014
PDFTron Systems Inc.