Left: | ||
Right: |
OLD | NEW |
---|---|
(Empty) | |
1 #include "ContentType.h" | |
2 | |
3 // Based on impl from libadblockplus | |
Eric
2015/01/13 17:29:36
Again, why not just use the existing implementatio
sergei
2015/01/28 13:44:45
I've tried it and the size is indeed suspiciously
Oleksandr
2015/01/29 15:36:30
While I personally agree that it would be best to
| |
4 | |
5 using AdblockPlus::FilterEngine; | |
6 | |
7 namespace | |
8 { | |
9 typedef std::map<FilterEngine::ContentType, std::string> ContentTypeMap; | |
10 ContentTypeMap CreateContentTypeMap() | |
11 { | |
12 ContentTypeMap contentTypes; | |
13 contentTypes[FilterEngine::CONTENT_TYPE_OTHER] = "OTHER"; | |
14 contentTypes[FilterEngine::CONTENT_TYPE_SCRIPT] = "SCRIPT"; | |
15 contentTypes[FilterEngine::CONTENT_TYPE_IMAGE] = "IMAGE"; | |
16 contentTypes[FilterEngine::CONTENT_TYPE_STYLESHEET] = "STYLESHEET"; | |
17 contentTypes[FilterEngine::CONTENT_TYPE_OBJECT] = "OBJECT"; | |
18 contentTypes[FilterEngine::CONTENT_TYPE_SUBDOCUMENT] = "SUBDOCUMENT"; | |
19 contentTypes[FilterEngine::CONTENT_TYPE_DOCUMENT] = "DOCUMENT"; | |
20 contentTypes[FilterEngine::CONTENT_TYPE_XMLHTTPREQUEST] = "XMLHTTPREQUEST"; | |
21 contentTypes[FilterEngine::CONTENT_TYPE_OBJECT_SUBREQUEST] = "OBJECT_SUBREQU EST"; | |
22 contentTypes[FilterEngine::CONTENT_TYPE_FONT] = "FONT"; | |
23 contentTypes[FilterEngine::CONTENT_TYPE_MEDIA] = "MEDIA"; | |
24 contentTypes[FilterEngine::CONTENT_TYPE_ELEMHIDE] = "ELEMHIDE"; | |
25 return contentTypes; | |
26 } | |
27 const ContentTypeMap g_contentTypes = CreateContentTypeMap(); | |
28 } | |
29 | |
30 std::string ContentTypeToString(AdblockPlus::FilterEngine::ContentType contentTy pe) | |
31 { | |
32 ContentTypeMap::const_iterator it = g_contentTypes.find(contentType); | |
33 if (it != g_contentTypes.end()) | |
34 return it->second; | |
35 throw std::invalid_argument("Argument is not a valid ContentType"); | |
36 } | |
OLD | NEW |