---
name: "log4tango::StringUtil"
section: "3"
platform: "linux"
package: "liblog4tango-doc"
version: "9.3.4+dfsg1-2+deb12u1"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/log4tango::StringUtil"
---

# log4tango::StringUtil(3)

## NAME

log4tango::StringUtil

## SYNOPSIS

`#include <StringUtil.hh>`

### Static Public Member Functions

static std::string **vform** (const char \*format, va\_list args)\
 Returns a string constructed from the a format specifier and a va\_list of arguments, analogously to [vprintf(3)](/vprintf/3.md).  static std::string **trim** (const std::string &s)\
 Returns a string identical to the given string but without leading or trailing HTABs or spaces.  static unsigned int **split** (std::vector\< std::string \> &v, const std::string &s, char delimiter, unsigned int maxSegments=INT\_MAX)\
 splits a string into a vector of string segments based on the given delimiter.  template\<typename T \> static unsigned int **split** (T &output, const std::string &s, char delimiter, unsigned int maxSegments=INT\_MAX)\
 splits a string into string segments based on the given delimiter and assigns the segments through an output\_iterator.

## Member Function Documentation

### unsigned int log4tango::StringUtil::split (std::vector\< std::string \> & v, const std::string & s, char delimiter, unsigned int maxSegments = `INT_MAX`)` [static]`

splits a string into a vector of string segments based on the given delimiter.

**Parameters**

*v* The vector in which the segments will be stored. The vector will be emptied before storing the segments \
 *s* The string to split into segments. \
 *delimiter* The delimiter character \
 *maxSegments* the maximum number of segments. Upon return v.size() \<= maxSegments. The string is scanned from left to right so v\[maxSegments - 1\] may contain a string containing the delimiter character.

**Returns**

The actual number of segments (limited by maxSegments).

### template\<typename T \> static unsigned int log4tango::StringUtil::split (T & output, const std::string & s, char delimiter, unsigned int maxSegments = `INT_MAX`)` [inline]`, ` [static]`

splits a string into string segments based on the given delimiter and assigns the segments through an output\_iterator.

**Parameters**

*output* The output\_iterator through which to assign the string segments. Typically this will be a back\_insertion\_iterator. \
 *s* The string to split into segments. \
 *delimiter* The delimiter character \
 *maxSegments* The maximum number of segments.

**Returns**

The actual number of segments (limited by maxSegments).

### std::string log4tango::StringUtil::trim (const std::string & s)` [static]`

Returns a string identical to the given string but without leading or trailing HTABs or spaces.

### std::string log4tango::StringUtil::vform (const char \* format, va\_list args)` [static]`

Returns a string constructed from the a format specifier and a va\_list of arguments, analogously to [vprintf(3)](/vprintf/3.md).

**Parameters**

*format* the format specifier. \
 *args* the va\_list of arguments.

## Author

Generated automatically by Doxygen for log4tango from the source code.
