1 : //=============================================================================
2 : // File <$/src/cpp/prod/tool/StringTokenizer.cpp>
3 : // This file is part of YaOrb : Yet Another Object Request Broker,
4 : // Copyright (c) 2000-2003, Marc Alff.
5 : //
6 : // This program is free software; you can redistribute it and/or
7 : // modify it under the terms of the GNU General Public License
8 : // as published by the Free Software Foundation; either version 2
9 : // of the License, or (at your option) any later version.
10 : //
11 : // This program is distributed in the hope that it will be useful,
12 : // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 : // GNU General Public License for more details.
15 : //
16 : // You should have received a copy of the GNU General Public License
17 : // along with this program; if not, write to the Free Software
18 : // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 : //
20 : //=============================================================================
21 :
22 : #include "src/cpp/prod/tool/StringTokenizer.h"
23 :
24 : #include <string.h>
25 :
26 : StringTokenizer::StringTokenizer(
27 : const String& aString,
28 8583 : const String& delim)
29 : {
30 8583 : _str = aString ;
31 8583 : _delim = delim ;
32 8583 : _ptr = NULL ;
33 :
34 : // Yes, breaks encapsulation.
35 8583 : char * _str2 = (char*) (const char*) _str ;
36 :
37 8583 : _token = strtok_r(_str2, _delim, & _ptr) ;
38 8583 : }
39 :
40 8583 : StringTokenizer::~StringTokenizer()
41 : {
42 8583 : }
43 :
44 : bool
45 33129 : StringTokenizer::hasMoreTokens()
46 : {
47 : return ((_token != NULL) ? true : false) ;
48 : }
49 :
50 : String
51 24546 : StringTokenizer::nextToken()
52 : {
53 24546 : String result = _token ;
54 :
55 24546 : _token = strtok_r(NULL, _delim, & _ptr) ;
56 :
57 0 : return result ;
58 : }
59 :
|