106#include <tclap/CmdLine.h>
112using namespace Aleph;
120 cout <<
"\n" << string(60,
'=') <<
"\n";
122 cout << string(60,
'=') <<
"\n\n";
132 cout << label <<
": \"" << s <<
"\"" <<
endl;
143 string s1 =
" hello world ";
144 string s2 =
"\t\n whitespace everywhere \r\n";
175 string text =
"Hola Mundo desde COLOMBIA";
205 string csv =
"Bogota,Medellin,Cali,Barranquilla,Cartagena";
217 string path =
"/home/user/documents/file.txt";
219 cout <<
"Path: \"" << path <<
"\"" <<
endl;
221 for (
const auto& p :
parts)
226 string text =
"Hello World";
229 cout <<
"Split at position 5:" <<
endl;
230 cout <<
" Left: \"" << left <<
"\"" <<
endl;
231 cout <<
" Right: \"" << right <<
"\"" <<
endl;
244 for (
auto it = words.
get_it(); it.has_curr(); it.next())
245 cout <<
"\"" << it.get_curr() <<
"\" ";
256 string result =
concat(
"Nombre: ",
"Juan",
", Edad: ", 25,
", Ciudad: ",
"Bogota");
272 cout <<
" is_double(\"" << s <<
"\"): " << (
is_double(s) ?
"yes" :
"no") <<
endl;
278 cout <<
" is_long(\"" << s <<
"\"): " << (
is_long(s) ?
"yes" :
"no") <<
endl;
284 cout <<
" is_size_t(\"" << s <<
"\"): " << (
is_size_t(s) ?
"yes" :
"no") <<
endl;
288 string text =
"Hello from Colombia";
295 cout <<
" is_prefix(\"Hello world\", \"Hello\"): "
296 << (
is_prefix(
"Hello world",
"Hello") ?
"yes" :
"no") <<
endl;
297 cout <<
" is_prefix(\"Hello world\", \"World\"): "
298 << (
is_prefix(
"Hello world",
"World") ?
"yes" :
"no") <<
endl;
309 string dirty =
" Hello123 World!@# ";
328 string to_fill =
"***secret***";
342 string lorem =
"Este es un texto de ejemplo que sera formateado de diferentes maneras para demostrar las capacidades de formateo de texto de Aleph-w.";
352 for (
const auto& line :
lines)
353 cout <<
" |" << line <<
"|" <<
endl;
360 for (
const auto& line :
lines)
361 cout <<
" |" << line <<
"|" <<
endl;
374 vector<int>
nums = {1, 2, 3, 4, 5};
377 vector<double>
prices = {19.99, 29.99, 39.99};
382 double pi = 3.14159265358979;
401 Nombre, Ciudad, Edad, Salario
402 Juan Perez, Bogota, 35, 5000000
403 Maria Garcia, Medellin, 28, 4500000
404 Carlos Lopez, Cali, 42, 6000000
420 if (line.empty())
continue;
422 auto fields =
split(line,
',');
427 for (
const auto& f : fields)
441 string value =
trim(fields[i]);
449 string salary =
"5000000";
450 cout <<
"Salary \"" <<
salary <<
"\" is valid number? "
454 cout <<
"Salary \"" <<
invalid <<
"\" is valid number? "
467 "String utilities example for Aleph-w.\n"
468 "Demonstrates trim, split, join, case conversion, and more.",
474 "Run only specific section: trim, case, split, join, validate, "
475 "filter, format, convert, practical, or 'all'",
476 false,
"all",
"section",
cmd
484 cout <<
"============================================================\n";
485 cout <<
" ALEPH-W STRING UTILITIES EXAMPLE\n";
486 cout <<
"============================================================\n";
515 cout <<
"\n" << string(60,
'=') <<
"\n";
516 cout <<
"String utilities demo completed!\n";
517 cout << string(60,
'=') <<
"\n\n";
521 catch (TCLAP::ArgException& e)
523 cerr <<
"Error: " << e.error() <<
" for argument " << e.argId() <<
endl;
528 cerr <<
"Error: " << e.what() <<
endl;
String manipulation utilities.
Dynamic singly linked list with functional programming support.
size_t size() const noexcept
Count the number of elements of the list.
auto get_it() const
Return a properly initialized iterator positioned at the first item on the container.
Singly linked list implementations with head-tail access.
Main namespace for Aleph-w library functions.
std::string tolower(const char *str)
Convert a C std::string to lower-case.
bool is_prefix(const std::string &str, const std::string &prefix)
Check whether prefix is a prefix of str.
std::string remove_symbols(const std::string &str, const std::string &symbols)
Remove any character appearing in symbols.
std::pair< std::string, std::string > split_pos(const std::string &str, const size_t pos)
Split a std::string at a fixed position.
void ltrim(std::string &s)
Remove leading whitespace from a std::string in-place.
std::string 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.
bool contains(const std::string_view &str, const std::string_view &substr)
Check if substr appears inside str.
std::string to_Pascalcase(const std::string &str)
Convert an identifier-like std::string to PascalCase.
bool is_long(const std::string &str)
Check whether a std::string fully parses as a long.
std::string to_name(const std::string &str)
Uppercase the first character of str and return the resulting copy.
bool is_size_t(const std::string &str)
Check whether a std::string fully parses as a non-negative size_t.
std::string trim(const std::string &s)
Return a trimmed copy of a std::string (leading + trailing whitespace removed).
void build_pars_list(std::string &unused)
Base case for build_pars_list(std::string&, ...).
std::string remove_spaces(const std::string &str)
Remove all whitespace characters from a std::string.
std::string to_string(const time_t t, const std::string &format)
Format a time_t value into a string using format.
std::string justify_text(const std::string &text, const size_t width, const size_t left_margin=0)
Justify a text to a target width.
bool is_double(const std::string &str)
Check whether a std::string fully parses as a finite double.
std::string concat(const Args &... args)
Concatenate multiple streamable arguments into a single std::string.
std::string toupper(const char *str)
Convert a C std::string to upper-case.
std::ostream & join(const C &c, const std::string &sep, std::ostream &out)
Join elements of an Aleph-style container into a stream.
void rtrim(std::string &s)
Remove trailing whitespace from a std::string in-place.
std::vector< std::string > & split(const std::string &s, const char delim, std::vector< std::string > &elems)
Split a std::string by a single delimiter character.
void fill_string(std::string &str, char sym)
Fill all the content of std::string with a defined char.
DynList< T > maps(const C &c, Op op)
Classic map operation.
std::string only_alpha(const std::string &str)
Extract alphanumeric ASCII characters and normalize letters to lower-case.
void print_subsection(const string &title)
void print_section(const string &title)
void demo_case_conversion()
void show_string(const string &label, const string &s)