예제 #1
0
파일: text.cpp 프로젝트: GamingAtheist/ogui
int_vec calculate_text_breaks(const xstring& text)
{
  int_vec breaks;
  auto it = text.begin();
  bool last = false;
  for (int i = 0; it != text.end(); ++it, ++i)
  {
    if (*it == ' ')
    {
      if (last) breaks.push_back(i);
      last = false;
    }
    else last = true;
  }
  return breaks;
}
예제 #2
0
std::deque<xstring> split(const xstring& s, const xstring& delimitersRE)
{
	std::deque<xstring> rv;

	const xstring fixed = std::regex_replace(s, std::wregex(L"\r"), L"");

	std::wregex rePattern(delimitersRE);
	std::wsregex_token_iterator iter(fixed.begin(), fixed.end(), rePattern, -1);
	std::wsregex_token_iterator end;
	for (; iter != end; ++iter)
	{
		const xstring& item = *iter;
		if (!item.empty())
			rv.push_back(item);
	}
	return rv;
}