1 /*
2  * This file is part of CSSTidy.
3  *
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.
8  *
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.
13  *
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
17  */
18 
19 #ifndef HEADER_CSS_MISC
20 #define HEADER_CSS_MISC
21 
22 // Checks if a charcter is escaped
23 bool escaped(const string &istring, int pos);
24 
25 // Returns a char of a string at pos but checks the string-length before
26 char s_at(const string &istring, int pos);
27 
28 // Splits a string at e
29 vector<string> explode(const string e, string s, const bool check = false);
30 
31 // Implodes a string at e
32 std::string implode(const string e, const vector<string> s);
33 
34 // Replaces <find> with <replace> in <str>
35 string str_replace(const string find, const string replace, string str);
36 
37 // Replaces all values of <find> with <replace> in <str>
38 string str_replace(const vector<string>& find, const string replace, string str);
39 
40 // Checks if a string exists in a string-array
41 bool in_char_arr(const char* haystack, const char needle);
42 bool in_str_array(const string& haystack, const char needle);
43 bool in_str_array(const vector<string>& haystack, const string needle);
44 
45 // Replaces certain chars with their entities
46 string htmlspecialchars(string istring, int quotes = 0);
47 
48 // Rounds a float value
49 float round(const float &number, const int num_digits);
50 
51 // Replacement for max (so that I don't have to include unnecessary things)
52 int max(const int i1, const int i2);
53 
54 /* isspace() and isdigit() do not work correctly with UTF-8 strings */
55 bool ctype_space(const char c);
56 bool ctype_digit(const char c);
57 bool ctype_xdigit(char c);
58 bool ctype_alpha(char c);
59 
60 /* Unserialise string arrays */
61 vector<string> unserialise_sa(const string istring);
62 
63 /* Serialise a string */
64 string serialise_sa(const string istring);
65 
66 #endif // HEADER_CSS_MISC
67