Logo de Aster Système

SCLS Foundation - Text

Text manipulation is a very commun kind of algorithm you can have to use in your program. Fortunately, SCLS Foundation provide some cool tools, to easily handle text.
Contenu

Simple text processing

Simple manipulation

SCLS Foundation provide some mid-level text manipulation. The tools are made to be simply used, and can be un-built-in C++ algorithm, or built-in C++ algorithme simplified. Some very commun concept are avaible in SCLS, like text splitting, text content analyse...

Format a text

In some context, you need to properly format a text, to correctly use it. SCLS offers some tools to do some specific (but commun) formatting. For example, you can format a number to a text with format_number_to_text, or even format tabulations with format_string_tabulations().

Handle text encoding

Let's be honest, in C++, you can handle text encoding with the locale system. However, this is not the simplest way to do, and you can't properly use std::string with it. To simply handle encoding in C++, SCLS provides some usefull features. The main one aims the UTF-8 encoding. To use it properly, you can use the to_utf_8() function. You can even revert the encoding, with to_utf_8_code_point().

contenu

Documentation

Simple manipulation

std::string char_array_to_string(const char* c_a, unsigned int c_a_size)

Convert a char array "c_a" (with "c_a_size" characters) and returns it in a std::string.

bool contains_string(std::string str, std::string part)
bool contains_string(std::string str, std::string part, std::string out_of)
bool contains_string(std::string str, std::string part, std::string out_of_start, std::string out_of_end)

Returns if the std::string "part" is present in the std::string "str". If "out_of" is used, then the research won't be done between two occurences of "out_of". If "out_of_start" and "out_of_end" are used, then the research won't be done if an occurence of "out_of_start" is detected, until an occurence of "out_of_end" is detected.

unsigned int count_string(std::string str, std::string part)
unsigned int count_string(std::string str, std::string part, std::string out_of)
unsigned int count_string(std::string str, std::string part, std::string out_of_start, std::string out_of_end)

Counts and returns the number of occurences of "part" in "str. If "out_of" is used, then the research won't be done between two occurences of "out_of". If "out_of_start" and "out_of_end" are used, then the research won't be done if an occurence of "out_of_start" is detected, until an occurence of "out_of_end" is detected.

std::vector<std::string> cut_string(std::string str, std::string cut, bool erase_blank = false, bool erase_last_if_blank = true)

scls_var member_content

std::string join_string(std::vector strings, std::string separation = "")

Join each strings in "strings" in a single string, separated by the string "separation".

std::string lowercase_string(std::string str)

Put each char in the string "str" in lower case.

std::string replace(std::string str, std::string to_replace, std::string new_str)

Replace each occurences of "to_replace" in "str" by "new_str".

bool string_is_number(char to_test)
bool string_is_number(std::string to_test)

scls_var member_content

double string_to_double(std::string str)

Convert the string "str" to a double, and return it.

Text formatting

std::string format_number_to_text(double number_to_format)

Format the number "number_to_format" in a pretty std::string.

std::string format_string_break_line(std::string str, std::string new_break_line)

Returns the string "str", with each possibles breaks lines (like characters 10 and 13 ASCII) with a new break line "nea_break_line".

std::string format_string(std::string str)

Returns the std::string "str" formatted, with the break lines erased.

std::string format_string_tabulations(std::string str, std::string new_tabulation)

Returns the std::string "str" with the tabulations (like 9 character ASCII) replaced by "new_tabulation".

std::string format_string_as_plain_text(std::string str)

Returns the un-formatted std::string "str" as a plain text std::string.

std::string format_string_from_plain_text(std::string str)

Returns the plain text std::string "str" to an unformatted text.

std::string remove_comment_out_of(std::string str, std::string out_of)

Returns the std::string "str", with the comments part removed. However, if a "out_of" occurence is detected, the research of comments to remove is suspended until the next occurence of "out_of".

std::string remove_space(std::string str)

Returns the std::string "str", with each spaces removed.