3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 void start(std::string niinq){
36 void to(unsigned int i){
42 std::string next(std::string plop){
43 //std::cout<<"tek=\""<<tek<<"\" plop=\""<<plop<<"\""<<std::endl;
48 //std::cout<<"\tp<tek.size()"<<std::endl;
49 if ((n = tek.find(plop, p)) == std::string::npos || plop == "")
51 //std::cout<<"\t\tn == string::npos || plop == \"\""<<std::endl;
56 //std::cout<<"\t\tn != string::npos"<<std::endl;
58 palautus = tek.substr(p, n-p);
59 p = n + plop.length();
62 //std::cout<<"\tp>=tek.size()"<<std::endl;
63 //std::cout<<"palautus=\""<<palautus<<"\""<<std::endl;
67 // Returns substr of tek up to the next occurence of plop that isn't escaped with '\'
68 std::string next_esc(std::string plop) {
76 n = tek.find(plop, p);
77 if (n == std::string::npos || plop == "")
79 p = n + plop.length();
80 } while (n > 0 && tek[n - 1] == '\\');
82 return tek.substr(realp, n - realp);
85 void skip_over(std::string chars){
86 while(p < tek.size()){
88 for(unsigned int i=0; i<chars.size(); i++){
89 if(chars[i] == tek[p]){
99 if(p>=tek.size()) return true;
102 Strfnd(std::string s){
111 void start(std::wstring niinq){
115 unsigned int where(){
118 void to(unsigned int i){
124 std::wstring next(std::wstring plop){
125 //std::cout<<"tek=\""<<tek<<"\" plop=\""<<plop<<"\""<<std::endl;
127 std::wstring palautus;
130 //std::cout<<"\tp<tek.size()"<<std::endl;
131 if ((n = tek.find(plop, p)) == std::wstring::npos || plop == L"")
133 //std::cout<<"\t\tn == string::npos || plop == \"\""<<std::endl;
138 //std::cout<<"\t\tn != string::npos"<<std::endl;
140 palautus = tek.substr(p, n-p);
141 p = n + plop.length();
144 //std::cout<<"\tp>=tek.size()"<<std::endl;
145 //std::cout<<"palautus=\""<<palautus<<"\""<<std::endl;
149 std::wstring next_esc(std::wstring plop) {
157 n = tek.find(plop, p);
158 if (n == std::wstring::npos || plop == L"")
160 p = n + plop.length();
161 } while (n > 0 && tek[n - 1] == '\\');
163 return tek.substr(realp, n - realp);
167 if(p>=tek.size()) return true;
170 WStrfnd(std::wstring s){