mirror of
https://github.com/MadeOfJelly/MushMachine.git
synced 2025-06-18 18:56:36 +02:00
initial import, >900commits predate this
This commit is contained in:
13
framework/std_utils/CMakeLists.txt
Normal file
13
framework/std_utils/CMakeLists.txt
Normal file
@ -0,0 +1,13 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
project(std_utils CXX)
|
||||
|
||||
add_library(std_utils INTERFACE)
|
||||
|
||||
target_include_directories(std_utils INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/src")
|
||||
|
||||
# TODO: test
|
||||
#if (BUILD_TESTING)
|
||||
#add_subdirectory(test)
|
||||
#endif()
|
||||
|
||||
|
27
framework/std_utils/src/mm/string_view_split.hpp
Normal file
27
framework/std_utils/src/mm/string_view_split.hpp
Normal file
@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <string_view>
|
||||
|
||||
namespace MM::std_utils {
|
||||
|
||||
// src : https://marcoarena.wordpress.com/2017/01/03/string_view-odi-et-amo/
|
||||
inline std::vector<std::string_view> split(std::string_view str, const char* delims) {
|
||||
std::vector<std::string_view> ret;
|
||||
|
||||
std::string_view::size_type start = 0;
|
||||
auto pos = str.find_first_of(delims, start);
|
||||
while (pos != std::string_view::npos) {
|
||||
if (pos != start) {
|
||||
ret.push_back(str.substr(start, pos - start));
|
||||
}
|
||||
start = pos + 1;
|
||||
pos = str.find_first_of(delims, start);
|
||||
}
|
||||
if (start < str.length())
|
||||
ret.push_back(str.substr(start, str.length() - start));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // MM::std_utils
|
||||
|
Reference in New Issue
Block a user