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:
Vadim Zeitlin
1999-06-10 21:16:58 +00:00
parent b23198ab9e
commit 85833f5c6c
4 changed files with 126 additions and 116 deletions

View File

@@ -20,21 +20,22 @@
#include "wx/string.h" #include "wx/string.h"
#include "wx/filefn.h" #include "wx/filefn.h"
class wxStringTokenizer : public wxObject { class WXDLLEXPORT wxStringTokenizer : public wxObject
{
public: public:
wxStringTokenizer(const wxString& to_tokenize, wxStringTokenizer(const wxString& to_tokenize,
const wxString& delims = " \t\r\n", const wxString& delims = " \t\r\n",
bool ret_delim = FALSE); bool ret_delim = FALSE);
wxStringTokenizer() { m_string = ""; m_delims = ""; m_retdelims = FALSE;} wxStringTokenizer() { m_retdelims = FALSE;}
~wxStringTokenizer(); virtual ~wxStringTokenizer();
int CountTokens() count;
bool HasMoreTokens();
int CountTokens();
bool HasMoreToken();
inline bool HasMoreTokens() { return HasMoreToken(); };
wxString NextToken(); wxString NextToken();
// A better name! wxString GetNextToken() { return NextToken(); };
inline wxString GetNextToken() { return NextToken(); };
wxString GetString() { return m_string; } wxString GetString() const { return m_string; }
void SetString(const wxString& to_tokenize, void SetString(const wxString& to_tokenize,
const wxString& delims = " \t\r\n", const wxString& delims = " \t\r\n",
@@ -47,11 +48,10 @@ public:
protected: protected:
off_t FindDelims(const wxString& str, const wxString& delims); off_t FindDelims(const wxString& str, const wxString& delims);
void EatLeadingDelims(); // AVS - added to fix leading whitespace / void EatLeadingDelims();
// mult. delims bugs
protected:
wxString m_string, m_delims; wxString m_string, m_delims;
bool m_retdelims; bool m_retdelims;
}; };
#endif #endif // _WX_TOKENZRH

View File

@@ -20,17 +20,11 @@
#pragma hdrstop #pragma hdrstop
#endif #endif
#ifndef WX_PRECOMP
#endif
#include "wx/object.h"
#include "wx/string.h"
#include "wx/tokenzr.h" #include "wx/tokenzr.h"
wxStringTokenizer::wxStringTokenizer(const wxString& to_tokenize, wxStringTokenizer::wxStringTokenizer(const wxString& to_tokenize,
const wxString& delims, const wxString& delims,
bool ret_delims) bool ret_delims)
: wxObject()
{ {
m_string = to_tokenize; m_string = to_tokenize;
m_delims = delims; m_delims = delims;
@@ -43,21 +37,21 @@ wxStringTokenizer::~wxStringTokenizer()
off_t wxStringTokenizer::FindDelims(const wxString& str, const wxString& delims) off_t wxStringTokenizer::FindDelims(const wxString& str, const wxString& delims)
{ {
int i, j; for ( int i = 0; i < str.Length(); i++ )
register int s_len = str.Length(), {
len = delims.Length(); char c = str[i];
for (i=0;i<s_len;i++) { for ( int j = 0; j < delims.Length() ; j++ )
register char c = str[i]; {
for (j=0;j<len;j++)
if ( delims[j] == c ) if ( delims[j] == c )
return i; return i;
} }
}
return -1; return -1;
} }
int wxStringTokenizer::CountTokens() int wxStringTokenizer::CountTokens() const
{ {
wxString p_string = m_string; wxString p_string = m_string;
bool found = TRUE; bool found = TRUE;
@@ -66,60 +60,76 @@ int wxStringTokenizer::CountTokens()
if (p_string.Length() == 0) if (p_string.Length() == 0)
return 0; return 0;
while (found) { while (found)
{
pos = FindDelims(p_string, m_delims); pos = FindDelims(p_string, m_delims);
if (pos != -1) { if (pos != -1)
{
count++; count++;
p_string = p_string(0, pos); p_string = p_string(0, pos);
} else }
else
{
found = FALSE; found = FALSE;
} }
}
return count; return count;
} }
bool wxStringTokenizer::HasMoreToken() 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() void wxStringTokenizer::EatLeadingDelims()
{ {
int pos; int pos;
while ((pos=FindDelims(m_string, m_delims))==0) { // while leading delims // while leading delims trim 'em from the left
m_string = m_string.Mid((size_t)1); // trim 'em from the left while ( ( pos = FindDelims(m_string, m_delims)) == 0 )
{
m_string = m_string.Mid((size_t)1);
} }
} }
wxString wxStringTokenizer::NextToken() wxString wxStringTokenizer::NextToken()
{ {
register off_t pos, pos2; off_t pos, pos2;
wxString r_string; wxString r_string;
if (m_string.IsNull()) if ( m_string.IsEmpty() )
return m_string; return m_string;
if ( !m_retdelims ) if ( !m_retdelims )
EatLeadingDelims(); // AVS - added to fix leading whitespace / EatLeadingDelims();
// mult. delims bugs
pos = FindDelims(m_string, m_delims); pos = FindDelims(m_string, m_delims);
if (pos == -1) { if (pos == -1)
{
r_string = m_string; r_string = m_string;
m_string = wxEmptyString; m_string = wxEmptyString;
return r_string; return r_string;
} }
if (m_retdelims) { if (m_retdelims)
if (!pos) { {
if (!pos)
{
pos++; pos++;
pos2 = 1; pos2 = 1;
} else }
else
{
pos2 = pos; pos2 = pos;
} else }
}
else
{
pos2 = pos + 1; pos2 = pos + 1;
}
r_string = m_string.Left((size_t)pos); r_string = m_string.Left((size_t)pos);
m_string = m_string.Mid((size_t)pos2); m_string = m_string.Mid((size_t)pos2);

View File

@@ -41,14 +41,14 @@ IMPLEMENT_ABSTRACT_CLASS(wxHTMLHelpControllerBase, wxHelpControllerBase)
and a file mapping numerical Section numbers to relative URLS. and a file mapping numerical Section numbers to relative URLS.
*/ */
wxHTMLHelpControllerBase::wxHTMLHelpControllerBase(void) wxHTMLHelpControllerBase::wxHTMLHelpControllerBase()
{ {
m_MapList = (wxList*) NULL; m_MapList = (wxList*) NULL;
m_NumOfEntries = 0; m_NumOfEntries = 0;
} }
void void
wxHTMLHelpControllerBase::DeleteList(void) wxHTMLHelpControllerBase::DeleteList()
{ {
if(m_MapList) if(m_MapList)
{ {
@@ -64,7 +64,7 @@ wxHTMLHelpControllerBase::DeleteList(void)
} }
} }
wxHTMLHelpControllerBase::~wxHTMLHelpControllerBase(void) wxHTMLHelpControllerBase::~wxHTMLHelpControllerBase()
{ {
DeleteList(); DeleteList();
} }
@@ -176,7 +176,7 @@ wxHTMLHelpControllerBase::LoadFile(const wxString& ifile)
bool bool
wxHTMLHelpControllerBase::DisplayContents(void) wxHTMLHelpControllerBase::DisplayContents()
{ {
if(! m_NumOfEntries) if(! m_NumOfEntries)
return FALSE; return FALSE;
@@ -272,13 +272,13 @@ wxHTMLHelpControllerBase::KeywordSearch(const wxString& k)
bool bool
wxHTMLHelpControllerBase::Quit(void) wxHTMLHelpControllerBase::Quit()
{ {
return TRUE; return TRUE;
} }
void void
wxHTMLHelpControllerBase::OnQuit(void) wxHTMLHelpControllerBase::OnQuit()
{ {
} }

View File

@@ -161,7 +161,7 @@ wxClientDC::~wxClientDC()
// So we store a list of windows for which we already have the DC and not // 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 // 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 // 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 // "wxPaintDC *" parameter to wxPaintEvent which should be used if it's
// !NULL instead of creating a new DC. // !NULL instead of creating a new DC.