cppassist  1.0.0.f4fab4f962ff
C++ sanctuary for small but powerful and frequently required, stand alone features.
manipulation.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 
5 #include <string>
6 #include <vector>
7 #include <set>
8 
9 #include <cppassist/cppassist_api.h>
10 
11 
12 namespace cppassist
13 {
14 namespace string
15 {
16 
17 
30 template <class Iterable>
31 std::string join(const Iterable & iterable, const std::string & separator);
32 
45 CPPASSIST_API std::string trim(const std::string & string, bool removeAllWhitespace = false);
46 
61 CPPASSIST_API std::string padLeft(const std::string & string, size_t length, char c = ' ');
62 
77 CPPASSIST_API std::string padRight(const std::string & string, size_t length, char c = ' ');
78 
91 CPPASSIST_API std::string stripped(const std::string & string, const std::set<char> & blacklist);
92 
105 CPPASSIST_API std::vector<std::string> parseArray(const std::string & string, size_t size);
106 
121 CPPASSIST_API std::vector<std::string> split(const std::string & string, char delimiter, bool keepEmptyParts = true);
122 
135 CPPASSIST_API bool contains(const std::string & string, const std::string & containsstring);
136 
149 CPPASSIST_API bool hasPrefix(const std::string & string, const std::string & prefix);
150 
163 CPPASSIST_API bool hasSuffix(const std::string & string, const std::string & suffix);
164 
165 
166 } // namespace string
167 } // namespace cppassist
168 
169 
CPPASSIST_API bool hasPrefix(const std::string &string, const std::string &prefix)
Check if a string starts with a given prefix.
CPPASSIST_API std::vector< std::string > parseArray(const std::string &string, size_t size)
Split string into substrings.
Definition: ArgumentParser.h:12
CPPASSIST_API std::string stripped(const std::string &string, const std::set< char > &blacklist)
Remove all occurences of provided characters from the string.
CPPASSIST_API std::vector< std::string > split(const std::string &string, char delimiter, bool keepEmptyParts=true)
Split string into substrings.
CPPASSIST_API std::string trim(const std::string &string, bool removeAllWhitespace=false)
Trim string by removing whitespace.
std::string join(const Iterable &iterable, const std::string &separator)
Join all values of a container in a single string.
Definition: manipulation.inl:15
CPPASSIST_API bool contains(const std::string &string, const std::string &containsstring)
Check if a string contains a substring.
CPPASSIST_API std::string padRight(const std::string &string, size_t length, char c=' ')
Pad string with character (add to the right until the given size is reached)
CPPASSIST_API bool hasSuffix(const std::string &string, const std::string &suffix)
Check if a string ends with a given suffix.
CPPASSIST_API std::string padLeft(const std::string &string, size_t length, char c=' ')
Pad string with character (add to the left until the given size is reached)