blob: 1dd303fb3816d10c1570c25be3e177c04163ded0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#pragma once
#include <string>
#include <vector>
#include <sstream>
#define SWIFTEN_STRING_TO_CFSTRING(a) \
CFStringCreateWithBytes(NULL, reinterpret_cast<const UInt8*>(a.c_str()), a.size(), kCFStringEncodingUTF8, false)
namespace Swift {
namespace String {
std::vector<unsigned int> getUnicodeCodePoints(const std::string&);
std::pair<std::string, std::string> getSplittedAtFirst(const std::string&, char c);
std::vector<std::string> split(const std::string&, char c);
void replaceAll(std::string&, char c, const std::string& s);
inline bool beginsWith(const std::string& s, char c) {
return s.size() > 0 && s[0] == c;
}
inline bool endsWith(const std::string& s, char c) {
return s.size() > 0 && s[s.size()-1] == c;
}
std::string convertIntToHexString(int h);
int convertHexStringToInt(const std::string& s);
};
class makeString {
public:
template <typename T> makeString& operator<<(T const& v) {
stream << v;
return *this;
}
operator std::string() const {
return stream.str();
}
private:
std::ostringstream stream;
};
}
|