ffead.server.doc
StringUtil.h
1 /*
2  Copyright 2009-2012, Sumeet Chhetri
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 /*
17  * StringUtil.h
18  *
19  * Created on: Aug 5, 2012
20  * Author: Sumeet
21  */
22 
23 #ifndef STRINGUTIL_H_
24 #define STRINGUTIL_H_
25 #include "string"
26 #include <algorithm>
27 #include <sstream>
28 #include <iterator>
29 #include "vector"
30 using namespace std;
31 
32 class StringUtil {
33  static void splitInternal(vector<string> &output, const string& input, const string& delimiter);
34 public:
35  StringUtil();
36  virtual ~StringUtil();
37  static void eraseAll(string &str, const string& ths);
38  static void capitalized(string &str);
39  static string capitalizedCopy(const string &str);
40  static void toUpper(string &str);
41  static string toUpperCopy(const string& str);
42  static void toLower(string& str);
43  static string toLowerCopy(const string& str);
44  static void replaceFirst(string &str, const string& ths, const string& with);
45  static string replaceFirstCopy(const string &str, const string& ths, const string& with);
46  static void replaceLast(string &str, const string& ths, const string& with);
47  static string replaceLastCopy(const string &str, const string& ths, const string& with);
48  static void replaceAll(string &str, const string& ths, const string& with);
49  static string replaceAllCopy(const string &str, const string& ths, const string& with);
50  static vector<string> split(const string& input, const string& delimiter);
51  static void split(vector<string> &output, const string& input, const string& delimiter);
52  static vector<string> split(const string& input, vector<string> delimiters);
53  static void split(vector<string> &output, const string& input, vector<string> delimiters);
54  static void trim(string& str);
55  static string trimCopy(const string &str);
56 };
57 
58 #endif /* STRINGUTIL_H_ */