clangd broke because it can't look through symlinks. compile_commands manipulation does not fix it, clangd configuration does not fix it, a vfs overlay does not fix it, and while a combination of those can fix it with a bind mount in place that's just too cursed to even consider clangd bug: https://github.com/llvm/llvm-project/issues/116877 Change-Id: I8e3e8489548eb3a7aa65ac9d12a5ec8abf814aec
35 lines
908 B
C++
35 lines
908 B
C++
#pragma once
|
|
///@file
|
|
|
|
#include <optional>
|
|
#include <string_view>
|
|
|
|
namespace nix {
|
|
|
|
/**
|
|
* If `separator` is found, we return the portion of the string before the
|
|
* separator, and modify the string argument to contain only the part after the
|
|
* separator. Otherwise, we return `std::nullopt`, and we leave the argument
|
|
* string alone.
|
|
*/
|
|
static inline std::optional<std::string_view> splitPrefixTo(std::string_view & string, char separator) {
|
|
auto sepInstance = string.find(separator);
|
|
|
|
if (sepInstance != std::string_view::npos) {
|
|
auto prefix = string.substr(0, sepInstance);
|
|
string.remove_prefix(sepInstance+1);
|
|
return prefix;
|
|
}
|
|
|
|
return std::nullopt;
|
|
}
|
|
|
|
static inline bool splitPrefix(std::string_view & string, std::string_view prefix) {
|
|
bool res = string.starts_with(prefix);
|
|
if (res)
|
|
string.remove_prefix(prefix.length());
|
|
return res;
|
|
}
|
|
|
|
}
|