aseprite/src/base/trim_string.cpp

29 lines
589 B
C++
Raw Normal View History

// ASEPRITE base library
2013-01-27 15:13:13 +00:00
// Copyright (C) 2001-2013 David Capello
//
// This source file is distributed under a BSD-like license, please
// 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 = "";
}