/* */ #ifndef D_URI_H #define D_URI_H #include "common.h" #include #include "uri_split.h" namespace aria2 { namespace uri { struct UriStruct { std::string protocol; std::string host; uint16_t port; std::string dir; std::string file; std::string query; std::string username; std::string password; bool hasPassword; bool ipv6LiteralAddress; UriStruct(); UriStruct(const UriStruct& c); ~UriStruct(); UriStruct& operator=(const UriStruct& c); void swap(UriStruct& other); }; void swap(UriStruct& lhs, UriStruct& rhs); // Splits URI uri into components and stores them into result. On // success returns true. Otherwise returns false and result is // undefined. bool parse(UriStruct& result, const std::string& uri); // Returns string specified by field in res. The base pointer in res // is given as base. If the given field is not stored in res, returns // empty string. std::string getFieldString(const uri_split_result& res, int field, const char* base); std::string construct(const UriStruct& us); std::string joinUri(const std::string& baseUri, const std::string& uri); std::string joinPath(const std::string& basePath, const std::string& newPath); // Normalizes path so that: 1) it does not contain successive / and 2) // resolve path component '.' and '..'. If there is not enough path // component to resolve '..', those '..' are discarded. The resulting // path starts / only if path starts with /. std::string normalizePath(std::string path); } // namespace uri } // namespace aria2 #endif // D_URI_H