26 #ifndef INCLUDE_OLA_STRINGUTILS_H_
27 #define INCLUDE_OLA_STRINGUTILS_H_
51 std::vector<std::string> *tokens,
52 const std::string &delimiters =
" ");
65 const std::string &input,
66 std::vector<std::string> &tokens,
67 const std::string &delimiters =
" ") {
97 bool StringEndsWith(
const std::string &s,
const std::string &suffix);
105 bool StripPrefix(std::string *s,
const std::string &prefix);
113 bool StripSuffix(std::string *s,
const std::string &suffix);
155 std::ostringstream str;
156 str << ola::strings::ToHex(i);
168 std::ostringstream str;
169 str << ola::strings::ToHex(i);
181 std::ostringstream str;
182 str << ola::strings::ToHex(i);
201 void Escape(std::string *original);
218 const std::string &find,
219 const std::string &replace);
243 bool StringToBool(
const std::string &value,
bool *output);
269 unsigned int *output,
270 bool strict =
false);
283 bool strict =
false);
296 bool strict =
false);
307 bool StringToInt(
const std::string &value,
int *output,
bool strict =
false);
320 bool strict =
false);
331 bool StringToInt(
const std::string &value, int8_t *output,
bool strict =
false);
342 template <
typename int_type>
344 int_type alternative,
345 bool strict =
false) {
347 return (
StringToInt(value, &output, strict)) ? output : alternative;
465 unsigned int indent = 0,
466 unsigned int byte_per_line = 8) {
473 template <
typename int_type>
475 if ((input.find(
"0x") != 0) && (input.find(
"0X") != 0))
477 std::string modified_input = input.substr(2);
487 std::string
StringJoin(
const std::string &delim,
const T &input) {
488 std::ostringstream str;
489 typename T::const_iterator iter = input.begin();
490 while (iter != input.end()) {
492 if (iter != input.end())
498 #endif // INCLUDE_OLA_STRINGUTILS_H_