mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-11 00:56:33 +01:00
add remove_extra_whitespace() to libpbd
This commit is contained in:
parent
bd9fe31778
commit
5563117a1b
2 changed files with 10 additions and 1 deletions
|
|
@ -29,7 +29,7 @@ namespace PBD {
|
||||||
// returns the empty string if the entire string is whitespace
|
// returns the empty string if the entire string is whitespace
|
||||||
// so check length after calling.
|
// so check length after calling.
|
||||||
LIBPBD_API extern void strip_whitespace_edges (std::string& str);
|
LIBPBD_API extern void strip_whitespace_edges (std::string& str);
|
||||||
|
LIBPBD_API extern void remove_extra_whitespace (std::string const & in, std::string out);
|
||||||
} // namespace PBD
|
} // namespace PBD
|
||||||
|
|
||||||
#endif // __pbd_whitespace_h__
|
#endif // __pbd_whitespace_h__
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*/
|
*/
|
||||||
|
#include <algorithm>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "pbd/whitespace.h"
|
#include "pbd/whitespace.h"
|
||||||
|
|
||||||
|
|
@ -77,4 +79,11 @@ strip_whitespace_edges (string& str)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
remove_extra_whitespace (string const & input, string & output)
|
||||||
|
{
|
||||||
|
std::unique_copy (input.begin(), input.end(), std::back_insert_iterator<string>(output), [](char a,char b){ return isspace(a) && isspace(b);});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace PBD
|
} // namespace PBD
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue