2012-06-16 20:50:52 +00:00
|
|
|
// ASEPRITE base library
|
2013-01-27 15:13:13 +00:00
|
|
|
// Copyright (C) 2001-2013 David Capello
|
2012-06-16 20:50:52 +00:00
|
|
|
//
|
2012-09-24 02:24:07 +00:00
|
|
|
// This source file is distributed under a BSD-like license, please
|
2012-06-16 20:50:52 +00:00
|
|
|
// read LICENSE.txt for more information.
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "base/trim_string.h"
|
|
|
|
#include <cctype>
|
|
|
|
|
|
|
|
void base::trim_string(const base::string& input, base::string& output)
|
|
|
|
{
|
|
|
|
size_t i, j;
|
|
|
|
|
|
|
|
for (i=0; i<input.size(); ++i)
|
|
|
|
if (!std::isspace(input.at(i)))
|
|
|
|
break;
|
|
|
|
|
|
|
|
for (j=input.size()-1; j>i; --j)
|
|
|
|
if (!std::isspace(input.at(j)))
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (i < j)
|
|
|
|
output = input.substr(i, j - i + 1);
|
|
|
|
else
|
|
|
|
output = "";
|
|
|
|
}
|