AWS SDK for C++

AWS SDK for C++ Version 1.11.440

Loading...
Searching...
No Matches
StringUtils.h
1
6#pragma once
7
8#include <aws/core/Core_EXPORTS.h>
9
10#include <aws/core/utils/memory/stl/AWSString.h>
11#include <aws/core/utils/memory/stl/AWSVector.h>
12#include <aws/core/utils/memory/stl/AWSStringStream.h>
13#include <aws/common/byte_buf.h>
14
15
16namespace Aws
17{
18 namespace Utils
19 {
23 class AWS_CORE_API StringUtils
24 {
25 public:
26 static void Replace(Aws::String& s, const char* search, const char* replace);
27
28
32 static Aws::String ToLower(const char* source);
33
34
38 static Aws::String ToUpper(const char* source);
39
40
44 static bool CaselessCompare(const char* value1, const char* value2);
45
46
50 static Aws::String URLEncode(const char* unsafe);
51
52 static inline Aws::String URLEncode(const Aws::String& unsafe)
53 {
54 return URLEncode(unsafe.c_str());
55 }
56
62 static Aws::String UTF8Escape(const char* unicodeString, const char* delimiter);
63
67 static Aws::String URLEncode(double unsafe);
68
69
73 static Aws::String URLDecode(const char* safe);
74
75 enum class SplitOptions
76 {
80 NOT_SET,
84 INCLUDE_EMPTY_ENTRIES,
88 INCLUDE_EMPTY_SEGMENTS,
89 };
90
96 static Aws::Vector<Aws::String> Split(const Aws::String& toSplit, char splitOn);
97
104 static Aws::Vector<Aws::String> Split(const Aws::String& toSplit, char splitOn, SplitOptions option);
105
112 static Aws::Vector<Aws::String> Split(const Aws::String& toSplit, char splitOn, size_t numOfTargetParts);
113
121 static Aws::Vector<Aws::String> Split(const Aws::String& toSplit, char splitOn, size_t numOfTargetParts, SplitOptions option);
122
128 static Aws::Vector<Aws::String> SplitWithSpaces(const Aws::String& toSplit, char splitOn);
129
134
135
139 static Aws::String LTrim(const char* source);
140
141
145 static Aws::String RTrim(const char* source);
146
150 static Aws::String Trim(const char* source);
151
152
156 static long long ConvertToInt64(const char* source);
157
158
162 static long ConvertToInt32(const char* source);
163
164
168 static bool ConvertToBool(const char* source);
169
170
174 static double ConvertToDouble(const char* source);
175
176
177#ifdef _WIN32
181 static Aws::WString ToWString(const char* source);
182
186 static Aws::String FromWString(const wchar_t* source);
187#endif
188
192 template< typename T >
193 static Aws::String to_string(T value)
194 {
196 os << value;
197 return os.str();
198 }
199
203 static bool IsAlnum(char c)
204 {
205 return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9');
206 }
207
211 template<typename T, class = typename std::enable_if<std::is_unsigned<T>::value>::type>
212 static Aws::String ToHexString(T value)
213 {
214 if (value == 0)
215 {
216 return "0";
217 }
218
219 Aws::String s;
220 s.reserve(sizeof(value) * 2);
221 T r = value;
222 while (r > 0)
223 {
224 s += "0123456789ABCDEF"[r & 0xf];
225 r >>= 4;
226 }
227
228 std::reverse(s.begin(), s.end());
229 return s;
230 }
231
232 static Aws::String FromByteCursor(aws_byte_cursor cursor)
233 {
234 return Aws::String(reinterpret_cast<char *>(cursor.ptr), cursor.len);
235 }
236 };
237
238
239 } // namespace Utils
240} // namespace Aws
static Aws::Vector< Aws::String > SplitOnLine(const Aws::String &toSplit)
static Aws::Vector< Aws::String > Split(const Aws::String &toSplit, char splitOn, size_t numOfTargetParts)
Splits a string on a delimiter (empty items are excluded).
static Aws::Vector< Aws::String > Split(const Aws::String &toSplit, char splitOn, SplitOptions option)
Splits a string on a delimiter.
static long ConvertToInt32(const char *source)
static void Replace(Aws::String &s, const char *search, const char *replace)
static long long ConvertToInt64(const char *source)
static bool IsAlnum(char c)
static Aws::String ToUpper(const char *source)
static Aws::String ToLower(const char *source)
static Aws::String LTrim(const char *source)
static Aws::String ToHexString(T value)
static Aws::String FromByteCursor(aws_byte_cursor cursor)
static bool ConvertToBool(const char *source)
static Aws::String Trim(const char *source)
static Aws::String URLEncode(double unsafe)
static Aws::Vector< Aws::String > SplitWithSpaces(const Aws::String &toSplit, char splitOn)
static Aws::String to_string(T value)
static Aws::String URLEncode(const char *unsafe)
static Aws::String UTF8Escape(const char *unicodeString, const char *delimiter)
static Aws::Vector< Aws::String > Split(const Aws::String &toSplit, char splitOn)
Splits a string on a delimiter (empty items are excluded).
static Aws::String RTrim(const char *source)
static Aws::String URLEncode(const Aws::String &unsafe)
Definition StringUtils.h:52
static Aws::String URLDecode(const char *safe)
static double ConvertToDouble(const char *source)
static Aws::Vector< Aws::String > Split(const Aws::String &toSplit, char splitOn, size_t numOfTargetParts, SplitOptions option)
Splits a string on a delimiter.
static bool CaselessCompare(const char *value1, const char *value2)
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
Definition AWSString.h:97
std::basic_ostringstream< char, std::char_traits< char >, Aws::Allocator< char > > OStringStream
std::vector< T, Aws::Allocator< T > > Vector
Definition AWSVector.h:17