added removeTrailingWhitespace
This commit is contained in:
parent
ab2d5ca0c7
commit
233a4d85f4
2 changed files with 33 additions and 19 deletions
|
@ -19,7 +19,7 @@
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
// $Id: StringUtil.cc,v 1.7 2003/09/29 14:01:48 fluxgen Exp $
|
// $Id: StringUtil.cc,v 1.8 2003/10/25 22:06:53 fluxgen Exp $
|
||||||
|
|
||||||
#include "StringUtil.hh"
|
#include "StringUtil.hh"
|
||||||
|
|
||||||
|
@ -185,6 +185,19 @@ string::size_type removeFirstWhitespace(std::string &str) {
|
||||||
return first_pos;
|
return first_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string::size_type removeTrailingWhitespace(std::string &str) {
|
||||||
|
// strip trailing whitespace
|
||||||
|
string::size_type first_pos = str.find_first_not_of(" \t");
|
||||||
|
if (first_pos != string::npos) {
|
||||||
|
string::size_type last_pos = str.find_first_of(" \t", first_pos);
|
||||||
|
while (last_pos != string::npos) {
|
||||||
|
str.erase(last_pos);
|
||||||
|
last_pos = str.find_first_of(" \t", last_pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}; // end namespace StringUtil
|
}; // end namespace StringUtil
|
||||||
|
|
||||||
}; // end namespace FbTk
|
}; // end namespace FbTk
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
//$Id: StringUtil.hh,v 1.6 2003/09/29 14:01:48 fluxgen Exp $
|
//$Id: StringUtil.hh,v 1.7 2003/10/25 22:06:53 fluxgen Exp $
|
||||||
|
|
||||||
#ifndef FBTK_STRINGUTIL_HH
|
#ifndef FBTK_STRINGUTIL_HH
|
||||||
#define FBTK_STRINGUTIL_HH
|
#define FBTK_STRINGUTIL_HH
|
||||||
|
@ -57,6 +57,7 @@ std::string basename(const std::string &basename);
|
||||||
|
|
||||||
/// removes the first whitespace characters of the string
|
/// removes the first whitespace characters of the string
|
||||||
std::string::size_type removeFirstWhitespace(std::string &str);
|
std::string::size_type removeFirstWhitespace(std::string &str);
|
||||||
|
std::string::size_type removeTrailingWhitespace(std::string &str);
|
||||||
|
|
||||||
/// Breaks a string into tokens
|
/// Breaks a string into tokens
|
||||||
template <typename Container>
|
template <typename Container>
|
||||||
|
|
Loading…
Reference in a new issue