.enable_warnings = !opts.disable_warnings, | .enable_warnings = !opts.disable_warnings, | ||||
}; | }; | ||||
auto man = package_manifest::load_from_directory(opts.project_dir).value_or(package_manifest{}); | |||||
auto man | |||||
= value_or(package_manifest::load_from_directory(opts.project_dir), package_manifest{}); | |||||
auto cat_path = opts.pkg_db_dir.value_or(pkg_db::default_path()); | auto cat_path = opts.pkg_db_dir.value_or(pkg_db::default_path()); | ||||
auto repo_path = opts.pkg_cache_dir.value_or(pkg_cache::default_local_path()); | auto repo_path = opts.pkg_cache_dir.value_or(pkg_cache::default_local_path()); | ||||
sdist sdist::from_directory(path_ref where) { | sdist sdist::from_directory(path_ref where) { | ||||
auto pkg_man = package_manifest::load_from_directory(where); | auto pkg_man = package_manifest::load_from_directory(where); | ||||
// Code paths should only call here if they *know* that the sdist is valid | // Code paths should only call here if they *know* that the sdist is valid | ||||
if (!pkg_man.has_value()) { | |||||
if (!pkg_man) { | |||||
throw_user_error<errc::invalid_pkg_filesystem>( | throw_user_error<errc::invalid_pkg_filesystem>( | ||||
"The given directory [{}] does not contain a package manifest file. All source " | "The given directory [{}] does not contain a package manifest file. All source " | ||||
"distribution directories are required to contain a package manifest.", | "distribution directories are required to contain a package manifest.", |
using boost::leaf::current_error; | using boost::leaf::current_error; | ||||
using boost::leaf::error_id; | using boost::leaf::error_id; | ||||
using boost::leaf::new_error; | using boost::leaf::new_error; | ||||
using boost::leaf::result; | |||||
template <typename T> | |||||
class result : public boost::leaf::result<T> { | |||||
public: | |||||
using result_base = boost::leaf::result<T>; | |||||
using result_base::result; | |||||
template <neo::convertible_to<result_base> Other> | |||||
result(Other&& oth) noexcept | |||||
: result_base(static_cast<result_base>(NEO_FWD(oth))) {} | |||||
constexpr bool has_value() const noexcept { return !!*this; } | |||||
template <typename U> | |||||
constexpr T value_or(U&& u) const noexcept { | |||||
if (has_value()) { | |||||
return **this; | |||||
} else { | |||||
return T(NEO_FWD(u)); | |||||
} | |||||
} | |||||
}; | |||||
template <typename T, neo::convertible_to<T> U> | |||||
constexpr T value_or(const result<T>& res, U&& arg) { | |||||
return res ? res.value() : static_cast<T>(arg); | |||||
} | |||||
/** | /** | ||||
* @brief Error object representing a captured system_error exception | * @brief Error object representing a captured system_error exception | ||||
auto NEO_CONCAT(_err_info_, __LINE__) = boost::leaf::on_error(DDS_E_ARG(__VA_ARGS__)) | auto NEO_CONCAT(_err_info_, __LINE__) = boost::leaf::on_error(DDS_E_ARG(__VA_ARGS__)) | ||||
} // namespace dds | } // namespace dds | ||||
template <typename T> | |||||
struct boost::leaf::is_result_type<dds::result<T>> : std::true_type {}; |