mirror of
https://github.com/NixOS/nix
synced 2025-06-27 00:11:17 +02:00
Trivial changes from the lazy-trees branch
This commit is contained in:
parent
c4a6113800
commit
703d863a48
62 changed files with 394 additions and 248 deletions
|
@ -510,6 +510,17 @@ std::optional<N> string2Float(const std::string_view s)
|
|||
}
|
||||
|
||||
|
||||
/* Convert a little-endian integer to host order. */
|
||||
template<typename T>
|
||||
T readLittleEndian(unsigned char * p)
|
||||
{
|
||||
T x = 0;
|
||||
for (size_t i = 0; i < sizeof(x); ++i)
|
||||
x |= ((T) *p++) << (i * 8);
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
/* Return true iff `s' starts with `prefix'. */
|
||||
bool hasPrefix(std::string_view s, std::string_view prefix);
|
||||
|
||||
|
@ -563,6 +574,12 @@ std::string base64Decode(std::string_view s);
|
|||
std::string stripIndentation(std::string_view s);
|
||||
|
||||
|
||||
/* Get the prefix of 's' up to and excluding the next line break (LF
|
||||
optionally preceded by CR), and the remainder following the line
|
||||
break. */
|
||||
std::pair<std::string_view, std::string_view> getLine(std::string_view s);
|
||||
|
||||
|
||||
/* Get a value for the specified key from an associate container. */
|
||||
template <class T>
|
||||
const typename T::mapped_type * get(const T & map, const typename T::key_type & key)
|
||||
|
@ -737,4 +754,11 @@ inline std::string operator + (std::string && s, std::string_view s2)
|
|||
return std::move(s);
|
||||
}
|
||||
|
||||
inline std::string operator + (std::string_view s1, const char * s2)
|
||||
{
|
||||
std::string s(s1);
|
||||
s.append(s2);
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue