mirror of
https://github.com/NixOS/nix.git
synced 2025-11-14 22:42:41 +01:00
Factor out lookupExecutable and other PATH improvments
This ended up motivating a good deal of other infra improvements in order to get Windows right: - `OsString` to complement `std::filesystem::path` - env var code for working with the underlying `OsString`s - Rename `PATHNG_LITERAL` to `OS_STR` - `NativePathTrait` renamed to `OsPathTrait`, given a character template parameter until #9205 is complete. Split `tests.cc` matching split of `util.{cc,hh}` last year. Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
This commit is contained in:
parent
0836888002
commit
6c861b9c51
32 changed files with 616 additions and 97 deletions
|
|
@ -13,6 +13,12 @@ namespace nix {
|
|||
*
|
||||
* See also `basicSplitString()`, which preserves empty strings between separators, as well as at the start and end.
|
||||
*/
|
||||
template<class C, class CharT = char>
|
||||
C basicTokenizeString(std::basic_string_view<CharT> s, std::basic_string_view<CharT> separators);
|
||||
|
||||
/**
|
||||
* Like `basicTokenizeString` but specialized to the default `char`
|
||||
*/
|
||||
template<class C>
|
||||
C tokenizeString(std::string_view s, std::string_view separators = " \t\n\r");
|
||||
|
||||
|
|
@ -20,6 +26,20 @@ extern template std::list<std::string> tokenizeString(std::string_view s, std::s
|
|||
extern template std::set<std::string> tokenizeString(std::string_view s, std::string_view separators);
|
||||
extern template std::vector<std::string> tokenizeString(std::string_view s, std::string_view separators);
|
||||
|
||||
/**
|
||||
* Split a string, preserving empty strings between separators, as well as at the start and end.
|
||||
*
|
||||
* Returns a non-empty collection of strings.
|
||||
*/
|
||||
template<class C, class CharT = char>
|
||||
C basicSplitString(std::basic_string_view<CharT> s, std::basic_string_view<CharT> separators);
|
||||
template<typename C>
|
||||
C splitString(std::string_view s, std::string_view separators);
|
||||
|
||||
extern template std::list<std::string> splitString(std::string_view s, std::string_view separators);
|
||||
extern template std::set<std::string> splitString(std::string_view s, std::string_view separators);
|
||||
extern template std::vector<std::string> splitString(std::string_view s, std::string_view separators);
|
||||
|
||||
/**
|
||||
* Concatenate the given strings with a separator between the elements.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue