26 #ifndef INCLUDE_OLA_STRINGUTILS_H_
27 #define INCLUDE_OLA_STRINGUTILS_H_
38 enum { HEX_BIT_WIDTH = 4 };
49 void StringSplit(
const std::string &input,
50 std::vector<std::string> &tokens,
51 const std::string &delimiters=
" ");
63 void ShortenString(std::string *input);
71 bool StringEndsWith(
const std::string &s,
const std::string &suffix);
142 void Escape(std::string *original);
150 std::string EscapeString(
const std::string &original);
158 void ReplaceAll(std::string *original,
159 const std::string &find,
160 const std::string &replace);
171 std::string EncodeString(
const std::string &original);
180 bool StringToBool(
const std::string &value,
bool *output);
190 bool StringToInt(
const std::string &value,
191 unsigned int *output,
192 bool strict =
false);
203 bool StringToInt(
const std::string &value,
205 bool strict =
false);
216 bool StringToInt(
const std::string &value,
218 bool strict =
false);
229 bool StringToInt(
const std::string &value,
int *output,
bool strict =
false);
240 bool StringToInt(
const std::string &value,
242 bool strict =
false);
253 bool StringToInt(
const std::string &value, int8_t *output,
bool strict =
false);
264 bool HexStringToInt(
const std::string &value, uint8_t *output);
275 bool HexStringToInt(
const std::string &value, uint16_t *output);
286 bool HexStringToInt(
const std::string &value, uint32_t *output);
297 bool HexStringToInt(
const std::string &value, int8_t *output);
308 bool HexStringToInt(
const std::string &value, int16_t *output);
319 bool HexStringToInt(
const std::string &value, int32_t *output);
325 void ToLower(std::string *s);
331 void ToUpper(std::string *s);
341 void CapitalizeLabel(std::string *s);
352 void CustomCapitalizeLabel(std::string *s);
369 unsigned int indent = 0,
370 unsigned int byte_per_line = 8);
375 template <
typename int_type>
377 if ((input.find(
"0x") != 0) && (input.find(
"0X") != 0))
379 std::string modified_input = input.substr(2);
380 return HexStringToInt(modified_input, output);
389 std::string
StringJoin(
const std::string &delim,
const T &input) {
390 std::ostringstream str;
391 typename T::const_iterator iter = input.begin();
392 while (iter != input.end()) {
394 if (iter != input.end())
400 #endif // INCLUDE_OLA_STRINGUTILS_H_