1 // Copyright (c) 2003-2006 stefan kersten
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License as
5 // published by the Free Software Foundation; either version 2 of the
6 // License, or (at your option) any later version.
8 // This program is distributed in the hope that it will be useful, but
9 // WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
18 #include "SC_StringParser.h"
19 #include "SC_BoundsMacros.h"
23 SC_StringParser::SC_StringParser()
24 : mSpec(0), mStart(0), mEnd(0), mSep(0)
28 SC_StringParser::SC_StringParser(const char *spec
, char sep
)
29 : mSpec(spec
), mStart(0), mEnd(0), mSep(sep
)
32 size_t len
= strlen(mSpec
);
42 bool SC_StringParser::AtEnd() const
47 const char *SC_StringParser::NextToken()
50 const char *end
= strchr(mStart
, mSep
);
55 size_t len
= sc_min(SC_MAX_TOKEN_LENGTH
-1, end
-mStart
);
56 memcpy(mBuf
, mStart
, len
);