10 #ifndef SRC_INCLUDE_STRINGFUNCTIONS_H_ 11 #define SRC_INCLUDE_STRINGFUNCTIONS_H_ 24 std::string
trim(
const std::string &s);
48 std::vector<std::string>
split(
const std::string &s,
char delim);
59 std::string
fill_left(
const std::string &s,
size_t width,
char fill =
' ');
69 std::string
fill_right(
const std::string &s,
size_t width,
char fill =
' ');
79 std::string
fill_both(
const std::string &s,
size_t width,
char fill =
' ');
89 template <
typename octet_type>
90 inline uint8_t
mask8(octet_type oc) {
91 return static_cast<uint8_t
>(0xff & oc);
101 template <
typename octet_iterator>
102 inline typename std::iterator_traits<octet_iterator>::difference_type
104 uint8_t lead =
mask8(*lead_it);
107 else if ((lead >> 5) == 0x6)
109 else if ((lead >> 4) == 0xe)
111 else if ((lead >> 3) == 0x1e)
121 #endif // SRC_INCLUDE_STRINGFUNCTIONS_H_ uint8_t mask8(octet_type oc)
Extract the first byte from a given value.
std::string trim(const std::string &s)
Strip leading and trailing whitespaces.
std::string fill_left(const std::string &s, size_t width, char fill= ' ')
Fill string with characters to the left until the given width is reached.
void isoclean(std::string &s)
Remove ⁺, ⁻, ⁰ from string.
std::vector< std::string > split(const std::string &s, char delim)
Split string by delimiter.
void remove_substr(std::string &s, const std::string &p)
Remove all instances of a substring p in a string s.
std::string fill_right(const std::string &s, size_t width, char fill= ' ')
Fill string with characters to the right until the given width is reached.
std::string fill_both(const std::string &s, size_t width, char fill= ' ')
Fill string with characters at both sides until the given width is reached.
std::iterator_traits< octet_iterator >::difference_type sequence_length(octet_iterator lead_it)
Given an iterator to the beginning of a UTF-8 sequence, return the length of the next UTF-8 code poin...