Nix 2.26.3
Nix, the purely functional package manager; unstable internal interfaces
 
Loading...
Searching...
No Matches
split.hh
Go to the documentation of this file.
1#pragma once
3
4#include <optional>
5#include <string_view>
6
7#include "util.hh"
8
9namespace nix {
10
17static inline std::optional<std::string_view> splitPrefixTo(std::string_view & string, char separator) {
18 auto sepInstance = string.find(separator);
19
20 if (sepInstance != std::string_view::npos) {
21 auto prefix = string.substr(0, sepInstance);
22 string.remove_prefix(sepInstance+1);
23 return prefix;
24 }
25
26 return std::nullopt;
27}
28
29static inline bool splitPrefix(std::string_view & string, std::string_view prefix) {
30 bool res = hasPrefix(string, prefix);
31 if (res)
32 string.remove_prefix(prefix.length());
33 return res;
34}
35
36}
Strings res
Definition lexer.l:2566