#pragma once
#include <optional>
#include <string>
#include <vector>
namespace solidity::frontend
{
using SourceUnitName = std::string;
using SourceCode = std::string;
using ImportPath = std::string;
class ImportRemapper
{
public:
struct Remapping
{
bool operator!=(Remapping const& _other) const noexcept { return !(*this == _other); }
bool operator==(Remapping const& _other) const noexcept
{
return
context == _other.context &&
prefix == _other.prefix &&
target == _other.target;
}
std::string context;
std::string prefix;
std::string target;
};
void clear() { m_remappings.clear(); }
void setRemappings(std::vector<Remapping> _remappings);
std::vector<Remapping> const& remappings() const noexcept { return m_remappings; }
SourceUnitName apply(ImportPath const& _path, std::string const& _context) const;
static bool isRemapping(std::string_view _input);
static std::optional<Remapping> parseRemapping(std::string_view _input);
private:
std::vector<Remapping> m_remappings = {};
};
}