Files
MuditaOS/module-utils/split_sv.hpp
Lucjan Bryndza 8be15b96e4 [EGD-4498] Virtual Filesystem Core Framework (#1074)
* [EGD-4498] Registering and unregistering VFS

* [EGD-4498] Mount structures added

* [EGD-4498] Mount filesystem completed

* [EGD-4498] Mount / unmount / and find mount impl

* [EGD-4498] Per thread directory TLS

* [EGD-4489] Absolute paths implementation

* [EGD-4498] Git ignore vim

* [EGD-4498] VFS core functions without cwd

* [EGD-4498] Other syscalls

* [EGD-4498] Code review fixes

* [EGD-4498] Code review #2

Signed-off-by: Lucjan Bryndza <lucjan.bryndza@mudita.com>

* [EGD-4498] Code review small fixes vol #3

Signed-off-by: Lucjan Bryndza <lucjan.bryndza@mudita.com>
2020-12-02 09:47:17 +01:00

34 lines
988 B
C++

// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
#include <list>
#include <string>
#include <type_traits>
namespace utils
{
template <template <class, class> class Container, class T, class Allocator = std::allocator<T>>
auto split(T strv, T delims = " ")
{
static_assert(std::is_same<T, std::string>::value || std::is_same<T, std::string_view>::value,
"std::string or std::string_view expected");
Container<T, Allocator> output;
size_t first = 0;
while (first < strv.size()) {
const auto second = strv.find_first_of(delims, first);
if (first != second)
output.emplace_back(strv.substr(first, second - first));
if (second == std::string_view::npos)
break;
first = second + 1;
}
return output;
}
} // namespace utils