activemq-cpp-3.3.0

src/main/decaf/util/StringTokenizer.h

Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one or more
00003  * contributor license agreements.  See the NOTICE file distributed with
00004  * this work for additional information regarding copyright ownership.
00005  * The ASF licenses this file to You under the Apache License, Version 2.0
00006  * (the "License"); you may not use this file except in compliance with
00007  * the License.  You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 #ifndef _DECAF_UTIL_STRINGTOKENIZER_H_
00018 #define _DECAF_UTIL_STRINGTOKENIZER_H_
00019 
00020 #include <decaf/util/NoSuchElementException.h>
00021 #include <decaf/util/Config.h>
00022 #include <string>
00023 
00024 namespace decaf{
00025 namespace util{
00026 
00032     class DECAF_API StringTokenizer {
00033     private:
00034 
00035         // String to tokenize
00036         std::string str;
00037 
00038         // The delimiter string
00039         std::string delim;
00040 
00041         // The current pos in the string
00042         std::string::size_type pos;
00043 
00044         // Are we returning delimiters
00045         bool returnDelims;
00046 
00047     public:
00048 
00066         StringTokenizer( const std::string& str,
00067                          const std::string& delim = " \t\n\r\f",
00068                          bool returnDelims = false);
00069 
00070         virtual ~StringTokenizer();
00071 
00078         virtual int countTokens() const;
00079 
00085         virtual bool hasMoreTokens() const;
00086 
00094         virtual std::string nextToken();
00095 
00112         virtual std::string nextToken( const std::string& delim );
00113 
00120         virtual unsigned int toArray( std::vector< std::string >& array );
00121 
00142         virtual void reset( const std::string& str = "",
00143                             const std::string& delim = "",
00144                             bool returnDelims = false );
00145 
00146     };
00147 
00148 }}
00149 
00150 #endif /*_DECAF_UTIL_STRINGTOKENIZER_H_*/