3#include <llvm/ADT/StringRef.h>
4#include <llvm/Support/Error.h>
5#include <llvm/Support/Registry.h>
20 URI(llvm::StringRef Scheme, llvm::StringRef Authority, llvm::StringRef Body);
23 llvm::StringRef
scheme()
const {
return Scheme; }
25 llvm::StringRef
authority()
const {
return Authority; }
27 llvm::StringRef
body()
const {
return Body; }
34 static llvm::Expected<URI>
create(llvm::StringRef AbsolutePath,
35 llvm::StringRef Scheme);
39 static URI create(llvm::StringRef AbsolutePath);
46 static llvm::Expected<URI>
parse(llvm::StringRef Uri);
53 static llvm::Expected<std::string>
resolve(
const URI &U,
54 llvm::StringRef HintPath =
"");
57 static llvm::Expected<std::string>
resolve(llvm::StringRef FileURI,
58 llvm::StringRef HintPath =
"");
64 static llvm::Expected<std::string>
resolvePath(llvm::StringRef AbsPath,
65 llvm::StringRef HintPath =
"");
78 return std::tie(LHS.Scheme, LHS.Authority, LHS.Body) ==
79 std::tie(RHS.Scheme, RHS.Authority, RHS.Body);
83 return std::tie(LHS.Scheme, LHS.Authority, LHS.Body) <
84 std::tie(RHS.Scheme, RHS.Authority, RHS.Body);
91 std::string Authority;
105 virtual llvm::Expected<std::string>
107 llvm::StringRef HintPath)
const = 0;
109 virtual llvm::Expected<URI>
virtual ~URIScheme()=default
virtual llvm::Expected< std::string > getAbsolutePath(llvm::StringRef Authority, llvm::StringRef Body, llvm::StringRef HintPath) const =0
virtual llvm::Expected< URI > uriFromAbsolutePath(llvm::StringRef AbsolutePath) const =0
virtual llvm::Expected< std::string > getIncludeSpelling(const URI &U) const
friend bool operator<(const URI &LHS, const URI &RHS)
static llvm::Expected< std::string > resolve(const URI &U, llvm::StringRef HintPath="")
static llvm::Expected< URI > parse(llvm::StringRef Uri)
static llvm::Expected< URI > create(llvm::StringRef AbsolutePath, llvm::StringRef Scheme)
llvm::StringRef authority() const
Returns decoded authority e.g. "reviews.lvm.org".
llvm::StringRef body() const
Returns decoded body e.g. "/D41946".
llvm::StringRef scheme() const
Returns decoded scheme e.g. "https".
std::string toString() const
Returns a string URI with all components percent-encoded.
static llvm::Expected< std::string > includeSpelling(const URI &U)
friend bool operator==(const URI &LHS, const URI &RHS)
static URI createFile(llvm::StringRef AbsolutePath)
This creates a file:// URI for AbsolutePath. The path must be absolute.
static llvm::Expected< std::string > resolvePath(llvm::StringRef AbsPath, llvm::StringRef HintPath="")
Whether current platform treats paths case insensitively.
llvm::Registry< URIScheme > URISchemeRegistry