Index: src/shared/ContentType.cpp |
diff --git a/src/shared/ContentType.cpp b/src/shared/ContentType.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d712206762f45cf4b218f43136091dc155a422f3 |
--- /dev/null |
+++ b/src/shared/ContentType.cpp |
@@ -0,0 +1,36 @@ |
+#include "ContentType.h" |
+ |
+// 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
|
+ |
+using AdblockPlus::FilterEngine; |
+ |
+namespace |
+{ |
+ typedef std::map<FilterEngine::ContentType, std::string> ContentTypeMap; |
+ ContentTypeMap CreateContentTypeMap() |
+ { |
+ ContentTypeMap contentTypes; |
+ contentTypes[FilterEngine::CONTENT_TYPE_OTHER] = "OTHER"; |
+ contentTypes[FilterEngine::CONTENT_TYPE_SCRIPT] = "SCRIPT"; |
+ contentTypes[FilterEngine::CONTENT_TYPE_IMAGE] = "IMAGE"; |
+ contentTypes[FilterEngine::CONTENT_TYPE_STYLESHEET] = "STYLESHEET"; |
+ contentTypes[FilterEngine::CONTENT_TYPE_OBJECT] = "OBJECT"; |
+ contentTypes[FilterEngine::CONTENT_TYPE_SUBDOCUMENT] = "SUBDOCUMENT"; |
+ contentTypes[FilterEngine::CONTENT_TYPE_DOCUMENT] = "DOCUMENT"; |
+ contentTypes[FilterEngine::CONTENT_TYPE_XMLHTTPREQUEST] = "XMLHTTPREQUEST"; |
+ contentTypes[FilterEngine::CONTENT_TYPE_OBJECT_SUBREQUEST] = "OBJECT_SUBREQUEST"; |
+ contentTypes[FilterEngine::CONTENT_TYPE_FONT] = "FONT"; |
+ contentTypes[FilterEngine::CONTENT_TYPE_MEDIA] = "MEDIA"; |
+ contentTypes[FilterEngine::CONTENT_TYPE_ELEMHIDE] = "ELEMHIDE"; |
+ return contentTypes; |
+ } |
+ const ContentTypeMap g_contentTypes = CreateContentTypeMap(); |
+} |
+ |
+std::string ContentTypeToString(AdblockPlus::FilterEngine::ContentType contentType) |
+{ |
+ ContentTypeMap::const_iterator it = g_contentTypes.find(contentType); |
+ if (it != g_contentTypes.end()) |
+ return it->second; |
+ throw std::invalid_argument("Argument is not a valid ContentType"); |
+} |