| 1 | /* |
| 2 | * File: StringTokenizer.h |
| 3 | * |
| 4 | * Author: Jacob Dekel |
| 5 | * Created on: Aug 7, 2009 |
| 6 | * |
| 7 | * Copyright (c) 2009-2013 Jacob Dekel |
| 8 | * $Id$ |
| 9 | * |
| 10 | * This object enables tokenizing a line of text by delimiters |
| 11 | * |
| 12 | * This program is free software: you can redistribute it and/or modify |
| 13 | * it under the terms of the GNU General Public License as published by |
| 14 | * the Free Software Foundation, either version 3 of the License, or |
| 15 | * (at your option) any later version. |
| 16 | * |
| 17 | * This program is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | * GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 24 | * |
| 25 | */ |
| 26 | |
| 27 | #ifndef STRINGTOKENIZER_H |
| 28 | #define STRINGTOKENIZER_Hcxx . . $ `HercStudio/StringTokenizer.h:28:9`! |
| 29 | |
| 30 | #include <string> |
| 31 | #include <iostream> |
| 32 | |
| 33 | namespace Tokenizercxx . . $ Tokenizer/ |
| 34 | { |
| 35 | typedef stdcxx . . $ std/::stringcxx . . $ std/string#::size_typecxx . . $ std/__cxx11/basic_string#size_type# handlecxx . . $ Tokenizer/handle#; |
| 36 | } |
| 37 | |
| 38 | class StringTokenizercxx . . $ StringTokenizer# |
| 39 | { |
| 40 | public: |
| 41 | static inline stdcxx . . $ std/::stringcxx . . $ std/string# getFirstWordcxx . . $ StringTokenizer#getFirstWord(d6887f0d22b52f3).(const stdcxx . . $ std/::stringcxx . . $ std/string#& line, stdcxx . . $ std/::stringcxx . . $ std/string#::size_typecxx . . $ std/__cxx11/basic_string#size_type# &pos, stdcxx . . $ std/::stringcxx . . $ std/string#::size_typecxx . . $ std/__cxx11/basic_string#size_type# &lastPos, const stdcxx . . $ std/::stringcxx . . $ std/string#& delimiters) |
| 42 | { |
| 43 | lastPos = line.find_first_not_ofcxx . . $ std/__cxx11/basic_string#find_first_not_of(7e867d215bf3e68).(delimiters, 0); |
| 44 | if (lastPos == stdcxx . . $ std/::stringcxx . . $ std/string#::nposcxx . . $ std/__cxx11/basic_string#npos.) returncxx . . $ std/__cxx11/basic_string#basic_string(3bc0f77cdfbaa67f). (cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).""); |
| 45 | pos = line.find_first_ofcxx . . $ std/__cxx11/basic_string#find_first_of(7e867d215bf3e68).(delimiters, lastPos); |
| 46 | if (pos == stdcxx . . $ std/::stringcxx . . $ std/string#::nposcxx . . $ std/__cxx11/basic_string#npos.) return (cxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5).line); |
| 47 | |
| 48 | return linecxx . . $ std/__cxx11/basic_string#basic_string(3bc0f77cdfbaa67f)..substrcxx . . $ std/__cxx11/basic_string#substr(149c655009c9bbd2).(lastPos, pos-lastPos); |
| 49 | } |
| 50 | |
| 51 | static inline stdcxx . . $ std/::stringcxx . . $ std/string# getNextWordcxx . . $ StringTokenizer#getNextWord(d6887f0d22b52f3).(const stdcxx . . $ std/::stringcxx . . $ std/string#& line, stdcxx . . $ std/::stringcxx . . $ std/string#::size_typecxx . . $ std/__cxx11/basic_string#size_type# &pos, stdcxx . . $ std/::stringcxx . . $ std/string#::size_typecxx . . $ std/__cxx11/basic_string#size_type# &lastPos, const stdcxx . . $ std/::stringcxx . . $ std/string#& delimiters) |
| 52 | { |
| 53 | lastPos = line.find_first_not_ofcxx . . $ std/__cxx11/basic_string#find_first_not_of(7e867d215bf3e68).(delimiters, pos); |
| 54 | if (lastPos == stdcxx . . $ std/::stringcxx . . $ std/string#::nposcxx . . $ std/__cxx11/basic_string#npos.) returncxx . . $ std/__cxx11/basic_string#basic_string(3bc0f77cdfbaa67f). (cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).""); |
| 55 | pos = line.find_first_ofcxx . . $ std/__cxx11/basic_string#find_first_of(7e867d215bf3e68).(delimiters, lastPos); |
| 56 | if (pos == stdcxx . . $ std/::stringcxx . . $ std/string#::nposcxx . . $ std/__cxx11/basic_string#npos.) pos=line.lengthcxx . . $ std/__cxx11/basic_string#length(48278e53df7b52a5).(); |
| 57 | |
| 58 | return linecxx . . $ std/__cxx11/basic_string#basic_string(3bc0f77cdfbaa67f)..substrcxx . . $ std/__cxx11/basic_string#substr(149c655009c9bbd2).(lastPos, pos-lastPos); |
| 59 | |
| 60 | } |
| 61 | }; |
| 62 | #endif // STRINGTOKENIZER_H |