Flox Package Database 1
CRUD Operations on Nix Package Metadata
|
Miscellaneous helper functions. More...
#include <filesystem>
#include <initializer_list>
#include <sstream>
#include <string>
#include <string_view>
#include <variant>
#include <vector>
#include <nix/attrs.hh>
#include <nix/flake/flakeref.hh>
#include <nlohmann/json.hpp>
#include "flox/core/exceptions.hh"
#include "flox/core/types.hh"
Go to the source code of this file.
Classes | |
struct | overloaded< Ts > |
Helper type for std::visit( overloaded { ... }, x ); pattern. More... | |
struct | nlohmann::adl_serializer< std::variant< A, B > > |
Variants ( Eithers ) of two elements to/from JSON. More... | |
struct | nlohmann::adl_serializer< std::variant< A, Types... > > |
Variants ( Eithers ) of any number of elements to/from JSON. More... | |
struct | nlohmann::adl_serializer< nix::fetchers::Attrs > |
nix::fetchers::Attrs to/from JSON More... | |
struct | nlohmann::adl_serializer< nix::FlakeRef > |
nix::FlakeRef to/from JSON. More... | |
Namespaces | |
namespace | nlohmann |
Extension to the ‘nlohmann::json’ serializer to support additional Argument Dependent Lookup (ADL) types. | |
namespace | flox |
Interfaces for use by flox . | |
Functions | |
template<class... Ts> | |
overloaded (Ts...) -> overloaded< Ts... > | |
static const std::vector< std::string > & | flox::getDefaultSystems () |
Systems to resolve/search in. | |
static const std::vector< std::string > & | flox::getDefaultSubtrees () |
‘flake’ subtrees to resolve/search in. | |
bool | flox::isSQLiteDb (const std::string &dbPath) |
Detect if a path is a SQLite3 database file. | |
nix::FlakeRef | flox::parseFlakeRef (const std::string &flakeRef) |
Parse a flake reference from either a JSON attrset or URI string. | |
nlohmann::json | flox::parseOrReadJSONObject (const std::string &jsonOrPath) |
Parse a JSON object from an inline string or a path to a JSON file. | |
nlohmann::json | flox::tomlToJSON (std::string_view toml) |
Convert a TOML string to JSON. | |
nlohmann::json | flox::yamlToJSON (std::string_view yaml) |
Convert a YAML string to JSON. | |
nlohmann::json | flox::readAndCoerceJSON (const std::filesystem::path &path) |
Read a file and coerce its contents to JSON based on its extension. | |
std::vector< std::string > | flox::splitAttrPath (std::string_view path) |
Split an attribute path string. | |
bool | flox::isUInt (std::string_view str) |
Is the string @str a positive natural number? | |
bool | flox::hasPrefix (std::string_view prefix, std::string_view str) |
Does the string @str have the prefix prefix? | |
std::string & | flox::ltrim (std::string &str) |
trim from start ( in place ). | |
std::string & | flox::rtrim (std::string &str) |
trim from end ( in place ). | |
std::string & | flox::trim (std::string &str) |
trim from both ends ( in place ). | |
std::string | flox::ltrim_copy (std::string_view str) |
trim from start ( copying ). | |
std::string | flox::rtrim_copy (std::string_view str) |
trim from end ( copying ). | |
std::string | flox::trim_copy (std::string_view str) |
trim from both ends ( copying ). | |
std::string | flox::extract_json_errmsg (nlohmann::json::exception &err) |
Extract the user-friendly portion of a nlohmann::json::exception. | |
template<typename Exception = FloxException> | |
static void | flox::assertIsJSONObject (const nlohmann::json &value, const std::string &who="JSON value") |
Assert that a JSON value is an object, or throw an exception. | |
template<typename T > | |
std::vector< T > | flox::merge_vectors (const std::vector< T > &lower, const std::vector< T > &higher) |
Merge two std::vector containers by putting all elements of the higher prioirty vector first, then appending the deduplicated keys of the lower priortity vector. | |
template<typename T > | |
std::vector< std::optional< T > > | flox::vectorMapOptional (const std::vector< T > &orig) |
Constructs a std::vector<std::optional<T>> from a std::vector<T>. | |
std::string | flox::displayableGlobbedPath (const AttrPathGlob &attrs) |
Convert a AttrPathGlob to a string for display. | |
Miscellaneous helper functions.