OpenAB  1.0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
StringHelper.hpp
Go to the documentation of this file.
1 /*
2  * This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5  */
10 #ifndef STRINGHELPER_HPP_
11 #define STRINGHELPER_HPP_
12 #include <string>
13 #include <vector>
14 
18 namespace OpenAB {
19 
24 void trimWhitespaces (std::string& str);
25 
30 void trimSpaces (std::string& str);
31 
41 std::vector<std::string> tokenize(const std::string& str, char delimiter, bool unique = false, bool leaveEmptyTokens = true);
42 
49 bool contains(const std::vector<std::string>& vec, const std::string& str);
50 
57 bool beginsWith (const std::string& str, const std::string& substr);
58 
65 bool endsWith (const std::string& str, const std::string& substr );
66 
72 void eraseAllOccurences(std::string& str, char toRemove);
73 
81 void substituteAll (std::string& str, const std::string& from, const std::string& to);
82 
92 std::string cut(const std::string& str, const std::string& begin, const std::string& end, std::string::size_type& pos);
93 
106 std::vector<std::string> parserURL(const std::string& url);
107 
113 std::string parseURLHostPart(const std::string& url);
114 
121 bool getUnfoldedLine(std::istream& is, std::string& str);
122 
127 void linearize(std::string& str);
128 
133 void unquoteSpecialCharacters(std::string& str);
134 
135 std::string percentDecode(const std::string& uri);
136 
137 
138 } // namespace OpenAB
139 
140 #endif // STRINGHELPER_HPP_
bool contains(const std::vector< std::string > &vec, const std::string &str)
Checks if given string is contained in vector of strings.
Definition: StringHelper.cpp:16
bool getUnfoldedLine(std::istream &is, std::string &str)
Definition: StringHelper.cpp:220
void trimWhitespaces(std::string &str)
Removes whitespaces from beginning and end of given string.
Definition: StringHelper.cpp:29
std::string cut(const std::string &str, const std::string &begin, const std::string &end, std::string::size_type &pos)
Cuts part of string contained between two substrings.
Definition: StringHelper.cpp:92
std::string parseURLHostPart(const std::string &url)
Parses host part out of URL.
Definition: StringHelper.cpp:174
void eraseAllOccurences(std::string &str, char toRemove)
Removes all occurences of given character from string.
Definition: StringHelper.cpp:87
void unquoteSpecialCharacters(std::string &str)
Removes quotation of special characters e.g. converts "\," into ",".
Definition: StringHelper.cpp:255
void linearize(std::string &str)
Unfolds all lines in provided string. check if it does not duplicates functionality from getUnfoldedL...
Definition: StringHelper.cpp:242
void substituteAll(std::string &str, const std::string &from, const std::string &to)
Substitutes all occurrences of given substring.
Definition: StringHelper.cpp:190
void trimSpaces(std::string &str)
Removes whitespaces and spaces from beginning and end of given string.
Definition: StringHelper.cpp:40
std::vector< std::string > tokenize(const std::string &str, char delimiter, bool unique, bool leaveEmptyTokens)
Tokenizes string. Uses provided delimiter for tokens, process can be controlled by behavior in case o...
Definition: StringHelper.cpp:51
bool beginsWith(const std::string &str, const std::string &substr)
Checks if given string begins with given substring.
Definition: StringHelper.cpp:202
std::vector< std::string > parserURL(const std::string &url)
Parses URL into parts. URL is parsed into four parts: scheme (http, https, ftp, etc.), host, path and query, eg. http://www.google.com/search?q=test will be parsed into:
Definition: StringHelper.cpp:124
bool endsWith(const std::string &str, const std::string &substr)
Checks if given string ends with given substring.
Definition: StringHelper.cpp:211
std::string percentDecode(const std::string &uri)
Definition: StringHelper.cpp:272