1 e0af76a7 2023-09-05 continue /* Detect MIME file type */
3 e0af76a7 2023-09-05 continue #include "utils.h"
5 e0af76a7 2023-09-05 continue #include <string>
6 e0af76a7 2023-09-05 continue #include <map>
8 e0af76a7 2023-09-05 continue #pragma once
11 e0af76a7 2023-09-05 continue namespace vostok
15 e0af76a7 2023-09-05 continue class Mime
18 e0af76a7 2023-09-05 continue /* Read and parse "mime.types" file content */
19 e0af76a7 2023-09-05 continue bool parse_db(NotNull<czstring> sz_path);
21 e0af76a7 2023-09-05 continue /* Lookup MIME type by FS path */
22 e0af76a7 2023-09-05 continue const std::string *lookup(const std::string &path) const;
24 e0af76a7 2023-09-05 continue /* Get file extension from path. Return path.end() if no extension. */
25 e0af76a7 2023-09-05 continue static std::string::const_iterator get_ext(const std::string &path);
27 e0af76a7 2023-09-05 continue protected:
28 e0af76a7 2023-09-05 continue class Key
31 e0af76a7 2023-09-05 continue explicit Key(/* in/out */ std::string &string) {m_string.swap(string);}
32 e0af76a7 2023-09-05 continue explicit Key(const char *p) : m_p(p) {}
33 e0af76a7 2023-09-05 continue const char *c_str() const { return m_p ? m_p : m_string.c_str(); }
35 e0af76a7 2023-09-05 continue private:
36 e0af76a7 2023-09-05 continue std::string m_string;
37 e0af76a7 2023-09-05 continue const char *m_p{nullptr};
40 e0af76a7 2023-09-05 continue private:
41 e0af76a7 2023-09-05 continue class Less
44 e0af76a7 2023-09-05 continue bool operator ()(const Key &key1, const Key &key2) const;
46 e0af76a7 2023-09-05 continue std::map<Key, std::string, Less> m_map;
50 e0af76a7 2023-09-05 continue } // namespace vostok