1
2
3
4
5
6 #ifndef SOULNG_UTIL_TEXTUTILS_INCLUDED
7 #define SOULNG_UTIL_TEXTUTILS_INCLUDED
8 #include <soulng/util/UtilApi.hpp>
9 #include <string>
10 #include <vector>
11 #include <stdint.h>
12
13 namespace soulng { namespace util {
14
15 enum class FormatWidth
16 {
17 exact, min
18 };
19
20 enum class FormatJustify
21 {
22 left, right
23 };
24
25 std::string Trim(const std::string& s);
26 std::string TrimAll(const std::string& s);
27 std::u32string Trim(const std::u32string& s);
28 std::u32string TrimAll(const std::u32string& s);
29 std::vector<std::string> Split(const std::string& s, char c);
30 std::string Replace(const std::string& s, char oldChar, char newChar);
31 std::string Replace(const std::string& s, const std::string& oldString, const std::string& newString);
32 std::string HexEscape(char c);
33 std::u32string HexEscape(uint32_t c);
34 std::string CharStr(char c);
35 std::u32string CharStr(char32_t c);
36 std::string StringStr(const std::string& s);
37 std::u32string StringStr(const std::u32string& s);
38 std::string MakeStringLiteral(const std::string& s);
39 std::u32string MakeStringLiteral(const std::u32string& s);
40 std::string QuotedPath(const std::string& path);
41 bool LastComponentsEqual(const std::string& s0, const std::string& s1, char componentSeparator);
42 bool StartsWith(const std::string& s, const std::string& prefix);
43 bool StartsWith(const std::u32string& s, const std::u32string& prefix);
44 bool EndsWith(const std::string& s, const std::string& suffix);
45 bool EndsWith(const std::u32string& s, const std::u32string& suffix);
46 std::string NarrowString(const char* str, int length);
47 std::string ToUpper(const std::string& s);
48 std::string ToLower(const std::string& s);
49 std::string ToString(double x);
50 std::string ToString(double x, int maxNumDecimals);
51 std::string ToString(double x, int minNumDecimals, int maxNumDecimals);
52 std::string ToHexString(uint8_t x);
53 std::string ToHexString(uint16_t x);
54 std::string ToHexString(uint32_t x);
55 std::string ToHexString(uint64_t x);
56 uint8_t ParseHexByte(const std::string& hexByteStr);
57 int Log10(int n);
58 std::u32string FormatNumber(int n, int numDigits);
59 std::string CurrentThreadIdStr();
60 std::string Format(const std::string& s, int width);
61 std::string Format(const std::string& s, int width, FormatJustify justify);
62 std::string Format(const std::string& s, int width, FormatWidth fw);
63 std::string Format(const std::string& s, int width, FormatWidth fw, FormatJustify justify);
64 std::string Format(const std::string& s, int width, FormatWidth fw, FormatJustify justify, char fillChar);
65 std::string PlatformStringToUtf8(const std::string& platformString);
66
67 } }
68
69 #endif // SOULNG_UTIL_TEXTUTILS_INCLUDED