26 #ifndef INCLUDE_OLA_STRINGUTILS_H_
27 #define INCLUDE_OLA_STRINGUTILS_H_
45 void StringSplit(
const std::string &input,
46 std::vector<std::string> &tokens,
47 const std::string &delimiters=
" ");
59 void ShortenString(std::string *input);
67 bool StringEndsWith(
const std::string &s,
const std::string &suffix);
98 void Escape(std::string *original);
106 std::string EscapeString(
const std::string &original);
114 void ReplaceAll(std::string *original,
115 const std::string &find,
116 const std::string &replace);
127 std::string EncodeString(
const std::string &original);
136 bool StringToBool(
const std::string &value,
bool *output);
146 bool StringToInt(
const std::string &value,
147 unsigned int *output,
148 bool strict =
false);
159 bool StringToInt(
const std::string &value,
161 bool strict =
false);
172 bool StringToInt(
const std::string &value,
174 bool strict =
false);
185 bool StringToInt(
const std::string &value,
int *output,
bool strict =
false);
196 bool StringToInt(
const std::string &value,
198 bool strict =
false);
209 bool StringToInt(
const std::string &value, int8_t *output,
bool strict =
false);
220 bool HexStringToInt(
const std::string &value, uint8_t *output);
231 bool HexStringToInt(
const std::string &value, uint16_t *output);
242 bool HexStringToInt(
const std::string &value, uint32_t *output);
253 bool HexStringToInt(
const std::string &value, int8_t *output);
264 bool HexStringToInt(
const std::string &value, int16_t *output);
275 bool HexStringToInt(
const std::string &value, int32_t *output);
281 void ToLower(std::string *s);
287 void ToUpper(std::string *s);
297 void CapitalizeLabel(std::string *s);
308 void CustomCapitalizeLabel(std::string *s);
325 unsigned int indent = 0,
326 unsigned int byte_per_line = 8);
331 template <
typename int_type>
333 if ((input.find(
"0x") != 0) && (input.find(
"0X") != 0))
335 std::string modified_input = input.substr(2);
336 return HexStringToInt(modified_input, output);
345 std::string
StringJoin(
const std::string &delim,
const T &input) {
346 std::ostringstream str;
347 typename T::const_iterator iter = input.begin();
348 while (iter != input.end()) {
350 if (iter != input.end())
356 #endif // INCLUDE_OLA_STRINGUTILS_H_