12#ifndef MCRL2_UTILITIES_TEXT_UTILITY_H
13#define MCRL2_UTILITIES_TEXT_UTILITY_H
33template <
class CharContainer>
36 for(
const typename CharContainer::value_type& c: input)
39 if (!(std::isprint(c) || c==
'\t' || c==
'\n' || c==
'\r' ))
69std::vector<std::string>
split(
const std::string& line,
const std::string& separators);
75std::string
read_text(
const std::string& filename,
bool warn=
false);
83 in.unsetf(std::ios::skipws);
86 std::istream_iterator<char>(in),
87 std::istream_iterator<char>(),
108std::string
regex_replace(
const std::string& src,
const std::string& dest,
const std::string& text);
114std::vector<std::string>
regex_split(
const std::string& text,
const std::string& sep);
119std::string
trim_copy(
const std::string& text);
123void trim(std::string& text);
128template <
typename Container>
129std::string
string_join(
const Container& c,
const std::string& separator)
131 std::ostringstream out;
132 for (
typename Container::const_iterator i = c.begin(); i != c.end(); ++i)
147std::string
word_wrap_text(
const std::string& text,
unsigned int max_line_length = 78);
158inline void number2string(std::size_t number, std::string& buffer, std::size_t start_position)
161 std::size_t number_of_digits=0;
168 for(std::size_t copy=number ; copy!=0; ++number_of_digits, copy=copy/10)
173 std::size_t position=start_position+number_of_digits;
174 buffer.resize(position);
176 while (position>start_position)
179 buffer[position] =
'0' + number % 10;
191 buffer.reserve(std::numeric_limits<std::size_t>::digits10 + 1);
193 return std::string(buffer);
std::string string_join(const Container &c, const std::string &separator)
Joins a sequence of strings. This is a replacement for boost::algorithm::join, since it gives stack o...
void number2string(std::size_t number, std::string &buffer, std::size_t start_position)
Convert a number to a string in the buffer starting at position start_position.
std::vector< std::string > split_paragraphs(const std::string &text)
Split a string into paragraphs.
void trim(std::string &text)
Remove all trailing and leading spaces from the input.
std::string regex_replace(const std::string &src, const std::string &dest, const std::string &text)
Regular expression replacement in a string.
std::string read_text(const std::string &filename, bool warn=false)
Read text from a file.
std::string word_wrap_text(const std::string &text, unsigned int max_line_length=78)
Apply word wrapping to a text.
bool is_numeric_string(const std::string &s)
Test if a string is a number.
std::string to_string(const T &x)
Transform parameter into string.
std::vector< std::string > regex_split(const std::string &text, const std::string &sep)
Split a string using a regular expression separator.
std::string remove_comments(const std::string &text)
Remove comments from a text (everything from '' until end of line).
std::string trim_copy(const std::string &text)
Remove all trailing and leading spaces from the input.
std::string remove_whitespace(const std::string &text)
Removes whitespace from a string.
bool contains_only_ascii_symbols(const CharContainer &input)
Checks whether the input only contains proper ascii characters, including common control characters.
std::vector< std::string > split(const std::string &line, const std::string &separators)
Split the text.
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...