WXDLLEXPORT added to wxStringTokenizer (and also several "const"s here and
there...) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2752 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
b23198ab9e
commit
85833f5c6c
@ -20,38 +20,38 @@
|
||||
#include "wx/string.h"
|
||||
#include "wx/filefn.h"
|
||||
|
||||
class wxStringTokenizer : public wxObject {
|
||||
class WXDLLEXPORT wxStringTokenizer : public wxObject
|
||||
{
|
||||
public:
|
||||
wxStringTokenizer(const wxString& to_tokenize,
|
||||
const wxString& delims = " \t\r\n",
|
||||
bool ret_delim = FALSE);
|
||||
wxStringTokenizer() { m_string = ""; m_delims = ""; m_retdelims = FALSE;}
|
||||
~wxStringTokenizer();
|
||||
wxStringTokenizer(const wxString& to_tokenize,
|
||||
const wxString& delims = " \t\r\n",
|
||||
bool ret_delim = FALSE);
|
||||
wxStringTokenizer() { m_retdelims = FALSE;}
|
||||
virtual ~wxStringTokenizer();
|
||||
|
||||
int CountTokens();
|
||||
bool HasMoreToken();
|
||||
inline bool HasMoreTokens() { return HasMoreToken(); };
|
||||
wxString NextToken();
|
||||
// A better name!
|
||||
inline wxString GetNextToken() { return NextToken(); };
|
||||
wxString GetString() { return m_string; }
|
||||
int CountTokens() count;
|
||||
bool HasMoreTokens();
|
||||
|
||||
void SetString(const wxString& to_tokenize,
|
||||
const wxString& delims = " \t\r\n",
|
||||
bool ret_delim = FALSE)
|
||||
{
|
||||
m_string = to_tokenize;
|
||||
m_delims = delims;
|
||||
m_retdelims = ret_delim;
|
||||
}
|
||||
wxString NextToken();
|
||||
wxString GetNextToken() { return NextToken(); };
|
||||
|
||||
wxString GetString() const { return m_string; }
|
||||
|
||||
void SetString(const wxString& to_tokenize,
|
||||
const wxString& delims = " \t\r\n",
|
||||
bool ret_delim = FALSE)
|
||||
{
|
||||
m_string = to_tokenize;
|
||||
m_delims = delims;
|
||||
m_retdelims = ret_delim;
|
||||
}
|
||||
|
||||
protected:
|
||||
off_t FindDelims(const wxString& str, const wxString& delims);
|
||||
void EatLeadingDelims(); // AVS - added to fix leading whitespace /
|
||||
// mult. delims bugs
|
||||
protected:
|
||||
wxString m_string, m_delims;
|
||||
bool m_retdelims;
|
||||
off_t FindDelims(const wxString& str, const wxString& delims);
|
||||
void EatLeadingDelims();
|
||||
|
||||
wxString m_string, m_delims;
|
||||
bool m_retdelims;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // _WX_TOKENZRH
|
||||
|
@ -10,31 +10,25 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "tokenzr.h"
|
||||
#pragma implementation "tokenzr.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#endif
|
||||
|
||||
#include "wx/object.h"
|
||||
#include "wx/string.h"
|
||||
#include "wx/tokenzr.h"
|
||||
|
||||
wxStringTokenizer::wxStringTokenizer(const wxString& to_tokenize,
|
||||
const wxString& delims,
|
||||
bool ret_delims)
|
||||
: wxObject()
|
||||
bool ret_delims)
|
||||
{
|
||||
m_string = to_tokenize;
|
||||
m_delims = delims;
|
||||
m_retdelims = ret_delims;
|
||||
m_string = to_tokenize;
|
||||
m_delims = delims;
|
||||
m_retdelims = ret_delims;
|
||||
}
|
||||
|
||||
wxStringTokenizer::~wxStringTokenizer()
|
||||
@ -43,86 +37,102 @@ wxStringTokenizer::~wxStringTokenizer()
|
||||
|
||||
off_t wxStringTokenizer::FindDelims(const wxString& str, const wxString& delims)
|
||||
{
|
||||
int i, j;
|
||||
register int s_len = str.Length(),
|
||||
len = delims.Length();
|
||||
for ( int i = 0; i < str.Length(); i++ )
|
||||
{
|
||||
char c = str[i];
|
||||
|
||||
for (i=0;i<s_len;i++) {
|
||||
register char c = str[i];
|
||||
for ( int j = 0; j < delims.Length() ; j++ )
|
||||
{
|
||||
if ( delims[j] == c )
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
for (j=0;j<len;j++)
|
||||
if (delims[j] == c)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int wxStringTokenizer::CountTokens()
|
||||
int wxStringTokenizer::CountTokens() const
|
||||
{
|
||||
wxString p_string = m_string;
|
||||
bool found = TRUE;
|
||||
int pos, count = 1;
|
||||
wxString p_string = m_string;
|
||||
bool found = TRUE;
|
||||
int pos, count = 1;
|
||||
|
||||
if (p_string.Length() == 0)
|
||||
return 0;
|
||||
if (p_string.Length() == 0)
|
||||
return 0;
|
||||
|
||||
while (found) {
|
||||
pos = FindDelims(p_string, m_delims);
|
||||
if (pos != -1) {
|
||||
count++;
|
||||
p_string = p_string(0, pos);
|
||||
} else
|
||||
found = FALSE;
|
||||
}
|
||||
return count;
|
||||
while (found)
|
||||
{
|
||||
pos = FindDelims(p_string, m_delims);
|
||||
if (pos != -1)
|
||||
{
|
||||
count++;
|
||||
p_string = p_string(0, pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
found = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
bool wxStringTokenizer::HasMoreToken()
|
||||
{
|
||||
return (m_string.Length() != 0);
|
||||
return !m_string.IsEmpty();
|
||||
}
|
||||
|
||||
// AVS - added to fix leading whitespace / mult. delims bugs
|
||||
// needed to fix leading whitespace / mult. delims bugs
|
||||
void wxStringTokenizer::EatLeadingDelims()
|
||||
{
|
||||
int pos;
|
||||
int pos;
|
||||
|
||||
while ((pos=FindDelims(m_string, m_delims))==0) { // while leading delims
|
||||
m_string = m_string.Mid((size_t)1); // trim 'em from the left
|
||||
}
|
||||
// while leading delims trim 'em from the left
|
||||
while ( ( pos = FindDelims(m_string, m_delims)) == 0 )
|
||||
{
|
||||
m_string = m_string.Mid((size_t)1);
|
||||
}
|
||||
}
|
||||
|
||||
wxString wxStringTokenizer::NextToken()
|
||||
{
|
||||
register off_t pos, pos2;
|
||||
wxString r_string;
|
||||
off_t pos, pos2;
|
||||
wxString r_string;
|
||||
|
||||
if (m_string.IsNull())
|
||||
return m_string;
|
||||
if ( m_string.IsEmpty() )
|
||||
return m_string;
|
||||
|
||||
if (!m_retdelims)
|
||||
EatLeadingDelims(); // AVS - added to fix leading whitespace /
|
||||
// mult. delims bugs
|
||||
if ( !m_retdelims )
|
||||
EatLeadingDelims();
|
||||
|
||||
pos = FindDelims(m_string, m_delims);
|
||||
if (pos == -1)
|
||||
{
|
||||
r_string = m_string;
|
||||
m_string = wxEmptyString;
|
||||
|
||||
return r_string;
|
||||
}
|
||||
|
||||
if (m_retdelims)
|
||||
{
|
||||
if (!pos)
|
||||
{
|
||||
pos++;
|
||||
pos2 = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos2 = pos;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pos2 = pos + 1;
|
||||
}
|
||||
|
||||
r_string = m_string.Left((size_t)pos);
|
||||
m_string = m_string.Mid((size_t)pos2);
|
||||
|
||||
pos = FindDelims(m_string, m_delims);
|
||||
if (pos == -1) {
|
||||
r_string = m_string;
|
||||
m_string = wxEmptyString;
|
||||
|
||||
return r_string;
|
||||
}
|
||||
|
||||
if (m_retdelims) {
|
||||
if (!pos) {
|
||||
pos++;
|
||||
pos2 = 1;
|
||||
} else
|
||||
pos2 = pos;
|
||||
} else
|
||||
pos2 = pos + 1;
|
||||
|
||||
r_string = m_string.Left((size_t)pos);
|
||||
m_string = m_string.Mid((size_t)pos2);
|
||||
|
||||
return r_string;
|
||||
}
|
||||
|
@ -34,21 +34,21 @@ public:
|
||||
};
|
||||
|
||||
IMPLEMENT_ABSTRACT_CLASS(wxHTMLHelpControllerBase, wxHelpControllerBase)
|
||||
|
||||
|
||||
/**
|
||||
This class implements help via an external browser.
|
||||
It requires the name of a directory containing the documentation
|
||||
and a file mapping numerical Section numbers to relative URLS.
|
||||
*/
|
||||
|
||||
wxHTMLHelpControllerBase::wxHTMLHelpControllerBase(void)
|
||||
wxHTMLHelpControllerBase::wxHTMLHelpControllerBase()
|
||||
{
|
||||
m_MapList = (wxList*) NULL;
|
||||
m_NumOfEntries = 0;
|
||||
}
|
||||
|
||||
void
|
||||
wxHTMLHelpControllerBase::DeleteList(void)
|
||||
wxHTMLHelpControllerBase::DeleteList()
|
||||
{
|
||||
if(m_MapList)
|
||||
{
|
||||
@ -64,7 +64,7 @@ wxHTMLHelpControllerBase::DeleteList(void)
|
||||
}
|
||||
}
|
||||
|
||||
wxHTMLHelpControllerBase::~wxHTMLHelpControllerBase(void)
|
||||
wxHTMLHelpControllerBase::~wxHTMLHelpControllerBase()
|
||||
{
|
||||
DeleteList();
|
||||
}
|
||||
@ -88,7 +88,7 @@ wxHTMLHelpControllerBase::LoadFile(const wxString& ifile)
|
||||
wxString mapFile, file, url, doc;
|
||||
int id,i,len;
|
||||
char buffer[WXEXTHELP_BUFLEN];
|
||||
|
||||
|
||||
wxBusyCursor b; // display a busy cursor
|
||||
|
||||
if(! ifile.IsEmpty())
|
||||
@ -125,10 +125,10 @@ wxHTMLHelpControllerBase::LoadFile(const wxString& ifile)
|
||||
file = newfile;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(! wxDirExists(file))
|
||||
return FALSE;
|
||||
|
||||
|
||||
mapFile << file << WXEXTHELP_SEPARATOR << WXEXTHELP_MAPFILE;
|
||||
}
|
||||
else // try to reload old file
|
||||
@ -140,7 +140,7 @@ wxHTMLHelpControllerBase::LoadFile(const wxString& ifile)
|
||||
DeleteList();
|
||||
m_MapList = new wxList;
|
||||
m_NumOfEntries = 0;
|
||||
|
||||
|
||||
FILE *input = fopen(mapFile.fn_str(),"rt");
|
||||
if(! input)
|
||||
return FALSE;
|
||||
@ -169,21 +169,21 @@ wxHTMLHelpControllerBase::LoadFile(const wxString& ifile)
|
||||
}
|
||||
}while(! feof(input));
|
||||
fclose(input);
|
||||
|
||||
|
||||
m_MapFile = file; // now it's valid
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
wxHTMLHelpControllerBase::DisplayContents(void)
|
||||
wxHTMLHelpControllerBase::DisplayContents()
|
||||
{
|
||||
if(! m_NumOfEntries)
|
||||
return FALSE;
|
||||
wxBusyCursor b; // display a busy cursor
|
||||
return KeywordSearch("");
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
wxHTMLHelpControllerBase::DisplaySection(int sectionNo)
|
||||
{
|
||||
@ -219,19 +219,19 @@ wxHTMLHelpControllerBase::KeywordSearch(const wxString& k)
|
||||
wxString *choices = new wxString[m_NumOfEntries];
|
||||
wxString *urls = new wxString[m_NumOfEntries];
|
||||
wxString compA, compB;
|
||||
|
||||
|
||||
int idx = 0, j;
|
||||
bool rc;
|
||||
bool showAll = k.IsEmpty();
|
||||
wxNode *node = m_MapList->First();
|
||||
wxExtHelpMapEntry *entry;
|
||||
|
||||
|
||||
compA = k; compA.LowerCase(); // we compare case insensitive
|
||||
while(node)
|
||||
{
|
||||
entry = (wxExtHelpMapEntry *)node->Data();
|
||||
compB = entry->doc; compB.LowerCase();
|
||||
if((showAll || compB.Contains(k)) && ! compB.IsEmpty())
|
||||
if((showAll || compB.Contains(k)) && ! compB.IsEmpty())
|
||||
{
|
||||
urls[idx] = entry->url;
|
||||
// doesn't work:
|
||||
@ -266,19 +266,19 @@ wxHTMLHelpControllerBase::KeywordSearch(const wxString& k)
|
||||
}
|
||||
delete[] urls;
|
||||
delete[] choices;
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
wxHTMLHelpControllerBase::Quit(void)
|
||||
wxHTMLHelpControllerBase::Quit()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
wxHTMLHelpControllerBase::OnQuit(void)
|
||||
wxHTMLHelpControllerBase::OnQuit()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ wxClientDC::~wxClientDC()
|
||||
// So we store a list of windows for which we already have the DC and not
|
||||
// just one single hDC. This seems to work, but I'm really not sure about
|
||||
// the usefullness of the whole idea - IMHO it's much better to not call
|
||||
// base class OnPaint() at all, or, if we realyl want to allow it, add a
|
||||
// base class OnPaint() at all, or, if we really want to allow it, add a
|
||||
// "wxPaintDC *" parameter to wxPaintEvent which should be used if it's
|
||||
// !NULL instead of creating a new DC.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user