2
* This file is part of CSSTidy.
4
* CSSTidy is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* CSSTidy is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with CSSTidy; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
#include "csspp_globals.hpp"
22
const string trim(const string istring)
24
std::string::size_type first = istring.find_first_not_of(" \n\t\r\0xb");
25
if (first == std::string::npos) {
29
std::string::size_type last = istring.find_last_not_of(" \n\t\r\0xb");
30
return istring.substr( first, last - first + 1);
34
const string ltrim(const string istring)
36
std::string::size_type first = istring.find_first_not_of(" \n\t\r\0xb");
37
if (first == std::string::npos) {
41
return istring.substr( first );
46
const string rtrim(const string istring)
48
std::string::size_type last = istring.find_last_not_of(" \n\t\r\0xb"); /// must succeed
49
return istring.substr( 0, last + 1);
52
const string rtrim(const string istring, const string chars)
54
std::string::size_type last = istring.find_last_not_of(chars); /// must succeed
55
return istring.substr( 0, last + 1);
58
string strip_tags(string istring)
63
for(int i = 0; i < istring.length(); i++)
65
if(istring[i] != '<' && !intag)
67
new_string += istring[i];
69
if(istring[i] == '<' && !intag)
73
if(istring[i] == '>' && intag)