/* Detect MIME file type */ #include "utils.h" #include #include #pragma once namespace vostok { class Mime { public: /* Read and parse "mime.types" file content */ bool parse_db(NotNull sz_path); /* Lookup MIME type by FS path */ const std::string *lookup(const std::string &path) const; /* Get file extension from path. Return path.end() if no extension. */ static std::string::const_iterator get_ext(const std::string &path); protected: class Key { public: explicit Key(/* in/out */ std::string &string) {m_string.swap(string);} explicit Key(const char *p) : m_p(p) {} const char *c_str() const { return m_p ? m_p : m_string.c_str(); } private: std::string m_string; const char *m_p{nullptr}; }; private: class Less { public: bool operator ()(const Key &key1, const Key &key2) const; }; std::map m_map; }; } // namespace vostok