AWS SDK for C++  1.9.159
AWS SDK for C++
StringUtils.h
Go to the documentation of this file.
1 
6 #pragma once
7 
9 
13 #include <aws/common/byte_buf.h>
14 
15 
16 namespace Aws
17 {
18  namespace Utils
19  {
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 
57  static Aws::String UTF8Escape(const char* unicodeString, const char* delimiter);
58 
62  static Aws::String URLEncode(double unsafe);
63 
64 
68  static Aws::String URLDecode(const char* safe);
69 
70  enum class SplitOptions
71  {
75  NOT_SET,
79  INCLUDE_EMPTY_ENTRIES
80  };
81 
87  static Aws::Vector<Aws::String> Split(const Aws::String& toSplit, char splitOn);
88 
95  static Aws::Vector<Aws::String> Split(const Aws::String& toSplit, char splitOn, SplitOptions option);
96 
103  static Aws::Vector<Aws::String> Split(const Aws::String& toSplit, char splitOn, size_t numOfTargetParts);
104 
112  static Aws::Vector<Aws::String> Split(const Aws::String& toSplit, char splitOn, size_t numOfTargetParts, SplitOptions option);
113 
118 
119 
123  static Aws::String LTrim(const char* source);
124 
125 
129  static Aws::String RTrim(const char* source);
130 
134  static Aws::String Trim(const char* source);
135 
136 
140  static long long ConvertToInt64(const char* source);
141 
142 
146  static long ConvertToInt32(const char* source);
147 
148 
152  static bool ConvertToBool(const char* source);
153 
154 
158  static double ConvertToDouble(const char* source);
159 
160 
161 #ifdef _WIN32
162 
165  static Aws::WString ToWString(const char* source);
166 
170  static Aws::String FromWString(const wchar_t* source);
171 #endif
172 
176  template< typename T >
177  static Aws::String to_string(T value)
178  {
180  os << value;
181  return os.str();
182  }
183 
187  static bool IsAlnum(char c)
188  {
189  return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9');
190  }
191 
195  template<typename T, class = typename std::enable_if<std::is_unsigned<T>::value>::type>
196  static Aws::String ToHexString(T value)
197  {
198  if (value == 0)
199  {
200  return "0";
201  }
202 
203  Aws::String s;
204  s.reserve(sizeof(value) * 2);
205  T r = value;
206  while (r > 0)
207  {
208  s += "0123456789ABCDEF"[r & 0xf];
209  r >>= 4;
210  }
211 
212  std::reverse(s.begin(), s.end());
213  return s;
214  }
215 
216  static Aws::String FromByteCursor(aws_byte_cursor cursor)
217  {
218  return Aws::String(reinterpret_cast<char *>(cursor.ptr), cursor.len);
219  }
220  };
221 
222 
223  } // namespace Utils
224 } // namespace Aws
Aws::Utils::StringUtils::URLEncode
static Aws::String URLEncode(double unsafe)
Aws::Utils::StringUtils::Split
static Aws::Vector< Aws::String > Split(const Aws::String &toSplit, char splitOn, SplitOptions option)
Splits a string on a delimiter.
AWS_CORE_API
#define AWS_CORE_API
Definition: Core_EXPORTS.h:25
Aws::Utils::StringUtils::LTrim
static Aws::String LTrim(const char *source)
Aws::Utils::StringUtils::RTrim
static Aws::String RTrim(const char *source)
Aws::Utils::StringUtils::ConvertToDouble
static double ConvertToDouble(const char *source)
Aws::Utils::StringUtils::FromByteCursor
static Aws::String FromByteCursor(aws_byte_cursor cursor)
Definition: StringUtils.h:216
Aws::OStringStream
std::basic_ostringstream< char, std::char_traits< char >, Aws::Allocator< char > > OStringStream
Definition: AWSStringStream.h:37
Aws::Utils::StringUtils::Split
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).
Aws::Utils::StringUtils::SplitOnLine
static Aws::Vector< Aws::String > SplitOnLine(const Aws::String &toSplit)
Aws::Vector
std::vector< T, Aws::Allocator< T > > Vector
Definition: AWSVector.h:17
Aws::Utils::StringUtils::ConvertToBool
static bool ConvertToBool(const char *source)
Aws::Utils::StringUtils::URLDecode
static Aws::String URLDecode(const char *safe)
AWSVector.h
Aws::Utils::StringUtils
Definition: StringUtils.h:24
Aws::Utils::StringUtils::ConvertToInt32
static long ConvertToInt32(const char *source)
Aws::Utils::StringUtils::URLEncode
static Aws::String URLEncode(const char *unsafe)
Aws::Utils::StringUtils::ConvertToInt64
static long long ConvertToInt64(const char *source)
Aws::Utils::StringUtils::UTF8Escape
static Aws::String UTF8Escape(const char *unicodeString, const char *delimiter)
Aws::Utils::StringUtils::ToUpper
static Aws::String ToUpper(const char *source)
Aws::Utils::StringUtils::ToHexString
static Aws::String ToHexString(T value)
Definition: StringUtils.h:196
Aws::Utils::StringUtils::Split
static Aws::Vector< Aws::String > Split(const Aws::String &toSplit, char splitOn, size_t numOfTargetParts, SplitOptions option)
Splits a string on a delimiter.
Aws::Utils::StringUtils::to_string
static Aws::String to_string(T value)
Definition: StringUtils.h:177
AWSStringStream.h
Aws::Utils::StringUtils::Split
static Aws::Vector< Aws::String > Split(const Aws::String &toSplit, char splitOn)
Splits a string on a delimiter (empty items are excluded).
AWSString.h
Aws::Utils::StringUtils::SplitOptions
SplitOptions
Definition: StringUtils.h:71
Core_EXPORTS.h
Aws
Definition: AccessManagementClient.h:15
Aws::Utils::StringUtils::Trim
static Aws::String Trim(const char *source)
Aws::String
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
Definition: AWSString.h:97
Aws::Utils::StringUtils::Replace
static void Replace(Aws::String &s, const char *search, const char *replace)
Aws::Utils::StringUtils::CaselessCompare
static bool CaselessCompare(const char *value1, const char *value2)
Aws::Utils::StringUtils::ToLower
static Aws::String ToLower(const char *source)
Aws::Utils::StringUtils::IsAlnum
static bool IsAlnum(char c)
Definition: StringUtils.h:187