42 auto const first{ s.find_first_not_of(
' ') };
43 if (first == std::string::npos)
return {};
44 auto const last{ s.find_last_not_of(
' ') };
45 return s.substr(first, (last - first + 1));
51 if ( nMax > s.length() )
53 for (
unsigned int n=0; n<s.length(); n++) std::cout << s[n];
54 for (
unsigned int n=s.length(); n<nMax; n++) std::cout <<
" ";
58 for (
unsigned int n=0; n<nMax-3; n++) std::cout << s[n];
59 for (
unsigned int n=nMax-3; n<nMax; n++) std::cout <<
".";
65 std::string s = std::to_string(d);
68 int dot_pos = s.find_first_of(
'.');
69 if(dot_pos != std::string::npos)
71 int ipos = s.size()-1;
72 while((s[ipos]==
'0' || s[ipos]==
'.') && ipos>dot_pos-1)
76 s.erase(ipos + 1, std::string::npos);
83 std::transform(contain.begin(), contain.end(), contain.begin(), ::tolower);
84 std::transform(contained.begin(), contained.end(), contained.begin(), ::tolower);
85 return contain.find(contained) != std::string::npos;
91 std::vector<int> numbers;
96 if (isdigit(c)) ss << c;
100 numbers.push_back(num);
Header file of the ITHACAstring file.
Namespace to implement some useful assign operation of OF fields.
std::string str_trim(std::string const &s)
Trim a string cf.
bool containsSubstring(std::string contain, std::string contained)
Returns true if contained is a substring of contain, false otherwise.
std::string double2ConciseString(const double &d)
Returns the double d in string format without keeping all the extra 0.
void str_format_io(std::string const &s, unsigned int nMax)
Format a string.
std::vector< int > extractIntFromString(std::string input)
Returns an array storing all the integers in the input string.