summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-05-07 14:47:21 +0100
committerLinus Groh <mail@linusgroh.de>2021-05-07 15:43:23 +0100
commite37d9eabb149396721fdc23dc2e22cfa7a35f7bf (patch)
tree90f481310c61f9ac85336386381bc628d1dde5de
parent2ddd2d0866d3a34b7391d94326e9bd9160ade179 (diff)
downloadserenity-e37d9eabb149396721fdc23dc2e22cfa7a35f7bf.zip
file: Clean up mime type enumeration macro
- Improve naming - Order alphabetically - Remove duplicates
-rw-r--r--Userland/Utilities/file.cpp35
1 files changed, 16 insertions, 19 deletions
diff --git a/Userland/Utilities/file.cpp b/Userland/Utilities/file.cpp
index fa82fcdca2..7792d69382 100644
--- a/Userland/Utilities/file.cpp
+++ b/Userland/Utilities/file.cpp
@@ -34,29 +34,26 @@ static Optional<String> image_details(const String& description, const String& p
return String::formatted("{}, {} x {}", description, image_decoder->width(), image_decoder->height());
}
-#define ENUMERATE_DESCRIPTION_CONTENTS(V) \
- V("image/x-portable-bitmap", "PBM image data", image_details) \
- V("image/x-portable-graymap", "PGM image data", image_details) \
- V("image/png", "PNG image data", image_details) \
- V("image/x-portable-pixmap", "PPM image data", image_details) \
- V("image/gif", "GIF image data", image_details) \
- V("image/gif", "GIF image data", image_details) \
- V("image/bmp", "BMP image data", image_details) \
- V("image/jpeg", "JPEG image data", image_details) \
- V("image/jpeg", "JFIF image data", image_details) \
- V("image/jpeg", "JPEG image data", image_details) \
- V("text/x-shellscript", "POSIX shell script text executable", description_only) \
- V("application/json", "JSON data", description_only) \
- V("application/javascript", "JavaScript source", description_only) \
- V("text/markdown", "Markdown document", description_only)
+#define ENUMERATE_MIME_TYPE_DESCRIPTIONS \
+ __ENUMERATE_MIME_TYPE_DESCRIPTION("application/javascript", "JavaScript source", description_only) \
+ __ENUMERATE_MIME_TYPE_DESCRIPTION("application/json", "JSON data", description_only) \
+ __ENUMERATE_MIME_TYPE_DESCRIPTION("image/bmp", "BMP image data", image_details) \
+ __ENUMERATE_MIME_TYPE_DESCRIPTION("image/gif", "GIF image data", image_details) \
+ __ENUMERATE_MIME_TYPE_DESCRIPTION("image/jpeg", "JPEG image data", image_details) \
+ __ENUMERATE_MIME_TYPE_DESCRIPTION("image/png", "PNG image data", image_details) \
+ __ENUMERATE_MIME_TYPE_DESCRIPTION("image/x-portable-bitmap", "PBM image data", image_details) \
+ __ENUMERATE_MIME_TYPE_DESCRIPTION("image/x-portable-graymap", "PGM image data", image_details) \
+ __ENUMERATE_MIME_TYPE_DESCRIPTION("image/x-portable-pixmap", "PPM image data", image_details) \
+ __ENUMERATE_MIME_TYPE_DESCRIPTION("text/markdown", "Markdown document", description_only) \
+ __ENUMERATE_MIME_TYPE_DESCRIPTION("text/x-shellscript", "POSIX shell script text executable", description_only)
static Optional<String> get_description_from_mime_type(const String& mime, const String& path)
{
-#define V(mime_type, description, details) \
- if (String(mime_type) == mime) \
+#define __ENUMERATE_MIME_TYPE_DESCRIPTION(mime_type, description, details) \
+ if (String(mime_type) == mime) \
return details(String(description), path);
- ENUMERATE_DESCRIPTION_CONTENTS(V);
-#undef V
+ ENUMERATE_MIME_TYPE_DESCRIPTIONS;
+#undef __ENUMERATE_MIME_TYPE_DESCRIPTION
return {};
}