]>
git.saurik.com Git - wxWidgets.git/blob - src/common/tokenzr.cpp
eb992377113bf19e711d9f2a2b8b9eb9af21398e
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 #include "wx/object.h"
17 #include "wx/string.h"
18 #include "wx/tokenzr.h"
20 wxStringTokenizer::wxStringTokenizer(const wxString
& to_tokenize
,
21 const wxString
& delims
,
25 m_string
= to_tokenize
;
27 m_retdelims
= ret_delims
;
30 wxStringTokenizer::~wxStringTokenizer()
34 off_t
wxStringTokenizer::FindDelims(const wxString
& str
, const wxString
& delims
)
37 register int s_len
= str
.Length(),
38 len
= delims
.Length();
40 for (i
=0;i
<s_len
;i
++) {
41 register char c
= str
[i
];
50 int wxStringTokenizer::CountTokens()
52 wxString p_string
= m_string
;
56 if (p_string
.Length() == 0)
60 pos
= FindDelims(p_string
, m_delims
);
63 p_string
= p_string(0, pos
);
70 bool wxStringTokenizer::HasMoreToken()
72 return (m_string
.Length() != 0);
75 wxString
wxStringTokenizer::NextToken()
77 register off_t pos
, pos2
;
80 if (m_string
.IsNull())
83 pos
= FindDelims(m_string
, m_delims
);
86 m_string
= (char *)NULL
;
100 r_string
= m_string
.Left((size_t)pos
);
101 m_string
= m_string
.Mid((size_t)pos2
);