3 Copyright (C) 2010 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 General Public License as published by
7 the Free Software Foundation; either version 2 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 General Public License for more details.
15 You should have received a copy of the GNU 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.
25 std::string trim(const std::string &str);
31 void start(std::string niinq){
38 void to(unsigned int i){
44 std::string next(std::string plop){
45 //std::cout<<"tek=\""<<tek<<"\" plop=\""<<plop<<"\""<<std::endl;
50 //std::cout<<"\tp<tek.size()"<<std::endl;
51 if ((n = tek.find(plop, p)) == std::string::npos || plop == "")
53 //std::cout<<"\t\tn == string::npos || plop == \"\""<<std::endl;
58 //std::cout<<"\t\tn != string::npos"<<std::endl;
60 palautus = tek.substr(p, n-p);
61 p = n + plop.length();
64 //std::cout<<"\tp>=tek.size()"<<std::endl;
65 //std::cout<<"palautus=\""<<palautus<<"\""<<std::endl;
69 if(p>=tek.size()) return true;
72 Strfnd(std::string s){
77 inline std::string trim(const std::string &s)
84 str.substr(0, 1)==" " ||
85 str.substr(0, 1)=="\t" ||
86 str.substr(0, 1)=="\r" ||
87 str.substr(0, 1)=="\n" ||
88 str.substr(str.length()-1, 1)==" " ||
89 str.substr(str.length()-1, 1)=="\t" ||
90 str.substr(str.length()-1, 1)=="\r" ||
91 str.substr(str.length()-1, 1)=="\n"
95 if (str.substr(0, 1)==" ")
96 str = str.substr(1,str.length()-1);
97 else if (str.substr(0, 1)=="\t")
98 str = str.substr(1,str.length()-1);
99 else if (str.substr(0, 1)=="\r")
100 str = str.substr(1,str.length()-1);
101 else if (str.substr(0, 1)=="\n")
102 str = str.substr(1,str.length()-1);
103 else if (str.substr(str.length()-1, 1)==" ")
104 str = str.substr(0,str.length()-1);
105 else if (str.substr(str.length()-1, 1)=="\t")
106 str = str.substr(0,str.length()-1);
107 else if (str.substr(str.length()-1, 1)=="\r")
108 str = str.substr(0,str.length()-1);
109 else if (str.substr(str.length()-1, 1)=="\n")
110 str = str.substr(0,str.length()-1);