-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathUtils.cc
More file actions
36 lines (25 loc) · 775 Bytes
/
Utils.cc
File metadata and controls
36 lines (25 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// -*- c++ -*-
// Copyright 2009 Isis Innovation Limited
/********************************************************************
A set of utility functions
Author: Robert Castle, 2009, bob@robots.ox.ac.uk
********************************************************************/
#include "Utils.h"
#include <sstream>
#include <gvars3/GStringUtil.h>
namespace PTAMM {
/**
* Edit a string so that the only whitespace is a single space between elements.
* @param str the string to edit. This gets replaced.
*/
void PruneWhiteSpace(std::string & str)
{
std::vector< std::string > tokens = GVars3::ChopAndUnquoteString(str);
std::ostringstream os;
os << tokens;
str = os.str();
if(str.at( str.size() - 1 ) == ' ' ) {
str.erase( str.end() - 1 );
}
}
}