| Index: src/shared/ContentType.cpp | 
| =================================================================== | 
| new file mode 100644 | 
| --- /dev/null | 
| +++ b/src/shared/ContentType.cpp | 
| @@ -0,0 +1,36 @@ | 
| +#include "ContentType.h" | 
| + | 
| +// Based on impl from libadblockplus | 
| + | 
| +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"); | 
| +} |