#include <cstdarg>
#include <regex>
#include <sstream>
#include <string>
#include <vector>
Go to the source code of this file.
|
std::string | format (const char *fmt,...) |
|
std::string | strip (const std::string &in) |
|
template<typename Out > |
void | split (const std::string &s, char delim, Out result) |
|
std::vector< std::string > | split (const std::string &s, char delim) |
|
template<typename Out > |
void | split (const std::string &s, Out result) |
|
std::vector< std::string > | split (const std::string &s) |
|
std::vector< std::string > | split_by_regex (const std::string &s, const std::regex ®ex) |
|
Missing string manipulations.
This header file contains essential methods to manipulate strings.
◆ format()
std::string format |
( |
const char * |
fmt, |
|
|
|
... |
|
) |
| |
|
inline |
missing string printf this is safe and convenient but not exactly efficient
- Parameters
-
fmt | string to be formatted |
... | variable amount of parameters |
- Returns
- formatted string
- Examples
- TestFormat.cpp.
◆ split() [1/4]
std::vector< std::string > split |
( |
const std::string & |
s | ) |
|
Helper method to simplify call to split
- Parameters
-
- Returns
- split vector of strings
◆ split() [2/4]
std::vector< std::string > split |
( |
const std::string & |
s, |
|
|
char |
delim |
|
) |
| |
Helper method to simplify call to split
- Parameters
-
s | string to split |
delim | character to split by |
- Returns
- vector of strings split' by delim
◆ split() [3/4]
template<typename Out >
void split |
( |
const std::string & |
s, |
|
|
char |
delim, |
|
|
Out |
result |
|
) |
| |
from https://stackoverflow.com/a/236803
splits s into result by delim
- Template Parameters
-
- Parameters
-
- Examples
- TestFormat.cpp.
◆ split() [4/4]
template<typename Out >
void split |
( |
const std::string & |
s, |
|
|
Out |
result |
|
) |
| |
Split after each character
- Template Parameters
-
Out | container type to write to |
- Parameters
-
s | string to split |
result | container to write results in |
◆ split_by_regex()
std::vector< std::string > split_by_regex |
( |
const std::string & |
s, |
|
|
const std::regex & |
regex |
|
) |
| |
◆ strip()
std::string strip |
( |
const std::string & |
in | ) |
|
Strips whitespaces of a string
- Parameters
-
in | string which may contain whitespaces |
- Returns
- input string without whitespaces
- Examples
- TestFormat.cpp.