| |
| |
| |
| |
|
|
| #pragma once |
|
|
| #include <aws/core/Core_EXPORTS.h> |
|
|
| #include <aws/core/utils/memory/stl/AWSString.h> |
| #include <aws/core/utils/memory/stl/AWSVector.h> |
| #include <aws/core/utils/memory/stl/AWSStringStream.h> |
| #include <aws/common/byte_buf.h> |
|
|
|
|
| namespace Aws |
| { |
| namespace Utils |
| { |
| |
| |
| |
| class AWS_CORE_API StringUtils |
| { |
| public: |
| static void Replace(Aws::String& s, const char* search, const char* replace); |
|
|
|
|
| |
| |
| |
| static Aws::String ToLower(const char* source); |
|
|
|
|
| |
| |
| |
| static Aws::String ToUpper(const char* source); |
|
|
|
|
| |
| |
| |
| static bool CaselessCompare(const char* value1, const char* value2); |
|
|
|
|
| |
| |
| |
| static Aws::String URLEncode(const char* unsafe); |
|
|
| static inline Aws::String URLEncode(const Aws::String& unsafe) |
| { |
| return URLEncode(unsafe.c_str()); |
| } |
|
|
| |
| |
| |
| |
| |
| static Aws::String UTF8Escape(const char* unicodeString, const char* delimiter); |
|
|
| |
| |
| |
| static Aws::String URLEncode(double unsafe); |
|
|
|
|
| |
| |
| |
| static Aws::String URLDecode(const char* safe); |
|
|
| enum class SplitOptions |
| { |
| |
| |
| |
| NOT_SET, |
| |
| |
| |
| INCLUDE_EMPTY_ENTRIES, |
| |
| |
| |
| INCLUDE_EMPTY_SEGMENTS, |
| }; |
|
|
| |
| |
| |
| |
| |
| static Aws::Vector<Aws::String> Split(const Aws::String& toSplit, char splitOn); |
|
|
| |
| |
| |
| |
| |
| |
| static Aws::Vector<Aws::String> Split(const Aws::String& toSplit, char splitOn, SplitOptions option); |
|
|
| |
| |
| |
| |
| |
| |
| static Aws::Vector<Aws::String> Split(const Aws::String& toSplit, char splitOn, size_t numOfTargetParts); |
|
|
| |
| |
| |
| |
| |
| |
| |
| static Aws::Vector<Aws::String> Split(const Aws::String& toSplit, char splitOn, size_t numOfTargetParts, SplitOptions option); |
|
|
| |
| |
| |
| |
| |
| static Aws::Vector<Aws::String> SplitWithSpaces(const Aws::String& toSplit, char splitOn); |
|
|
| |
| |
| |
| static Aws::Vector<Aws::String> SplitOnLine(const Aws::String& toSplit); |
|
|
|
|
| |
| |
| |
| static Aws::String LTrim(const char* source); |
|
|
|
|
| |
| |
| |
| static Aws::String RTrim(const char* source); |
|
|
| |
| |
| |
| static Aws::String Trim(const char* source); |
|
|
|
|
| |
| |
| |
| static long long ConvertToInt64(const char* source); |
|
|
|
|
| |
| |
| |
| static long ConvertToInt32(const char* source); |
|
|
|
|
| |
| |
| |
| static bool ConvertToBool(const char* source); |
|
|
|
|
| |
| |
| |
| static double ConvertToDouble(const char* source); |
|
|
|
|
| #ifdef _WIN32 |
| |
| |
| |
| static Aws::WString ToWString(const char* source); |
|
|
| |
| |
| |
| static Aws::String FromWString(const wchar_t* source); |
| #endif |
|
|
| |
| |
| |
| template< typename T > |
| static Aws::String to_string(T value) |
| { |
| Aws::OStringStream os; |
| os << value; |
| return os.str(); |
| } |
|
|
| |
| |
| |
| static bool IsAlnum(char c) |
| { |
| return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9'); |
| } |
|
|
| |
| |
| |
| template<typename T, class = typename std::enable_if<std::is_unsigned<T>::value>::type> |
| static Aws::String ToHexString(T value) |
| { |
| if (value == 0) |
| { |
| return "0"; |
| } |
|
|
| Aws::String s; |
| s.reserve(sizeof(value) * 2); |
| T r = value; |
| while (r > 0) |
| { |
| s += "0123456789ABCDEF"[r & 0xf]; |
| r >>= 4; |
| } |
|
|
| std::reverse(s.begin(), s.end()); |
| return s; |
| } |
|
|
| static Aws::String FromByteCursor(aws_byte_cursor cursor) |
| { |
| return Aws::String(reinterpret_cast<char *>(cursor.ptr), cursor.len); |
| } |
| }; |
|
|
|
|
| } |
| } |
|
|