mirror of
https://github.com/NixOS/nix.git
synced 2025-11-16 23:42:43 +01:00
Apply clang-format universally.
* It is tough to contribute to a project that doesn't use a formatter, * It is extra hard to contribute to a project which has configured the formatter, but ignores it for some files * Code formatting makes it harder to hide obscure / weird bugs by accident or on purpose, Let's rip the bandaid off? Note that PRs currently in flight should be able to be merged relatively easily by applying `clang-format` to their tip prior to merge.
This commit is contained in:
parent
41bf87ec70
commit
e4f62e4608
587 changed files with 23258 additions and 23135 deletions
|
|
@ -10,20 +10,20 @@ namespace nix {
|
|||
const nlohmann::json * get(const nlohmann::json & map, const std::string & key)
|
||||
{
|
||||
auto i = map.find(key);
|
||||
if (i == map.end()) return nullptr;
|
||||
if (i == map.end())
|
||||
return nullptr;
|
||||
return &*i;
|
||||
}
|
||||
|
||||
nlohmann::json * get(nlohmann::json & map, const std::string & key)
|
||||
{
|
||||
auto i = map.find(key);
|
||||
if (i == map.end()) return nullptr;
|
||||
if (i == map.end())
|
||||
return nullptr;
|
||||
return &*i;
|
||||
}
|
||||
|
||||
const nlohmann::json & valueAt(
|
||||
const nlohmann::json::object_t & map,
|
||||
const std::string & key)
|
||||
const nlohmann::json & valueAt(const nlohmann::json::object_t & map, const std::string & key)
|
||||
{
|
||||
if (!map.contains(key))
|
||||
throw Error("Expected JSON object to contain key '%s' but it doesn't: %s", key, nlohmann::json(map).dump());
|
||||
|
|
@ -36,7 +36,7 @@ std::optional<nlohmann::json> optionalValueAt(const nlohmann::json::object_t & m
|
|||
if (!map.contains(key))
|
||||
return std::nullopt;
|
||||
|
||||
return std::optional { map.at(key) };
|
||||
return std::optional{map.at(key)};
|
||||
}
|
||||
|
||||
std::optional<nlohmann::json> nullableValueAt(const nlohmann::json::object_t & map, const std::string & key)
|
||||
|
|
@ -46,7 +46,7 @@ std::optional<nlohmann::json> nullableValueAt(const nlohmann::json::object_t & m
|
|||
if (value.is_null())
|
||||
return std::nullopt;
|
||||
|
||||
return std::optional { std::move(value) };
|
||||
return std::optional{std::move(value)};
|
||||
}
|
||||
|
||||
const nlohmann::json * getNullable(const nlohmann::json & value)
|
||||
|
|
@ -63,16 +63,14 @@ const nlohmann::json * getNullable(const nlohmann::json & value)
|
|||
* functions. It is too cumbersome and easy to forget to expect regular
|
||||
* JSON code to use it directly.
|
||||
*/
|
||||
static const nlohmann::json & ensureType(
|
||||
const nlohmann::json & value,
|
||||
nlohmann::json::value_type expectedType
|
||||
)
|
||||
static const nlohmann::json & ensureType(const nlohmann::json & value, nlohmann::json::value_type expectedType)
|
||||
{
|
||||
if (value.type() != expectedType)
|
||||
throw Error(
|
||||
"Expected JSON value to be of type '%s' but it is of type '%s': %s",
|
||||
nlohmann::json(expectedType).type_name(),
|
||||
value.type_name(), value.dump());
|
||||
value.type_name(),
|
||||
value.dump());
|
||||
|
||||
return value;
|
||||
}
|
||||
|
|
@ -102,8 +100,7 @@ const nlohmann::json::number_unsigned_t & getUnsigned(const nlohmann::json & val
|
|||
typeName = value.is_number_float() ? "floating point number" : "signed integral number";
|
||||
}
|
||||
throw Error(
|
||||
"Expected JSON value to be an unsigned integral number but it is of type '%s': %s",
|
||||
typeName, value.dump());
|
||||
"Expected JSON value to be an unsigned integral number but it is of type '%s': %s", typeName, value.dump());
|
||||
}
|
||||
|
||||
const nlohmann::json::boolean_t & getBoolean(const nlohmann::json & value)
|
||||
|
|
@ -146,4 +143,4 @@ StringSet getStringSet(const nlohmann::json & value)
|
|||
|
||||
return stringSet;
|
||||
}
|
||||
}
|
||||
} // namespace nix
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue