|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
String manipulation utilities. More...
#include <algorithm>#include <cctype>#include <cerrno>#include <cstdlib>#include <iomanip>#include <limits>#include <stdexcept>#include <string_view>#include <type_traits>#include <cstring>#include <memory>#include <string>#include <sstream>#include <iterator>#include <vector>#include <htlist.H>#include <tpl_array.H>#include <ah-zip.H>Go to the source code of this file.
Namespaces | |
| namespace | Aleph |
| Main namespace for Aleph-w library functions. | |
Functions | |
| template<typename T > | |
| std::string | Aleph::to_string (const std::vector< T > &v) |
Convert a std::vector<T> to a comma-separated std::string. | |
| template<typename T > | |
| std::string | Aleph::to_string (const Array< T > &v) |
Convert an Aleph::Array<T> to a comma-separated std::string. | |
| void | Aleph::ltrim (std::string &s) |
| Remove leading whitespace from a std::string in-place. | |
| void | Aleph::rtrim (std::string &s) |
| Remove trailing whitespace from a std::string in-place. | |
| template<class... Args> | |
| std::string | Aleph::concat (const Args &... args) |
| Concatenate multiple streamable arguments into a single std::string. | |
| std::string | Aleph::trim (const std::string &s) |
| Return a trimmed copy of a std::string (leading + trailing whitespace removed). | |
| std::string & | Aleph::trim_in_place (std::string &s) |
| Trim a std::string in-place (leading + trailing whitespace removed). | |
| bool | Aleph::contains (const std::string_view &str, const std::string_view &substr) |
Check if substr appears inside str. | |
| std::string | Aleph::to_string (const double d, const size_t precision) |
Format a double using fixed notation with the given precision. | |
| std::string | Aleph::to_str (const double d) |
Convert double to a std::string with maximum round-trip precision. | |
| std::string | Aleph::tolower (const char *str) |
| Convert a C std::string to lower-case. | |
| std::string | Aleph::toupper (const char *str) |
| Convert a C std::string to upper-case. | |
| std::string | Aleph::tolower (const std::string &str) |
Convert a std::string to lower-case. | |
| std::string | Aleph::toupper (const std::string &str) |
Convert a std::string to upper-case. | |
| std::string & | Aleph::mutable_tolower (std::string &str) |
| Convert a std::string to lower-case in-place. | |
| std::string & | Aleph::mutable_toupper (std::string &str) |
| Convert a std::string to upper-case in-place. | |
| std::string | Aleph::only_alpha (const std::string &str) |
| Extract alphanumeric ASCII characters and normalize letters to lower-case. | |
| std::string | Aleph::remove_spaces (const std::string &str) |
| Remove all whitespace characters from a std::string. | |
| std::string | Aleph::remove_symbols (const std::string &str, const std::string &symbols) |
Remove any character appearing in symbols. | |
| template<class C > | |
| std::ostream & | Aleph::join (const C &c, const std::string &sep, std::ostream &out) |
| Join elements of an Aleph-style container into a stream. | |
| template<class C > | |
| std::string | Aleph::join (const C &c, const std::string &sep=" ") |
| Join elements of an Aleph-style container into a std::string. | |
| bool | Aleph::is_double (const std::string &str) |
Check whether a std::string fully parses as a finite double. | |
| bool | Aleph::is_float (const std::string &str) |
Check whether a std::string fully parses as a finite float. | |
| bool | Aleph::is_long (const std::string &str) |
Check whether a std::string fully parses as a long. | |
| bool | Aleph::is_size_t (const std::string &str) |
Check whether a std::string fully parses as a non-negative size_t. | |
| long | Aleph::safe_atol (const std::string &s) |
Convert a std::string to long and throw on parse errors. | |
| double | Aleph::safe_atof (const std::string &s) |
Convert a std::string to double and throw on parse errors. | |
| bool | Aleph::is_prefix (const std::string &str, const std::string &prefix) |
Check whether prefix is a prefix of str. | |
| std::string | Aleph::remove_prefix (std::string &str, const std::string &prefix) |
Remove prefix from str if present. | |
| std::string | Aleph::to_lower (const std::string &str) |
| Convert a std::string to lower-case (byte-wise). | |
| std::string | Aleph::to_upper (const std::string &str) |
| Convert a std::string to upper-case (byte-wise). | |
| std::string | Aleph::to_name (const std::string &str) |
Uppercase the first character of str and return the resulting copy. | |
| DynList< std::string > | Aleph::split_camel_case (const char *const str) |
| Split a camelCase / PascalCase std::string into tokens. | |
| DynList< std::string > | Aleph::split_camel_case (const std::string &str) |
| Split a camelCase / PascalCase std::string into tokens. | |
| void | Aleph::fill_string (std::string &str, char sym) |
| Fill all the content of std::string with a defined char. | |
| std::vector< std::string > & | Aleph::split (const std::string &s, const char delim, std::vector< std::string > &elems) |
| Split a std::string by a single delimiter character. | |
| std::vector< std::string > | Aleph::split (const std::string &s, const char delim) |
| Split a std::string by a single delimiter character. | |
| template<template< typename > class Container = DynList> | |
| Container< std::string > | Aleph::split_string (const std::string &s, const std::string &delim) |
| Split a std::string by a set of delimiter characters. | |
| DynList< std::string > | Aleph::split_to_list (const std::string &s, const std::string &delim) |
Split a std::string into an Aleph::DynList<std::string>. | |
| std::string | Aleph::to_Pascalcase (const std::string &str) |
| Convert an identifier-like std::string to PascalCase. | |
| Array< std::string > | Aleph::split_to_array (const std::string &s, const std::string &delim) |
Split a std::string into an Aleph::Array<std::string>. | |
| std::pair< std::string, std::string > | Aleph::split_pos (const std::string &str, const size_t pos) |
| Split a std::string at a fixed position. | |
| DynList< std::string > | Aleph::split_n (const std::string &str, const size_t n) |
Split a std::string into n parts. | |
| template<typename T > | |
| DynList< DynList< T > > | Aleph::complete_rows (DynList< DynList< T > > &m) |
| Pad all rows of a matrix to the maximum row length. | |
| DynList< DynList< std::string > > | Aleph::format_string (const DynList< size_t > &lens, const DynList< DynList< std::string > > &mat) |
| std::ostream & | Aleph::format_string (std::ostream &out, const DynList< size_t > &lens, const DynList< DynList< std::string > > &mat) |
| Write a formatted matrix to a stream. | |
| DynList< DynList< std::string > > | Aleph::format_string (const DynList< DynList< std::string > > &mat) |
| Format a matrix by computing column widths. | |
| DynList< DynList< std::string > > | Aleph::format_string_csv (const DynList< DynList< std::string > > &mat) |
| Produce a CSV-like matrix (commas added to all but last element in each row). | |
| std::string | Aleph::to_string (const DynList< DynList< std::string > > &mat) |
| Convert a matrix of strings to a single std::string. | |
| DynList< std::string > | Aleph::split_text_into_words (const std::string &text) |
| Split a text into whitespace-separated words. | |
| DynList< std::string > | Aleph::split_text_into_lines (const std::string &text) |
Split a text into lines by "\n". | |
| std::string | Aleph::to_string (const DynList< std::string > &lines) |
| Join lines into a single std::string separated by newlines. | |
| std::string | Aleph::justify_line (std::string line, const size_t page_width) |
| Justify a single line by inserting extra spaces. | |
| std::string | Aleph::justify_text (const std::string &text, const size_t width, const size_t left_margin=0) |
| Justify a text to a target width. | |
| std::string | Aleph::justify_line_except_first (const std::string &text, const size_t width, const size_t left_margin=0) |
| Justify all lines except the first one. | |
| std::string | Aleph::align_text_to_left (const std::string &text, const size_t page_width, const size_t left_margin=0) |
Align text to the left by wrapping lines at page_width. | |
| std::string | Aleph::align_text_to_left_except_first (const std::string &text, const size_t width, const size_t left_margin=0) |
| Align all lines except the first one. | |
| std::string | Aleph::shift_lines_to_left (const std::string &str, const size_t n) |
Indent every line in a multi-line std::string by n spaces. | |
| void | Aleph::build_pars_list (std::string &unused) |
Base case for build_pars_list(std::string&, ...). | |
| template<typename T > requires requires(std::ostream & out, const T & v) { out << v; } | |
| void | Aleph::build_pars_list (std::string &str, const T &item) |
| template<class T , class... Args> | |
| void | Aleph::build_pars_list (std::string &str, const T &item, Args... args) |
| Append multiple parameters to a comma-separated parameter list. | |
| template<class First , class... Rest> requires (not requires(const std::remove_reference_t<First> & c) { c.is_empty(); c.get_last(); c.get_it(); }) | |
| std::string | Aleph::build_pars_list (const First &first, const Rest &... rest) |
| Build a sringficated parameters' lists. | |
| template<class C > requires requires(const C & c) { c.is_empty(); c.get_last(); c.get_it(); } | |
| std::string | Aleph::build_pars_list (const C &c, const std::string &sep=",") |
String manipulation utilities.
This file provides a comprehensive set of string utilities including:
Most functions operate on byte strings and use C locale ctype functions.
Definition in file ah-string-utils.H.