Strings::Array SplitPath(const String& str, Char separator) { const String delimiter(1, separator); Strings::Array parts; boost::algorithm::split(parts, str, boost::algorithm::is_any_of(delimiter), boost::algorithm::token_compress_on); const Strings::Array::iterator newEnd = std::remove_if(parts.begin(), parts.end(), std::mem_fun_ref(&String::empty)); parts.erase(newEnd, parts.end()); return parts; }
Path::Ptr CreatePath(Char separator, Strings::Array data) { if (!data.empty()) { return MakePtr<ParsedPath>(separator, std::move(data)); } else { return MakePtr<EmptyPath>(separator); } }
Path::Ptr ParsePath(const String& str, Char separator) { const Strings::Array parsed = SplitPath(str, separator); return CreatePath(separator, parsed.begin(), parsed.end()); }