#include <my++/stype.h>
#include <string>


inline std::string split_ws (const std::string &s, unsigned index, unsigned limit) {
	std::string stripped = my::rtrim(my::ltrim(s));
	std::string::iterator i = stripped.begin();
	std::string::iterator start = stripped.begin(), stop = stripped.end();

	while (i != stripped.end()) {
		// find the first non-ws character
		while (i != stripped.end()) {
			if (!isspace(*i)) {
				start = i++;
				break;
			}
			++i;
		}

		// then go until we hit whitespace
		while (i != stripped.end()) {
			if (isspace(*i)) {
				stop = i++;
				break;
			}
			++i;
		}
	}

	return std::string(start, stop);
}
