]>
git.saurik.com Git - wxWidgets.git/blob - src/html/search.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: search engine
4 // Author: Vaclav Slavik
6 // Copyright: (c) 1999 Vaclav Slavik
7 // Licence: wxWindows Licence
8 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation
16 #include "wx/wxprec.h"
29 #include "wx/html/helpdata.h"
33 //--------------------------------------------------------------------------------
35 //--------------------------------------------------------------------------------
37 void wxSearchEngine::LookFor(const wxString
& keyword
)
39 if (m_Keyword
) delete[] m_Keyword
;
40 m_Keyword
= new char[keyword
.Length() + 1];
41 strcpy(m_Keyword
, keyword
.c_str());
42 for (int i
= strlen(m_Keyword
) - 1; i
>= 0; i
--)
43 if ((m_Keyword
[i
] >= 'A') && (m_Keyword
[i
] <= 'Z'))
44 m_Keyword
[i
] += 'a' - 'A';
49 bool wxSearchEngine::Scan(wxInputStream
*stream
)
51 wxASSERT_MSG(m_Keyword
!= NULL
, _("wxSearchEngine::LookFor must be called before scanning!"));
54 int lng
= stream
->GetSize();
55 int wrd
= strlen(m_Keyword
);
57 char *buf
= new char[lng
+ 1];
58 stream
-> Read(buf
, lng
);
61 for (i
= 0; i
< lng
; i
++)
62 if ((buf
[i
] >= 'A') && (buf
[i
] <= 'Z')) buf
[i
] += 'a' - 'A';
64 for (i
= 0; i
< lng
- wrd
; i
++) {
66 while ((j
< wrd
) && (buf
[i
+ j
] == m_Keyword
[j
])) j
++;
67 if (j
== wrd
) {found
= TRUE
; break;}