12#ifndef BELFEM_STRINGTOOLS_HPP
13#define BELFEM_STRINGTOOLS_HPP
36#pragma clang diagnostic push
37#pragma clang diagnostic ignored "-Wformat-security"
38#pragma clang diagnostic ignored "-Wformat"
39#pragma clang diagnostic ignored "-Wunused-variable"
40#pragma clang diagnostic ignored "-Wunused-parameter"
42#elif defined(__GNUC__) || defined(__GNUG__)
43#pragma GCC diagnostic push
44#pragma GCC diagnostic ignored "-Wformat"
45#pragma GCC diagnostic ignored "-Wunused-variable"
46#pragma GCC diagnostic ignored "-Wunused-parameter"
48#elif defined(BELFEM_INTEL)
52#pragma warning(disable: 1011)
54#pragma warning(disable: 177)
56#pragma warning(disable: 1595)
62 template <
typename T >
93 return "unsigned int";
102 return "long unsigned int";
129 return "complex<double>";
138 basename(
const std::string & aFilePath );
146 dirname(
const std::string & aFilePath );
154 filetype(
const std::string & aFilePath );
162 filename(
const std::string & aFilePath );
178 first_word(
const std::string & aString,
const char aDelimiter =
' ');
185 string_to_words(
const std::string & aString,
const char aDelimiter =
' ' );
191 const std::string & aString,
192 const std::string & aSearch,
193 const std::string & aReplace );
225 to_real(
const std::string & aString );
249 template <
typename T >
261 " ",
"" ),
";",
" ; " ),
266 for(
string tWord : tWords )
268 if( tWord.find(
":") < tWord.size() )
271 T tA = ( T ) std::stoll( tNumbers(0) );
272 T tB = ( T ) std::stoll( tNumbers(1) );
279 for( T k=0; k<tN; ++k )
290 for( T k=0; k<tN; ++k )
297 else if( tWord ==
";" )
304 aValues.
push( ( T ) std::stoll( tWord ) );
311 template <
typename T >
313 to_pair(
const std::string & aString,
Cell< std::pair< std::string, T >> & aResult )
319 std::regex re(R
"(([A-Za-z]+)(\d+))");
322 for (std::sregex_iterator it(aString.begin(), aString.end(), re);
323 it != std::sregex_iterator(); ++it)
325 const std::smatch& match = *it;
327 std::string label = match[1].str();
328 T
value = std::stoi(match[2].str());
330 aResult.push( { std::move( label ),
value } );
335#pragma clang diagnostic pop
337#pragma GCC diagnostic pop
Cell is a wrapper around the standard vector.
Definition cl_Cell.hpp:42
void push(const T &aValue)
push an entry to the end of the cell (copy version)
Definition cl_Cell.hpp:262
USER GUIDES:
Definition cl_Capacitor.cpp:16
std::string datatype_string< std::string >()
Definition stringtools.hpp:118
std::string basename(const std::string &aFilePath)
returns the basename of a file
Definition stringtools.cpp:21
std::string datatype_string()
Definition stringtools.hpp:64
std::string dirname(const std::string &aFilePath)
returns the directory name of a file
Definition stringtools.cpp:33
std::string clean_string(const std::string &aString)
tidy up the string
Definition stringtools.cpp:86
size_t utf8_character_count(const string &aString)
Definition stringtools.cpp:1191
std::string filename(const std::string &aFilePath)
returns the name of a file without the path
Definition stringtools.cpp:70
value unit_to_si(const string &aString)
Definition stringtools.cpp:335
std::pair< real, unit > value
Definition typedefs.hpp:74
unsigned int uint
Definition typedefs.hpp:30
std::string search_and_replace(const std::string &aString, const std::string &aSearch, const std::string &aReplace)
Definition stringtools.cpp:236
real to_real(const std::string &aString)
convert string to real, return NAN if it is not real
Definition stringtools.cpp:316
std::string filetype(const std::string &aFilePath)
returns the filetype of a file
Definition stringtools.cpp:55
bool is_integer(const string &aString)
Definition stringtools.cpp:1173
string first_word(const std::string &aString, char aDelimiter)
return the first word of the string
Definition stringtools.cpp:190
std::string string_to_lower(const std::string &aString)
convert the string to lower case
Definition stringtools.cpp:267
bool string_to_bool(const std::string &aString)
return true if string is either 1, on, true or yes
Definition stringtools.cpp:301
void to_pair(const std::string &aString, Cell< std::pair< std::string, T > > &aResult)
Definition stringtools.hpp:313
std::string string_to_upper(const std::string &aString)
convert the string to upper case
Definition stringtools.cpp:284
void string_to_cell(const string &aString, Cell< T > &aValues)
Definition stringtools.hpp:251
Cell< string > string_to_words(const std::string &aString, char aDelimiter)
create a cell of words from a string
Definition stringtools.cpp:201
double real
Definition typedefs.hpp:36
string format_with_leading_zeros(const uint aNumber)
Definition stringtools.cpp:1127