casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
StringTokenizer.h
Go to the documentation of this file.
00001 /*
00002  * ALMA - Atacama Large Millimeter Array
00003  * (c) European Southern Observatory, 2002
00004  * (c) Associated Universities Inc., 2002
00005  * Copyright by ESO (in the framework of the ALMA collaboration),
00006  * Copyright by AUI (in the framework of the ALMA collaboration),
00007  * All rights reserved.
00008  * 
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public
00011  * License as published by the Free software Foundation; either
00012  * version 2.1 of the License, or (at your option) any later version.
00013  * 
00014  * This library is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY, without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017  * Lesser General Public License for more details.
00018  * 
00019  * You should have received a copy of the GNU Lesser General Public
00020  * License along with this library; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00022  * MA 02111-1307  USA
00023  *
00024  * File StringTokenizer.h
00025  */
00026 # ifndef StringTokenizer_CLASS
00027 # define StringTokenizer_CLASS
00028 
00029 #include <InvalidArgumentException.h>
00030 #include <OutOfBoundsException.h>
00031 
00032 #include <string>
00033 
00034 using std::string;
00035 
00036 namespace asdm {
00037 
00043 class StringTokenizer {
00044 
00045 public:
00046 
00047     StringTokenizer(const string &s, 
00048         const string &delim = " \t\n\r\f", 
00049         bool returnDelims = false)
00050         throw (InvalidArgumentException);
00051         virtual ~StringTokenizer();
00052 
00053     bool hasMoreTokens(); 
00054     string nextToken() throw (OutOfBoundsException);
00055     string nextToken(const string delim) throw (OutOfBoundsException);
00056     int countTokens();
00057 
00058 private:
00059 
00060     int currentPosition;
00061     int newPosition;
00062     int maxPosition;
00063     char *str;
00064         string *ostr;
00065         string strDelimiter;
00066     const char *delimiter;
00067         int numDelimiters;
00068     bool retDelims;
00069     bool delimsChanged;
00070 
00071     char maxDelimChar;
00072 
00073     void setMaxDelimChar() throw (InvalidArgumentException);
00074     int skipDelimiters(int startPos) throw (InvalidArgumentException);
00075     int scanToken(int startPos);
00076         int indexOfDelimiters(char c);
00077 
00078 };
00079 
00080 } // End namespace asdm
00081 
00082 #endif /* StringTokenizer_CLASS */