/** * @file implementation.h * @brief Definitions for user facing functions for parsing URL and it's * components. */ #ifndef ADA_IMPLEMENTATION_H #define ADA_IMPLEMENTATION_H #include #include #include "ada/parser.h" #include "ada/common_defs.h" #include "ada/encoding_type.h" #include "ada/url.h" #include "ada/state.h" #include "ada/url_aggregator.h" namespace ada { enum class errors { generic_error }; template using result = tl::expected; /** * The URL parser takes a scalar value string input, with an optional null or * base URL base (default null). The parser assumes the input is a valid ASCII * or UTF-8 string. * * @param input the string input to analyze (must be valid ASCII or UTF-8) * @param base_url the optional URL input to use as a base url. * @return a parsed URL. */ template ada_warn_unused ada::result parse( std::string_view input, const result_type* base_url = nullptr); extern template ada::result parse(std::string_view input, const url* base_url); extern template ada::result parse( std::string_view input, const url_aggregator* base_url); /** * Verifies whether the URL strings can be parsed. The function assumes * that the inputs are valid ASCII or UTF-8 strings. * @see https://url.spec.whatwg.org/#dom-url-canparse * @return If URL can be parsed or not. */ bool can_parse(std::string_view input, const std::string_view* base_input = nullptr); /** * Computes a href string from a file path. The function assumes * that the input is a valid ASCII or UTF-8 string. * @return a href string (starts with file:://) */ std::string href_from_file(std::string_view path); } // namespace ada #endif // ADA_IMPLEMENTATION_H