]>
git.saurik.com Git - wxWidgets.git/blob - src/common/tokenzr.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: String tokenizer
4 // Author: Guilhem Lavaux
8 // Copyright: (c) Guilhem Lavaux
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "tokenzr.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
26 #include "wx/object.h"
27 #include "wx/string.h"
28 #include "wx/tokenzr.h"
30 wxStringTokenizer::wxStringTokenizer(const wxString
& to_tokenize
,
31 const wxString
& delims
,
35 m_string
= to_tokenize
;
37 m_retdelims
= ret_delims
;
40 wxStringTokenizer::~wxStringTokenizer()
44 off_t
wxStringTokenizer::FindDelims(const wxString
& str
, const wxString
& delims
)
47 register int s_len
= str
.Length(),
48 len
= delims
.Length();
50 for (i
=0;i
<s_len
;i
++) {
51 register char c
= str
[i
];
60 int wxStringTokenizer::CountTokens()
62 wxString p_string
= m_string
;
66 if (p_string
.Length() == 0)
70 pos
= FindDelims(p_string
, m_delims
);
73 p_string
= p_string(0, pos
);
80 bool wxStringTokenizer::HasMoreToken()
82 return (m_string
.Length() != 0);
85 wxString
wxStringTokenizer::NextToken()
87 register off_t pos
, pos2
;
90 if (m_string
.IsNull())
93 pos
= FindDelims(m_string
, m_delims
);
96 m_string
= (char *)NULL
;
110 r_string
= m_string
.Left((size_t)pos
);
111 m_string
= m_string
.Mid((size_t)pos2
);