optional<T> from_string(const std::string& what) { auto uti = uniform_typeid<T>(); auto uv = from_string_impl(what); if (!uv || (*uv->ti) != typeid(T)) { // try again using the type name std::string tmp = uti->name(); tmp += " ( "; tmp += what; tmp += " )"; uv = from_string_impl(tmp); } if (uv && (*uv->ti) == typeid(T)) { return T{std::move(*reinterpret_cast<T*>(uv->val))}; } return none; }
private_key_info read_pem_private_key_from_string(const std::string& s) { return from_string_impl(s, &read_pem_private_key); }
certificate read_pem_certificate_from_string(const std::string& s) { return from_string_impl(s, &read_pem_certificate); }