Basic support C++20 named module. (#12)
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <Support/Error.h>
|
||||
|
||||
#include "Support/Support.h"
|
||||
|
||||
namespace clice {
|
||||
|
||||
@@ -14,19 +15,34 @@ public:
|
||||
|
||||
bool operator== (const URI&) const = default;
|
||||
|
||||
/// Returns decoded scheme e.g. "https"
|
||||
llvm::StringRef scheme() const { return m_scheme; }
|
||||
|
||||
/// Returns decoded authority e.g. "reviews.lvm.org"
|
||||
llvm::StringRef authority() const { return m_authority; }
|
||||
|
||||
/// Returns decoded body e.g. "/D41946"
|
||||
llvm::StringRef body() const { return m_body; }
|
||||
/// Construct a URI object from the given file path.
|
||||
static URI from(llvm::StringRef file);
|
||||
|
||||
/// Parse the given URI string to create a URI object.
|
||||
static llvm::Expected<URI> parse(llvm::StringRef content);
|
||||
|
||||
/// Same as `parse`, but will crash if failed.
|
||||
static std::string resolve(llvm::StringRef content);
|
||||
|
||||
/// Returns decoded scheme e.g. "https"
|
||||
llvm::StringRef scheme() const {
|
||||
return m_scheme;
|
||||
}
|
||||
|
||||
/// Returns decoded authority e.g. "reviews.llvm.org"
|
||||
llvm::StringRef authority() const {
|
||||
return m_authority;
|
||||
}
|
||||
|
||||
/// Returns decoded body e.g. "/D41946"
|
||||
llvm::StringRef body() const {
|
||||
return m_body;
|
||||
}
|
||||
|
||||
std::string toString() const {
|
||||
return std::format("{}://{}{}", m_scheme, m_authority, m_body);
|
||||
}
|
||||
|
||||
private:
|
||||
std::string m_scheme;
|
||||
std::string m_authority;
|
||||
|
||||
Reference in New Issue
Block a user