#ifndef MYGRATE_OUTPUT_PQ_TYPEMAPPER_H #define MYGRATE_OUTPUT_PQ_TYPEMAPPER_H #include #include #include #include #include namespace MyGrate::Output::Pq { class TypeMapper { public: class ObsRegex : public std::regex { public: explicit ObsRegex(const std::string & src, std::regex_constants::syntax_option_type sot = {}) : std::regex {src, sot}, src {src} { } const std::string src; }; struct Mapping { virtual ~Mapping() = default; virtual std::optional map(std::string_view t, std::string_view n) const = 0; }; using MappingPtr = std::unique_ptr; struct RegexMapper : public Mapping { RegexMapper(std::optional, std::optional, std::string); std::optional map(std::string_view t, std::string_view n) const override; std::optional typeMatch; std::optional columnMatch; std::string targetType; }; TypeMapper(); std::string_view map(std::string_view t, std::string_view n) const; private: std::vector mappings; }; TypeMapper::ObsRegex operator""_r(const char * input, std::size_t); } #endif