Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
io_stringutil Namespace Reference

Functions

bool startswith (const std::string &a, const std::string &b)
 Check if string starts with given text.
 
std::string trim (const std::string &s)
 Remove leading and trailing white spaces.
 

Function Documentation

◆ startswith()

bool io_stringutil::startswith ( const std::string & a,
const std::string & b )
inline

Check if string starts with given text.

Parameters
ainput string
btext
Returns
true if string start with text; else false

Definition at line 70 of file io_ascii.hh.

71{
72 if ( a.find( b ) == 0 ) return true;
73 return false;
74}

◆ trim()

std::string io_stringutil::trim ( const std::string & s)
inline

Remove leading and trailing white spaces.

Parameters
sinput string
Returns
trimmed string

Definition at line 82 of file io_ascii.hh.

83{
84 using namespace std;
85
86 if ( s == "" ) return s;
87
88 string::size_type i1;
89 string::size_type i2;
90
91 for (i1 = 0; i1 < s.length(); i1++)
92 {
93 if ( !isspace (s[i1]) ) break;
94 }
95 for (i2 = s.length() - 1 ; i2 > i1 ; i2--)
96 {
97 if ( !isspace (s[i2]) ) break;
98 }
99 return s.substr( i1, i2 - i1 + 1 );
100}